WPF TextFormattingOptions.Display更改字母间距

时间:2018-03-13 12:08:07

标签: wpf text-rendering

基于this answer关于WPF中模糊文本的问题,我尝试使用TextOptions.TextFormattingMode = TextFormattingMode.Display,但似乎它也会改变字母之间的间距

TextFormattingMode.Display会导致ze个字符混合到另一个字符中:

TextFormattingMode.Display actual size

虽然使用TextFormattingMode.Ideal

不会发生这种“混合”

enter image description here

向上缩放文本时,差异变得更加明显(左侧TextFormattingMode.Display):

enter image description here enter image description here

仅在使用Segoe UI Semilight且仅使用12pt字体大小时才会发生此行为。

为什么会这样?这是特定字体,WPF渲染引擎的问题还是这个实际需要的行为?

编辑:如果你想自己检查一下,这里有一些可以复制的示例代码:

<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>

1 个答案:

答案 0 :(得分:0)

这是实际的通缉行为。您可以尝试使用&#34; HELLO WORLD&#34;字符串,你会知道真正的区别。使用这些模式的常见方案是:

  1. 大文字(15pt +) - 根据用户的偏好进行理想/显示。
  2. 转换后的文字 - 理想
  3. 放大文字 - 理想
  4. 设计方案 - 理想
  5. 小文字 - 显示