Share via


How to: Set Typographic Properties

Windows Presentation Foundation (WPF) includes support for a complex set of typographic properties. These properties can be used either in code at the TextRun level or in Extensible Application Markup Language (XAML).

Example

The following code sample shows the use subscripting, superscripting, and other typographic Variants in XAML. Variant features are those types of typographic items where an alternate glyph shape is used to express a form. Notice that the variant feature is limited to only the text contained with the Run element.

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

The following code sample shows the use typographic Capitals in XAML. Notice that the variant feature is applied to all text contained with the Paragraph element.

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

The following code sample shows the use typographic Capitals and NumeralStyle features in XAML. Notice that both typographic properties are applied to the entire paragraph.

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

See Also

Concepts

OpenType Font Features