Поделиться через


Tips for improving your WPF text rendering experience

WPF uses the latest version of ClearType to render text. This version of ClearType has a few new features over the standard ClearType used in GDI and WinForms. You can read more about these features here.

We’ve found that a couple simple tips can improve your reading experience:

-Make sure your monitor is set to its native resolution, typically the maximum resolution possible. This can be adjusted through Control Panel-->Display Properties on XP or Control Panel--> Adjust screen resolution on Vista.

-Use the ClearType tuner PowerToy. This adjusts the system's ClearType settings including pixel orientation and Gamma. Though WPF's ClearType engine is separate from GDI and WinForms, WPF still picks up these system wide settings.

-For advanced users who are comfortable playing with regedit, there is one additional WPF ClearType setting that may help improve your experience: you can adjust the color level that WPF ClearType uses for sub-pixel anti-aliasing. At the moment this can only be tuned via registry keys, but we do have future plans to update the ClearType tuner to include this setting in a UI.

To adjust this you will need to create this new reg key:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\<displayName>\

With <displayName> typically being 'DISPLAY1'. You can adjust things independently if you have multiple monitors.

Then create the following DWORD with any value between 0 and 100 (base 10):

ClearTypeLevel

The default value of 100 is the maximum amount of color and provides the greatest utilization of sub-pixels. On LCD panels this is the most optimal setting for the majority of users. If you perceive color fringes or halos around your text at a normal reading distance tune the value lower (You will need to restart any WPF application to see the effects of the change). The value of 0 uses only grayscale anti-aliasing and no color. Note if 'font smoothing' is turned off or set to ‘anti-alias’ on the system level, WPF will automatically render using grayscale anti-aliasing. Due to our pixel independent architecture we cannot render aliased text even if ‘font smoothing’ is turned off completely.

-Chris Han

Comments

  • Anonymous
    January 01, 2007
    It seems that ClearType is OFF in popups (e.g. menus and combo boxes) - I only get grayscale antialiasing, which is pretty bad. Is that because Popups are layered windows (AllowsTransparency=true)?

  • Anonymous
    October 09, 2007
    We're looking for a way to override the WPF ClearType setting right the other way — force it ON when the system setting reads OFF. Somehow like IE7 does, you know. The point is that, as WPF would not render aliased text, its presentation cannot follow system “OFF” settings in any case. But full-pixel antialiasing (“grayscale”) renders much worse a presentation than ClearType at the typical UI tasks on the typical 96 DPI screen. Having to break the user settings, we'd like to choose the least evil possible. I'm not sure if users will stand the full-pixel antialiasing of controls' text or not. I, for instance, would not. So, go ClearType, or ditch WPF, as it seems to be. Can this be done at “user level”? By tweaking the HwndSource/HwndTarget/CompositionTarget? By sending a MIL CMD? I'm afraid that without the help of a WPF team insider it would be hard to dig it up in time. On the other hand, going back WinForms does not seem nice at all. Can you help?

  • Anonymous
    June 24, 2008
    I have used WPF to create a rich display of data in a WinForms application.  The difference in how the text is rendered between the WinForms portions and the WPF portions is really problematic. From what I've read on the forums, there is no way to change this text rendering behavior.  Are there any plans to allow this to be changed to render the same as every other application in Windows?   Unfortunately, we may have to pull the WPF out and use an HTML rendering tool because of this issue. Thanks

  • Anonymous
    February 11, 2010
    Text is still blurry in .NET 4 RC, and the Avalon.Graphics doesn't seem to have any effect anymore. Has this been moved or removed?

  • Anonymous
    March 01, 2010
    Mauricio – When I tried changing the Avalon.Graphics key on the RC build I experienced the same problem. Others on my team tried to reproduce this problem on newer builds and it was not present. If this functionality did regress in RC, it should be back for the final release of the product.