views:

190

answers:

1

I do not wish to use compatible text rendering, but I do not wish to use

Application.SetCompatibleTextRenderingDefault(false);

Naturally, I thought all I had to do was set each label's UseCompatibleTextRendering property to false. The Forms Designer, however, apparently only generates code to set the property if UseCompatibleTextRendering is set to true.

No problem, I thought, that must mean that UseCompatibleTextRendering is initialized to false by default. Yet when I start up my form, lo and behold, I see ugly CompatibleTextRendering. So, a question:

1) Why on earth isn't the designer adding code for UseCompatibleTextRendering when I set it to false and it is when I set it to true, if the default is true?

+1  A: 

The designer does not add code for setting UseCompatibleTextRendering to false, because false is the default value.

So, why do the controls use compatible text rendering by default, if the default value of the property is false, that seems to be... odd? Well, the Application.SetCompatibleTextRenderingDefault method assigns the given value to a static field in the Control class, and the static constructor of the Control class initializes this field to true.

So, removing the line Application.SetCompatibleTextRenderingDefault(false); will cause the application to use compatible text rendering, contrary to what you might think based on the default value of the UseCompatibleTextRendering property.

The only reasonable solution that I can see is to simply leave the automatically generated call to Application.SetCompatibleTextRenderingDefault where it is.

Fredrik Mörk
Thanks. Why Control.UseCompatibleTextRenderingDefault is initialized to true baffles me.
Sam Pearson