I'm developing a WPF app but I've noticed that at certain font sizes the text doesn't render as nicely as the samples you see in Control Panel -> Fonts. I'm using large Segoe UI fonts (FontSize="36"
), and the effect is more noticeable on the upright lines, e.g. a letter "U" might be slightly thicker on one side than the other.
).
The font quality improves at certain font sizes, e.g. FontSize="48"
(which I believe is the equivalent of 36pt), but using a limited number of font sizes isn't always practical.
I can improve the font quality by applying the following properties to the TextBlock:-
TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="ClearType"
Given the improvement in quality I'm curious to know why WPF doesn't do this for all text, or is it down to performance? I was thinking of creating a global style to apply this to all controls, or will this cause a problem?
(I tried uploading a screenshot but SO must store images at a low quality, and you couldn't really make out the font problem).
Best Answer
Here is the blog post that the WPF Text team wrote about this feature.
Note for the
TextFormattingMode
:Since these properties are new in .NET 4.0, they kept the original WPF algorithm as default, which is Ideal mode.
For the
TextRenderingMode
Since
Auto
is default, you will generally getClearType
rendering.Now, because these are attached properties, and they inherit, you can just set them at the root
Window
. No need to create a bunch ofStyle
s.