kobik
kobik

Reputation: 21252

SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE) return 0

if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &uiType, 0) != 0) {      
  Debug(uiType); // shows 0
}

This happened to me on Remote desktop with Windows Server 2012 R2. According to the docs there are 2 possible values:

The possible values are FE_FONTSMOOTHINGSTANDARD (1) and FE_FONTSMOOTHINGCLEARTYPE (2).

I also found this similar question but no answers: Meaning of, SystemInformation.FontSmoothingType's return value

Does anyone knows what uiType 0 means?


EDIT: On that remote machine SPI_GETFONTSMOOTHING returns 0.

Determines whether the font smoothing feature is enabled.

The docs are obviously wrong. I would assume the correct way should be to first check the SPI_GETFONTSMOOTHING and only then SPI_GETFONTSMOOTHINGTYPE

Upvotes: 3

Views: 495

Answers (1)

Cody Gray
Cody Gray

Reputation: 244913

The font smoothing "type" (SPI_GETFONTSMOOTHINGTYPE) is only meaningful if font smoothing is enabled (SPI_GETFONTSMOOTHING). The same is true for all of the other font smoothing attributes, like SPI_GETFONTSMOOTHINGCONTRAST and SPI_GETFONTSMOOTHINGORIENTATION.

You should check SPI_GETFONTSMOOTHING first. If it returns TRUE (non-zero), then you can query the other font smoothing attributes. If it returns FALSE (zero), then you are done. If you request the other font smoothing attributes, you will get meaningless noise.

So, in other words, your edit is correct, and the MSDN documentation could afford to be improved. I'm not sure it is "incorrect"; this seems like a pretty obvious design to me. It is a C API; calling it with the wrong parameters can be assumed to lead to wrong results.

The documentation does say that the only possible return values for SPI_GETFONTSMOOTHINGTYPE are FE_FONTSMOOTHINGSTANDARD and FE_FONTSMOOTHINGCLEARTYPE, so it would not be possible for this parameter to indicate that font smoothing is disabled or not applicable. The current implementation of SystemParametersInfo might return 0 for the case where font smoothing is disabled, but since the documentation doesn't explicitly say that you can rely on that, you shouldn't rely on it.

Upvotes: 4

Related Questions