TextOptions.TextRenderingMode vs. Visual.VisualTextRenderingMode

494 Views Asked by At

There appear to be two ways to set a TextRenderingMode enumeration value on a WPF Visual.

Is there any difference between using the TextOptions.TextRenderingMode attached property (with or without its static getter/setters) versus the instance property Visual.VisualTextRenderingMode on the Visual base class?

I took a quick look in Reflector, but surprisingly it wasn't immediately clear that one method was calling the other or vice-versa. Each way seems to have a small, but non-trivial amount of proactively side-effecting code. I guess I was expecting those getter/setters to be more passive (i.e. simply recording state changes and then deferring to subsequent, centrally-coordinated action).

The enumeration itself lives in System.Windows.Media, so that doesn't come down on either side of the debate. In case you're curious, there are four modes available, as follows:

public enum TextRenderingMode
{
    Auto      /**/ = 0, // Text is rendered with the most appropriate rendering algorithm based on the layout mode that was used to format the text.
    Aliased   /**/ = 1, // Text is rendered with bilevel anti-aliasing.
    Grayscale /**/ = 2, // Text is rendered with grayscale anti-aliasing.
    ClearType /**/ = 3, // Text is rendered with the most appropriate ClearType rendering algorithm based on the layout mode that was used to format the text.
}

This isn't the only confusing rendering flag in WPF. Text and edge rendering (?) tweaks, and support for the various hinting and bitmap caching options seem to be amongst those rare areas of WPF where the API isn't organized (or comprehensively documented) very well.

0

There are 0 best solutions below