2

Based on this answer about issues with blurry texts in WPF, I tried to use TextOptions.TextFormattingMode = TextFormattingMode.Display, but it seems like it also changes the spacing between the letters:

TextFormattingMode.Displayleads to the z and e characters being blended into another:

TextFormattingMode.Display actual size

while this "blending" does not happen using TextFormattingMode.Ideal:

enter image description here

The differences become even more visible when scaling the texts up (TextFormattingMode.Display on the left):

enter image description here enter image description here

The behavior occurred only when using Segoe UI Semilight and only at 12pt font size.

Why does that happen? Is this an issue with that particular font, the WPF rendering engine or is this actually wanted behavior?

EDIT: If you want to check for yourself, here is some ready-to-copy sample code:

<Grid>
    <Grid.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="FontFamily" Value="Segoe UI Semilight" />
            <Setter Property="FontSize" Value="12" />
        </Style>
    </Grid.Resources>

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <TextBlock Grid.Row="0"
               Text="size"
               TextOptions.TextFormattingMode="Display" />

    <TextBlock Grid.Row="1"         
               Text="size"
               TextOptions.TextFormattingMode="Ideal" />
</Grid>
Thomas Flinkow
  • 4,845
  • 5
  • 29
  • 65
  • 1
    I prefer to set `TextFormattingMode="Display"` and `SnapsToDevicePixels="true"` at the `Window` level in WPF and let it inherit through all the elements. Both settings combined at the top level seem to give the "best", least blurry rending for WPF on desktop applications. `TextFormattingMode.Ideal` is really only designed to look good on super high-resolution displays, like cell-phones IMHO. – Bradley Uffner Mar 13 '18 at 12:33

1 Answers1

2

It is the actual wanted behaviour. You can try doing the same with "HELLO WORLD" string and you will know the real difference. The usual scenarios for using these modes are:

  1. Large Text (15pt+) - Ideal/Display as per user's preference.
  2. Transformed Text - Ideal
  3. Zoomed Text - Ideal
  4. Design Scenarios - Ideal
  5. Small Text - Display
Raviraj Palvankar
  • 879
  • 1
  • 5
  • 9
  • Thank you for the answer. Provided that my sample uses 12pt, from your answer follows that I should use `TextFormattingMode,Display` - but this causes the spacing issue. – Thomas Flinkow Mar 13 '18 at 12:26
  • Then use Ideal it looks perfect for 12pt. Also check with a longer string and not just one 'size' word. – Raviraj Palvankar Mar 13 '18 at 12:27