Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blurry text in WPF only when the program is ran

I have been having this issue with blurry text in WPF. I know that there are these TextFormatting="Display" options and I've been googling a lot, but the thing is that it's still not right. Let me demonstrate:

WPF blurry text

The left side is what I see in Visual Studio 2011 Developer Preview's "preview mode", and the right side is what I see when I actually run the program. What I want is the left ClearType which is by far the nicest, but none of those options in actual program running mode look good.

This is the code:

<StackPanel TextOptions.TextFormattingMode="Display">
    <TextBlock>Hello World ... ClearType</TextBlock>
    <TextBlock TextOptions.TextRenderingMode="Grayscale">Hello World ... Grayscale</TextBlock>
    <TextBlock TextOptions.TextRenderingMode="Aliased">Hello World ... Aliased</TextBlock>
</StackPanel>

How do I render text the way it is rendered in the preview mode right inside Visual Studio?

EDIT: I found out that the reason that causes this problem is because I use WPF Shell Integration Library with the Glass style. This glass style somehow makes WPF to not use ClearType.

like image 215
Tower Avatar asked Feb 26 '12 10:02

Tower


1 Answers

Try writing the following way:

<TextBlock Text="ClearType ENABLED." RenderOptions.ClearTypeHint="Enabled"/>

You can read about ClearTypeHint at MSDN

like image 153
Pavel Krymets Avatar answered Oct 13 '22 02:10

Pavel Krymets