google fan google fan - 3 years ago 307 Question

WPF `Glyphs` not rendering the text right like `TextBlock`

I'm making a WPF text-editor using

And I have a problem that the text is not drawn correctly
as you can see in the picture, how can I solve this problem?

enter image description here

There are two problems:

  1. Kerning between letters.

  2. Kerning between letters and diacritics.

The first problem I solved by

How do I solve this problem, maybe I'm wrong?

<Window x:Class="MainWindow"
Title="MainWindow" Height="200" Width="525">
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<RowDefinition Height="AUTO"/>
<RowDefinition Height="AUTO"/>

<TextBlock Text="TextBlock" VerticalAlignment="Center" Margin="6"/>
<TextBlock Grid.Row="1" Text="Glyphs" VerticalAlignment="Center" Margin="6"/>

<TextBlock Text="בְּרֵאשִׁית" Grid.Column="1" FontSize="50" FontFamily="Times New Roman"
FontWeight="Normal" Grid.Row="0"/>

<Glyphs Grid.Row="1" Grid.Column="1"
FontUri = "C:\WINDOWS\Fonts\TIMES.TTF"
FontRenderingEmSize = "50"
UnicodeString = "בְּרֵאשִׁית"
Fill = "Black"/>

<TextBlock Text="AVAV" Grid.Column="2" FontSize="50" FontFamily="Times New Roman"
FontWeight="Normal" Grid.Row="0"/>

<Glyphs Grid.Row="1" Grid.Column="2"
FontUri = "C:\WINDOWS\Fonts\TIMES.TTF"
FontRenderingEmSize = "50"
UnicodeString = "AVAV"
Fill = "Black"/>


Answer Source

Kerning for diacritics does not exist in TrueType fonts, So you must define your own list of pairs for diacritics, and give the corresponding kerning. In most letters, the diacritics is centered, and in the others on the right side. Apparently Text Block does the above.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download