New WPF 4.0 Features

WPF 4.0 Beta1 was released last month. While many exciting features were included in Beat1, there was no work targeting text, flow, or layout. This will all be reversed with WPF Beat2. Below is a brief overview for each of the features included in Beta2 which target text, flow, or layout. I will make subsequent posts giving more detail about each feature, including API details. For now, I just want to let everyone know that great features are coming!



Text clarity improvements

In previous versions of WPF, all text is formatted without specifically accounting for pixel boundaries. This approach provides uniform scalability and ensures that glyph outlines adhere to font specifications. Unfortunately, small text appears blurry when it is rendered across pixel boundaries, and this has affected our customers.  In the past, we have only been able to say “we are working on a fix.”  Now I can tell you that this is solved in WPF4.0!


As of Beta2, WPF provides developers with the ability to control how text is both formatted and rendered. Text can now be formatted to either strictly adhere to font specifications or fall on pixel boundaries. This new option allows text to be rendered more clearly at the slight expense of glyph shape and position.


The option to set the rendering mode for text (eg, aliased, grayscale, ClearType) is also conveniently exposed. In most situations ClearType is an obvious win; however ClearType can degrade the user experience on CRTs and for people whose eyes are color sensitive. In the past, WPF forced all apps to use ClearType. Now, developers can choose between two additional rendering modes.



A Bindable Run

The inability to bind Run.Text has forced many people to create home brew solutions. In WPF4.0, Run.Text has been converted to a Dependency Property.  Run.Text now enjoys most of the benefits that come with this change, such as the ability to be bound, styled, and templated.


One-way binding is fully supported. Unfortunately, we did not have time to implement full support for two-way binding. This scenario is supported if a run is only modified through the property system, but not when the run is modified via a RichTextBox or the text object model.




WPF’s layout engine frequently causes subpixel rendering along element boundaries. This can lead to both rendering artifacts and blurry rendering, as antialiasing causes subpixel rendered elements to be displayed over multiple actual pixels. A classic example of this problem is small icons which get blurred because the icon images are placed on subpixel boundaries. Enabling LayoutRounding forces the WPF layout engine to place elements on whole pixel boundaries, thus removing most of the rendering artifacts caused by this problem.



Caret and Selection Brush

The default visual appearance of most objects in WPF can be easily tweaked or completely changed.  This provides developers far greater power over the visual look of an application than ever before. Facilitating the creation of highly customized apps has become a major adoption point for WPF. Despite WPF’s extensibility, the color of text selection and carets in text boxes and document viewers remains baked into the framework. WPF now exposes properties to control the brushes used to paint text selection and carets.




Comments (14)
  1. Alex T. says:

    I’m speechless…

    Could it be that with WPF4 I will finally be able to wholeheartedly recommend WPF as UI tool-kit? You know, without sidelines that ‘it’s great but the text quality sucks’. Let’s hope so!

  2. Rondy says:

    WOW, look forward to test the text improvement. I use text animation for entertainment applications, and this will be awsome!!

  3. Ivo says:

    I was unpleasantly surprised by Visual Studio 2010 Beta1 as it doesn’t support the Courier font any more. The reason turned out to be that it uses WPF, which doesn’t support raster fonts.

    So I tried to find another font that works for me. There’s not that much choice for fixed-width fonts – Consolas, Courier, Courier New, Fixed Sys, Lucida Console, MS Mincho and Terminal.

    Courier, Fixed Sys and Terminal are raster fonts so they don’t count. MS Mincho is waaay too narrow for source code. Next I tried Consolas, Courer New and Lucida Console but they all felt weird. Aside from Consolas and Courier New wasting too much space between the lines and Lucida Console being just too fancy, there was something else.

    I looked closer to see what really bothered me and I think I got it. All of these fonts looked blurry even when I disable the font smoothing from the system settings. This makes the vertical parts of the glyphs wash out and the horizontal parts stand out.

    Will the new WPF 4.0 solve this? And will it be solved in time to affect Visual Studio 2010?

    Also, can somebody recommend a fixed-width vector font that is suitable for coding? Something that looks crisp and legible at size 10 and doesn’t waste space between the lines?


  4. Daniel Smith says:

    Any chance of a screenshot of the text quality improvements?  As they say, a picture’s worth a thousand words…

  5. lixin says:

    Two questions,

    1. Which text rendering option I should take if I need to get the most clear and smooth texts? Grayscale? I am talking about a WinForm like quality.

    2. Will Silverlight’s text rendering be improved at the same time? I know there is ClearType support in Silverlight 3 now, but the actual clarity is still far away from satisfaction yet.

  6. text says:

    Yes, screenshots and API details are on their way.

  7. Hexmaster says:

    Fantastic news! I find that smoothed text can be difficult to read, so hearing that crisp fonts (ie: simple rasterization without antialiasing) are available on the WPF is truly joyous news! Huzzah!

  8. Daniel Smith says:

    Is the screenshot post still on its way?  I take it we should be looking out for the post on the DirectX dev blog rather than here, but it’s looking awfully quiet over there!

    Hopefully it won’t be too long until .NET 4.0 beta 2 is out and and we can see the text rendering improvements first hand.

  9. text says:

    Daniel –

    Yes, I am almost done with the follow up post which goes into much more depth about the new text stack in WPF4.0. I hope to post it early next week.

    Rodny –

    This is a good news/bad news situation. Let’s start with the bad. In general, pixel snapped text is not suited for animations. Some animations are worse than others. For example, applying a scale transform to pixel snapped text will produce much worse results that applying a translation. Due to this, please do not expect the new text formatting mode to necessarily improve text animation quality.

    Now, on to the good news… Another feature of our new text stack, not mentioned previously, is a property aimed at improving text animations. Depending on the problems that you have run into with animated text, this property should be very useful for you. I’ll post more details about this in the future.

    Ivo – Yes, the new WPF 4.0 text stack will solve the issue you brought up, and VS 2010 will definitely take advantage of that.

    I believe Consolas is the default font used by VS 2010. Did you not like using it because of clarity problems or line spacing issues? If it is the former, this should be a non issue once VS switches to WPF’s new text stack.

    Lixin –

    1. If your font size is below 15pt, you will most likely want to use pixel snapped text. If your font size is above 15pt, non pixel snapped text will produce better results. ClearType should be used in both situations.

    2. I don’t know the answer to that, but I’ll ask around.

  10. Martin says:

    Does anybody know if RichTextbox will support multi-column editing and displaying page-breaks more "word like editing"?



  11. Herschel Krustovsky says:


    This paragraph:

    "The option to set the rendering mode for text (eg, aliased, grayscale, ClearType) is also conveniently exposed. In most situations ClearType is an obvious win; however ClearType can degrade the user experience on CRTs and for people whose eyes are color sensitive. In the past, WPF forced all apps to use ClearType. Now, developers can choose between two additional rendering modes."

    just made me orgasm. I’ve hated the WPF because it made me suffer through crappy font smoothing that refused to respect my system setting (no font smoothing, disable ClearType). If this is fixed with WPF 4, and I can get back aliased texts, you will have made me the happiest boy on the planet.

  12. Brett B says:

    Will the new text clarity improvements help with text in a layered window?  Currently if you have a window with the AllowsTransparency=true, you get into this whole air space issue, and if I read correctly, WPF chose the Application-Provided Content mode, which naturally allows WPF’s anti-aliased rendering to work on the layered window too, but the text in a window that allows transparency ends up looking fuzzy.  You can verify this by turning off AllowsTransparency, the font (Segoe UI) renders crisp!

    Will this be fixed?

  13. text says:

    Martin – Those features are not planned for .Net4.0

    Brett B – To render ClearType, WPF must know the final background color for text when we rasterizing the glyph bitmaps. If we do not know this, we will not be able to correctly apply the ClearType algorithm.  Basically this means that WPF cannot render ClearType text on a transparent object.  Technically, WPF cannot render ClearType when an object introduces an intermediate render target. Unfortunately, not all objects which force intermediate render targets are necessarily transparent (eg PopUp). In these cases ClearType is over aggressively disabled by WPF. The property RenderOptions.ClearTypeHint has been introduced in .Net4.0 to help combat this problem. Setting ClearTypeHint to “Enabled” on an object essentially tells WPF that this object is opaque and rendering ClearType is safe.  I’ll do a more thorough blog post on this topic in the near future.

Comments are closed.

Skip to main content