固定格式的文档演示,包括以前版本的 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 中的文档