相关文章推荐
腼腆的遥控器  ·  Argument of type ...·  9 月前    · 
谈吐大方的人字拖  ·  php ...·  1 年前    · 

GlyphRun 简介

Windows Presentation Foundation (WPF) 提供高级文本支持,包括可直接访问 Glyphs 的字形级标记,以便客户拦截和保留格式化后的文本。 这些功能为以下每种方案中不同的文本呈现要求提供关键支持。

  • 固定格式文档的屏幕显示。

  • 打印方案。

  • Extensible Application Markup Language (XAML) 作为设备打印机语言。

  • Microsoft XPS 文档编写器。

  • 以前的打印机驱动程序,从 Win32 应用程序输出为固定格式。

  • 打印后台处理格式。

  • 固定格式的文档演示,包括以前版本的 Windows 客户端和其他计算设备。

    Glyphs GlyphRun 专为固定格式的文档演示和打印方案而设计。 有关 UI 方案,请参阅 WPF 中的版式

    GlyphRun 对象

    GlyphRun 对象表示单一大小且具有单一呈现样式的单个字体的单个字面的一系列字形。

    GlyphRun 包括字体细节(如字形 Indices )和各字形位置。 它还包括运行生成自的原始 Unicode 代码点、字符到字形缓冲偏移映射信息,以及每字符和每字形标志。

    GlyphRun 具有相应的高级别 FrameworkElement Glyphs 。 可以在元素树和 XAML 标记中使用 Glyphs 来表示 GlyphRun 输出。

    Glyphs 元素

    Glyphs 元素表示 XAML 中 GlyphRun 的输出。 以下标记语法用于描述 Glyphs 元素。

    <!-- The example shows how to use a Glyphs object. -->
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       <StackPanel Background="PowderBlue">
          <Glyphs
             FontUri             = "C:\WINDOWS\Fonts\TIMES.TTF"
             FontRenderingEmSize = "100"
             StyleSimulations    = "BoldSimulation"
             UnicodeString       = "Hello World!"
             Fill                = "Black"
             OriginX             = "100"
             OriginY             = "200"
       </StackPanel>
    </Page>
    

    以下属性定义对应于示例标记中的前四个特性。

    Indices 属性

    Indices 属性是字形规范的字符串。 在一系列字形形成单个群集的情况下,群集中第一个字形的规范之前会跟有一个规范,说明组合了多少个字形和多少个代码点来形成群集。 Indices 属性在一个字符串中收集以下属性。

  • 字形步进宽度

  • 组合字形附加矢量

  • 从代码点映射到字形的群集

    每个字形规范具有以下形式。

    [GlyphIndex][,[Advance][,[uOffset][,[vOffset][,[Flags]]]]]

    字形度量值

    每个字形定义了指定它与其他 Glyphs 的对齐方式的度量值。 以下图形定义两种不同字形字符的各种排版品质。

    Glyphs 标记

    以下代码示例演示如何使用 XAML 中 Glyphs 元素的各种属性。

    <!-- The example shows how to use different property settings of Glyphs objects. -->
    <Canvas
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Background="PowderBlue"
    <Glyphs 
       FontUri             = "C:\WINDOWS\Fonts\ARIAL.TTF"
       FontRenderingEmSize = "36"
       StyleSimulations    = "ItalicSimulation"
       UnicodeString       = "Hello World!"
       Fill                = "SteelBlue"
       OriginX             = "50"
       OriginY             = "75"
    <!-- "Hello World!" with default kerning -->
    <Glyphs 
       FontUri             = "C:\WINDOWS\Fonts\ARIAL.TTF"
       FontRenderingEmSize = "36"
       UnicodeString       = "Hello World!"
       Fill                = "Maroon"
       OriginX             = "50"
       OriginY             = "150"
    <!-- "Hello World!" with explicit character widths for proportional font -->
    <Glyphs 
       FontUri             = "C:\WINDOWS\Fonts\ARIAL.TTF"
       FontRenderingEmSize = "36"
       UnicodeString       = "Hello World!"
       Indices             = ",80;,80;,80;,80;,80;,80;,80;,80;,80;,80;,80"
       Fill                = "Maroon"
       OriginX             = "50"
       OriginY             = "225"
    <!-- "Hello World!" with fixed-width font -->
    <Glyphs 
         FontUri             = "C:\WINDOWS\Fonts\COUR.TTF"
         FontRenderingEmSize = "36"
         StyleSimulations    = "BoldSimulation"
         UnicodeString       = "Hello World!"
         Fill                = "Maroon"
         OriginX             = "50"
         OriginY             = "300"
    <!-- "Open file" without "fi" ligature -->
    <Glyphs
       FontUri             = "C:\WINDOWS\Fonts\TIMES.TTF"
       FontRenderingEmSize = "36"
       StyleSimulations    = "BoldSimulation"
       UnicodeString       = "Open file"
       Fill                = "SlateGray"
       OriginX             = "400"
       OriginY             = "75"
    <!-- "Open file" with "fi" ligature -->
    <Glyphs
       FontUri             = "C:\WINDOWS\Fonts\TIMES.TTF"
       FontRenderingEmSize = "36"
       StyleSimulations    = "BoldSimulation"
       UnicodeString       = "Open file"
       Indices             = ";;;;;(2:1)191"
       Fill                = "SlateGray"
       OriginX             = "400"
       OriginY             = "150"
    </Canvas>
    
  • WPF 中的版式
  • WPF 中的文档
  •