#821 – Use TextFormattingMode to Make Text Look More Clear
May 16, 2013 2 Comments
WPF tries to retain the exact shape and style of each glyph in a font, no matter what size the font is being rendered at. This means that as the text gets smaller, relative to the pixel density of the display, the edges of the glyphs may no longer occur at pixel boundaries. When this happens, WPF will use anti-aliasing to render the edges of the glyphs in a different color. This can lead to small text looking fuzzy, or having some odd color fragments along the edges of the letters.
To avoid fuzzy text at small sizes, you can set the TextOptions.TextFormattingMode property to Display (as opposed to the default value of Ideal). This tells WPF to align the glyphs at pixel boundaries, which can lead to crisper/cleaner text.
<TextBlock Text="WiWi WIWI HaHaHa (Ideal = Default)" Margin="5"/> <TextBlock Text="WiWi WIWI HaHaHa (Display)" TextOptions.TextFormattingMode="Display" Margin="5"/>