首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GlyphIndices属性是如何在GlyphRun对象中编码的?

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

Stack Overflow用户
提问于 2012-06-03 11:14:05
回答 1查看 1.6K关注 0票数 3

我试图构建一个GlyphRun对象,但我似乎无法理解GlyphIndices属性是如何编码的。

例如,下面是 XAML字符串创建"hello“。显然,以下规则适用于:

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

但是这个编码方案是什么呢?我试过ASCII,但似乎不合适。

你有什么想法吗?

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-03 15:10:31

使用此代码可将Unicode代码点转换为字形索引:

代码语言:javascript
复制
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。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10869826

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档