我试图构建一个GlyphRun对象,但我似乎无法理解GlyphIndices属性是如何编码的。
例如,下面是 XAML字符串创建"hello“。显然,以下规则适用于:
但是这个编码方案是什么呢?我试过ASCII,但似乎不合适。
你有什么想法吗?
<GlyphRunDrawing ForegroundBrush="Black">
<GlyphRunDrawing.GlyphRun>
<GlyphRun
CaretStops="{x:Null}"
ClusterMap="{x:Null}"
IsSideways="False"
GlyphOffsets="{x:Null}"
GlyphIndices="43 72 79 79 82 3 58 82 85 79 71"
BaselineOrigin="0,12.29"
FontRenderingEmSize="13.333333333333334"
DeviceFontName="{x:Null}"
AdvanceWidths="9.62666666666667 7.41333333333333 2.96 2.96 7.41333333333333 3.70666666666667 12.5866666666667 7.41333333333333 4.44 2.96 7.41333333333333"
BidiLevel="0">
<GlyphRun.GlyphTypeface>
<GlyphTypeface FontUri="C:\WINDOWS\Fonts\TIMES.TTF" />
</GlyphRun.GlyphTypeface>
</GlyphRun>
</GlyphRunDrawing.GlyphRun>
</GlyphRunDrawing>发布于 2012-06-03 15:10:31
使用此代码可将Unicode代码点转换为字形索引:
GlyphTypeface glyphTypeface = new GlyphTypeface(new Uri(@"C:\WINDOWS\Fonts\TIMES.TTF"));
const char character = 'и';
ushort glyphIndex;
glyphTypeface.CharacterToGlyphMap.TryGetValue(character, out glyphIndex);
MessageBox.Show("Index = " + glyphIndex);上面的示例返回西里尔字母и字符的610。
https://stackoverflow.com/questions/10869826
复制相似问题