简体   繁体   English

GlyphIndices属性如何在GlyphRun对象中编码?

[英]How is GlyphIndices property encoded in GlyphRun object?

I am trying to build a GlyphRun object, and I can't seem to understand how GlyphIndices property is encoded. 我正在尝试构建一个GlyphRun对象,我似乎无法理解GlyphIndices属性是如何编码的。

For example, the following XAML string creates "hello world". 例如, 以下 XAML字符串创建“hello world”。 It is obvious that the following rules hold: 很明显,以下规则适用:

  • 43 -> h 43 - > h
  • 72 -> e 72 - > e
  • 79 -> l 79 - > l

But what is this coding scheme? 但这个编码方案是什么? I tried ASCII and it doesn't seem to fit. 我试过ASCII,它似乎不合适。

Do you have any idea? 你有什么主意吗?


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

Use this code to convert a Unicode code point to a glyph index: 使用此代码将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);

The sample above returns 610 for the Cyrillic и character. 上面的示例为西里尔字符返回610。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM