【发布时间】:2017-09-16 22:36:20
【问题描述】:
我正在使用 Glyphs 元素制作 WPF 文本编辑器。
我有一个问题是文本没有正确绘制
如图所示,我该如何解决这个问题?
有两个问题:
- 字母之间的字距调整。
- 字母和变音符号之间的字距调整。
我用GetKerningPairs函数解决的第一个问题。
我该如何解决这个问题,也许我错了?
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="AUTO"/>
<RowDefinition Height="AUTO"/>
</Grid.RowDefinitions>
<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 = "בְּרֵאשִׁית"
BidiLevel="1"
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"
BidiLevel="0"
Fill = "Black"/>
</Grid>
</Window>
【问题讨论】:
-
看起来问题是字体类型,如果你看英文字符,一个是固定宽度,另一个是固定间距。您必须查看字符的宽度和字符之间的间距。定宽字符 字符和空格都是一样的。固定间距字符宽度不同,字符间距相同。所以看起来 Glyphs 使用的是固定间距,并且下标是左对齐的。
-
您可能还应该设置 Glyph 的 Indices 属性。见Introduction to the GlyphRun Object and Glyphs Element。
-
是的,我根据
GetKerningPairs函数获得的信息设置了 Indices 属性,但是字体文件中是否包含变音符号的索引?