Windows Presentation Foundation (WPF) には、文字体裁プロパティの複雑なセットのサポートが含まれます。 これらのプロパティは TextRun レベルのコードまたは Extensible Application Markup Language (XAML) で使用できます。
使用例
上付き文字、下付き文字、およびその他の文字体裁の Variants を使用する XAML でのコード サンプルを次に示します。 バリアント機能とは、代替グリフ図形を使用して形式を表す文字体裁項目の種類です。 バリアント機能は Run 要素を使用して格納されたテキストのみに制限されます。
<FlowDocument FontFamily="Palatino Linotype" FontSize="24">
<Paragraph>
This is an <Run Typography.Variants="Ordinal">ordinal</Run><LineBreak/>
This is a <Run Typography.Variants="Superscript">superscript</Run><LineBreak/>
This is a <Run Typography.Variants="Subscript">subscript</Run><LineBreak/>
This is an <Run Typography.Variants="Inferior">inferior</Run><LineBreak/>
</Paragraph>
</FlowDocument>
文字体裁の Capitals を使用する XAML でのコード サンプルを次に示します。 バリアント機能は Paragraph 要素を使用して格納されたすべてのテキストに適用されます。
<FlowDocument FontFamily="Palatino Linotype" FontSize="24">
<Paragraph Typography.Capitals="SmallCaps">
This example shows the use of the Capitals property
of the Typography object. The entirety of this paragraph
is displayed in small capitals letters,
except for the first letter of a sentence,
and where an uppercase letter is used. In these cases,
a large capital letter is used.
</Paragraph>
</FlowDocument>
文字体裁の Capitals および NumeralStyle 機能を使用する XAML でのコード サンプルを次に示します。 両方の文字体裁プロパティが段落全体に適用されます。
<FlowDocument FontFamily="Palatino Linotype" FontSize="24">
<Paragraph Typography.Capitals="SmallCaps" Typography.NumeralStyle="OldStyle">
Welcome to C#! . . . 14<LineBreak/>
Working with Variables, Operators, and Expressions . . . 29<LineBreak/>
Writing Methods and Applying Scope . . . 45
</Paragraph>
</FlowDocument>