-api-id | -api-type |
---|---|
T:Windows.UI.Xaml.Documents.Typography |
winrt class |
Provides access to a set of Microsoft OpenType typography properties. These properties are implemented as XAML attached properties such that they can be set from text object model properties as well as from specific text controls.
You typically use Typography attached properties with the text of TextBlock or RichTextBlock controls.
Note
You cannot use these properties with the TextBox or RichEditBox controls.
The Typography object exposes the set of features that the Microsoft OpenType font supports. By setting the properties of Typography in markup or code, you can author documents that take advantage of Microsoft OpenType features, and turn those features on at a per-element level if desired.
Some fonts contain stylistic variant glyphs that correspond to portions of a character set. Glyphs in stylistic sets may be designed to harmonize visually, interact in particular ways, or work together in other ways. Some of these variants are identified by particular conventions, for example the font might have discretionary ligatures. In this example case, the typography behavior can be enabled by setting Typography.DiscretionaryLigatures to true. Other stylistic variants are not identified by any Microsoft OpenType set or convention, and are instead specific to that particular font's typography design. These variants can be accessed by setting any of the StylisticSet# attached properties to true.
Note
Whenever possible, TextBlock renders text using an efficient fast path. Only the default values for the various Typography attached properties are fast path. Non-default values require TextBlock to fall back to a more CPU intensive code path for text rendering. For more info, see the TextBlock control guide.
Typography is the host service class for several XAML attached properties.
In order to support XAML processor access to the attached properties, and also to expose equivalent get and set operations to code, each XAML attached property has a pair of Get and Set accessor methods. Another way to get or set the value in code is to use the dependency property system, calling either GetValue or SetValue and passing the identifier field as the dependency property identifier.
Attached property | Description |
---|---|
AnnotationAlternates | Gets or sets an extension instance that defines helper methods for phased rendering of a data template. |
Capitals | Gets or sets a FontCapitals value that indicates the capital form of the selected font. |
CapitalSpacing | Gets or sets a value that determines whether inter-glyph spacing for all-capital text is globally adjusted to improve readability. |
CaseSensitiveForms | Gets or sets a value that determines whether glyphs adjust their vertical position to better align with uppercase glyphs. |
ContextualAlternates | Gets or sets a value that determines whether custom glyph forms can be used based upon the context of the text being rendered. |
ContextualLigatures | Gets or sets a value that determines whether contextual ligatures are enabled. |
ContextualSwashes | Gets or sets a value that specifies the index of a contextual swashes form. |
DiscretionaryLigatures | Gets or sets a value that determines whether discretionary ligatures are enabled. |
EastAsianExpertForms | Gets or sets a value that determines whether the standard Japanese font forms have been replaced with the corresponding preferred typographic forms. |
EastAsianLanguage | Gets or sets a FontEastAsianLanguage value that indicates glyphs used for a specific writing system or language. |
EastAsianWidths | Gets or sets a FontEastAsianWidths value that indicates the proportional width for Latin characters in an East Asian font. |
Fraction | Gets or sets a FontFraction value that indicates the fraction style. |
HistoricalForms | Gets or sets a value that determines whether historical forms are enabled. |
HistoricalLigatures | Gets or sets a value that indicates whether historical ligatures are enabled. |
Kerning | Gets or sets a value that indicates whether kerning is enabled. Kerning is a typographic function that adjusts the spacing between characters to enhance word shape. |
MathematicalGreek | Gets or sets a value that indicates whether standard typographic font forms of Greek glyphs have been replaced with corresponding font forms commonly used in mathematical notation. |
NumeralAlignment | Gets or sets a FontNumeralAlignment value that indicates the alignment of widths for numerals. |
NumeralStyle | Gets or sets a FontNumeralStyle value that determines the set of glyphs that are used to render numeric alternate font forms. |
SlashedZero | Gets or sets a value that indicates whether a nominal zero font form should be replaced with a slashed zero. |
StandardLigatures | Gets or sets a value that indicates whether standard ligatures are enabled. |
StandardSwashes | Gets or sets a value that specifies the index of a standard swashes form. |
StylisticAlternates | Gets or sets a value that specifies the index of a stylistic alternates form. |
StylisticSet1 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet2 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet3 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet4 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet5 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet6 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet7 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet8 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet9 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet10 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet11 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet12 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet13 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet14 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet15 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet16 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet17 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet18 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet19 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
StylisticSet20 | Gets or sets a value that indicates whether a stylistic set of a font form is enabled. |
Variants | Gets or sets a FontVariants value that indicates a variation of the standard typographic form to be used. |
Here, Typography values are set on a TextBlock to render the text in small caps using stylistic set 4.
<TextBlock Text="Hello, world!"
Typography.Capitals="SmallCaps"
Typography.StylisticSet4="True"/>
TextBlock textBlock1 = new TextBlock();
textBlock1.Text = "Hello, world!";
Windows.UI.Xaml.Documents.Typography.SetCapitals(textBlock1, FontCapitals.SmallCaps);
Windows.UI.Xaml.Documents.Typography.SetStylisticSet4(textBlock1, true);
In this example, the Typography.Fraction attached property is set on a Run in a RichTextBlock.
<RichTextBlock>
<Paragraph>12 x <Run Typography.Fraction="Slashed">1/3</Run> = 4.</Paragraph>
</RichTextBlock>
TextBlock, RichTextBlock, TextBlock control guide, RichTextBlock control guide