Search code examples
wpf.net-3.5textblock

TextBlock blurry in WPF 3.5


There is a criticism of one of my applications. The displayed text is perceived as blurry. I zoomed the window somewhat and got this result (so they are right)

Blurry text

resulting from what I've tried here in this simplified example:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel>
            <TextBlock Text="StatusDTC [1]"></TextBlock>
            <TextBlock Text="StatusDTC [2]"
                       RenderOptions.BitmapScalingMode="NearestNeighbor"
                       RenderOptions.EdgeMode="Aliased"></TextBlock>
            <TextBlock Text="StatusDTC [3]" 
                       SnapsToDevicePixels="True"></TextBlock>
            <TextBlock Text="StatusDTC [4]"
                       SnapsToDevicePixels="True"
                       RenderOptions.BitmapScalingMode="NearestNeighbor"
                       RenderOptions.EdgeMode="Aliased"></TextBlock>
        </StackPanel>
    </Grid>
</Window>

I found something similar here. but UseLayoutRounding seems to be not available for .Net 3.5. I googled a bit and found that there are improvements in .Net 4 (TextOptions.TextRenderingMode) addressing this issue, but switching to .Net 4 with this application is not an option.

As I know that Win7 renders WPF different than XP, I also started a virtual XP and tried it there. The result is the same.

Does someone have an idea to crisp the text in .Net 3.5?


Solution

  • As explained in the link from Ameen's answer, this problem is mostly seen at small font sizes.

    Is increasing the font size an option for you? I know that this is more a workaround than a solution, but it's a quick and easy way to get rid of the blurryness if you cannot move away from Framework 3.5.