OpenType Font Features

This topic provides an overview of some of the key features of OpenType font technology in Windows Presentation Foundation (WPF).

This topic contains the following sections.

  • OpenType Font Format
  • Variants
  • Capitals
  • Ligatures
  • Swashes
  • Alternates
  • Numerical Styles
  • Typography Class
  • Related Topics

OpenType Font Format

The OpenType font format is an extension of the TrueType® font format, adding support for PostScript font data. The OpenType font format was developed jointly by Microsoft and Adobe Corporation. OpenType fonts and the operating system services which support OpenType fonts provide users with a simple way to install and use fonts, whether the fonts contain TrueType outlines or CFF (PostScript) outlines.

The OpenType font format addresses the following developer challenges:

  • Broader multi-platform support.

  • Better support for international character sets.

  • Better protection for font data.

  • Smaller file sizes to make font distribution more efficient.

  • Broader support for advanced typographic control.

Note

The Windows SDK contains a set of sample OpenType fonts that you can use with Windows Presentation Foundation (WPF) applications. These fonts provide most of the features illustrated in the rest of this topic. For more information, see Sample OpenType Font Pack.

See the OpenType Specification for details of the OpenType font format.

Advanced Typographic Extensions

The Advanced Typographic tables (OpenType Layout tables) extend the functionality of fonts with either TrueType or CFF outlines. OpenType Layout fonts contain additional information that extends the capabilities of the fonts to support high-quality international typography. Most OpenType fonts expose only a subset of the total OpenType features available. OpenType fonts provide the following features. 

  • Rich mapping between characters and glyphs that support ligatures, positional forms, alternates, and other font substitutions.

  • Support for two-dimensional positioning and glyph attachment.

  • Explicit script and language information contained in font, so a text-processing application can adjust its behavior accordingly.

The OpenType Layout tables are described in more detail in the "Font File Tables" section of the OpenType specification.

The remainder of this overview introduces the breadth and flexibility of some of the visually-interesting OpenType features that are exposed by the properties of the Typography object. For more information on this object, see Typography Class.

Variants

Variants are used to render different typographic styles, such as superscripts and subscripts.

Superscripts and Subscripts

The Variants property allows you to set superscript and subscript values for an OpenType font.

The following text displays superscripts for the Palatino Linotype font.

Text using OpenType superscripts

Text using OpenType superscripts

The following markup example shows how to define superscripts for the Palatino Linotype font, using properties of the Typography object.

<Paragraph FontFamily="Palatino Linotype">
  2<Run Typography.Variants="Superscript">3</Run>
  14<Run Typography.Variants="Superscript">th</Run>
</Paragraph>

The following text displays subscripts for the Palatino Linotype font.

Text using OpenType subscripts

Text using OpenType subscripts

The following markup example shows how to define subscripts for the Palatino Linotype font, using properties of the Typography object.

<Paragraph FontFamily="Palatino Linotype">
  H<Run Typography.Variants="Subscript">2</Run>O
  Footnote<Run Typography.Variants="Subscript">4</Run>
</Paragraph>

Decorative Uses of Superscripts and Subscripts

You can also use superscripts and subscripts to create decorative effects of mixed case text. The following text displays superscript and subscript text for the Palatino Linotype font. Note that the capitals are not affected.

Text using OpenType superscripts and subscripts

Text using OpenType superscripts and subscripts

The following markup example shows how to define superscripts and subscripts for a font, using properties of the Typography object.

<Paragraph FontFamily="Palatino Linotype" Typography.Variants="Superscript">
  Chapter One
</Paragraph>
<Paragraph FontFamily="Palatino Linotype" Typography.Variants="Subscript">
  Chapter One
</Paragraph>

Capitals

Capitals are a set of typographical forms that render text in capital-styled glyphs. Typically, when text is rendered as all capitals, the spacing between letters can appear too tight, and the weight and proportion of the letters too heavy. OpenType supports a number of styling formats for capitals, including small capitals, petite capitals, titling, and capital spacing. These styling formats allow you to control the appearance of capitals.

The following text displays standard capital letters for the Pescadero font, followed by the letters styled as "SmallCaps" and "AllSmallCaps". In this case, the same font size is used for all three words.

Text using OpenType capitals

Text using OpenType capitals

The following markup example shows how to define capitals for the Using OpenType Fonts Sample, using properties of the Typography object. When the "SmallCaps" format is used, any leading capital letter is ignored.

<Paragraph FontFamily="Pescadero" FontSize="48">
  <Run>CAPITALS</Run>
  <Run Typography.Capitals="SmallCaps">Capitals</Run>
  <Run Typography.Capitals="AllSmallCaps">Capitals</Run>
</Paragraph>

Titling Capitals

Titling capitals are lighter in weight and proportion and designed to give a more elegant look than normal capitals. Titling capitals are typically used in larger font sizes as headings. The following text displays normal and titling capitals for the Pescadero font. Notice the narrower stem widths of the text on the second line.

Text using OpenType titling capitals

Text using OpenType titling capitals

The following markup example shows how to define titling capitals for the Pescadero font, using properties of the Typography object.

<Paragraph FontFamily="Pescadero">
  <Run Typography.Capitals="Titling">chapter one</Run>
</Paragraph>

Capital Spacing

Capital spacing is a feature that allows you to provide more spacing when using all capitals in text. Capital letters are typically designed to blend with lowercase letters. Spacing that appears attractive between and a capital letter and a lowercase letter may look too tight when all capital letters are used. The following text displays normal and capital spacing for the Pescadero font.

Text using OpenType capital spacing

Text using OpenType capital spacing

The following markup example shows how to define capital spacing for the Pescadero font, using properties of the Typography object.

<Paragraph FontFamily="Pescadero">
  <Run Typography.CapitalSpacing="True">CHAPTER ONE</Run>
</Paragraph>

Ligatures

Ligatures are two or more glyphs that are formed into a single glyph in order to create more readable or attractive text. OpenType fonts support four types of ligatures:

  • Standard ligatures. Designed to enhance readability. Standard ligatures include "fi", "fl", and "ff".

  • Contextual ligatures. Designed to enhance readability by providing better joining behavior between the characters that make up the ligature.

  • Discretionary ligatures. Designed to be ornamental, and not specifically designed for readability.

  • Historical ligatures. Designed to be historical, and not specifically designed for readability.

The following text displays standard ligature glyphs for the Pericles font.

Text using OpenType standard ligatures

Text using OpenType standard ligatures

The following markup example shows how to define standard ligature glyphs for the Pericles font, using properties of the Typography object.

<Paragraph FontFamily="Pericles" Typography.StandardLigatures="True">
  <Run Typography.StylisticAlternates="1">FI</Run>
  <Run Typography.StylisticAlternates="1">FL</Run>
  <Run Typography.StylisticAlternates="1">TH</Run>
  <Run Typography.StylisticAlternates="1">TT</Run>
  <Run Typography.StylisticAlternates="1">TV</Run>
  <Run Typography.StylisticAlternates="1">TW</Run>
  <Run Typography.StylisticAlternates="1">TY</Run>
  <Run Typography.StylisticAlternates="1">VT</Run>
  <Run Typography.StylisticAlternates="1">WT</Run>
  <Run Typography.StylisticAlternates="1">YT</Run>
</Paragraph>

The following text displays discretionary ligature glyphs for the Pericles font.

Text using OpenType discretionary ligatures

Text using OpenType discretionary ligatures

The following markup example shows how to define discretionary ligature glyphs for the Pericles font, using properties of the Typography object.

<Paragraph FontFamily="Pericles" Typography.DiscretionaryLigatures="True">
  <Run Typography.StylisticAlternates="1">CO</Run>
  <Run Typography.StylisticAlternates="1">LA</Run>
  <Run Typography.StylisticAlternates="1">LE</Run>
  <Run Typography.StylisticAlternates="1">LI</Run>
  <Run Typography.StylisticAlternates="1">LL</Run>
  <Run Typography.StylisticAlternates="1">LO</Run>
  <Run Typography.StylisticAlternates="1">LU</Run>
</Paragraph>

By default, OpenType fonts in Windows Presentation Foundation (WPF) enable standard ligatures. For example, if you use the Palatino Linotype font, the standard ligatures "fi", "ff", and "fl" appear as a combined character glyph. Notice that the pair of characters for each standard ligature touch each other.

Text using OpenType standard ligatures

Text using OpenType standard ligatures

However, you can disable standard ligature features so that a standard ligature such as "ff" displays as two separate glyphs, rather than as a combined character glyph.

Text using disabled OpenType standard ligatures

Text using disabled OpenType standard ligatures

The following markup example shows how to disable standard ligature glyphs for the Palatino Linotype font, using properties of the Typography object.

<!-- Set standard ligatures to false in order to disable feature. -->
<Paragraph Typography.StandardLigatures="False" FontFamily="Palatino Linotype" FontSize="72">
  fi ff fl
</Paragraph>

Swashes

Swashes are decorative glyphs that use elaborate ornamentation often associated with calligraphy. The following text displays standard and swash glyphs for the Pescadero font.

Text using OpenType standard and swash glyphs

Text using OpenType standard and swash glyphs

Swashes are often used as decorative elements in short phrases such as event announcements. The following text uses swashes to emphasize the capital letters of the name of the event.

Text using OpenType swashes

Text using OpenType swashes

The following markup example shows how to define swashes for a font, using properties of the Typography object.

<Paragraph FontFamily="Pescadero" TextBlock.TextAlignment="Center">
  Wishing you a<LineBreak/>
  <Run Typography.StandardSwashes="1" FontSize="36">Happy New Year!</Run>
</Paragraph>

Contextual Swashes

Certain combinations of swash glyphs can cause an unattractive appearance, such as overlapping descenders on adjacent letters. Using a contextual swash allows you to use a substitute swash glyph that produces a better appearance. The following text shows the same word before and after a contextual swash is applied.

Text using OpenType contextual swashes

Text using OpenType contextual swashes

The following markup example shows how to define a contextual swash for the Pescadero font, using properties of the Typography object.

<Paragraph FontFamily="Pescadero" Typography.StandardSwashes="1">
  Lyon <Run Typography.ContextualSwashes="1">L</Run>yon
</Paragraph>

Alternates

Alternates are glyphs that can be substituted for a standard glyph. OpenType fonts, such as the Pericles font used in the following examples, can contain alternate glyphs that you can use to create different appearances for text. The following text displays standard glyphs for the Pericles font.

Text using OpenType standard glyphs

Text using OpenType standard glyphs

The Pericles OpenType font contains additional glyphs that provide stylistic alternates to the standard set of glyphs. The following text displays stylistic alternate glyphs.

Text using OpenType stylistic alternate glyphs

Text using OpenType stylistic alternate glyphs

The following markup example shows how to define stylistic alternate glyphs for the Pericles font, using properties of the Typography object.

<Paragraph FontFamily="Pericles">
  <Run Typography.StylisticAlternates="1">A</Run>NCIENT
  GR<Run Typography.StylisticAlternates="1">EE</Run>K
  MYTH<Run Typography.StylisticAlternates="1">O</Run>LOGY
</Paragraph>

The following text displays several other stylistic alternate glyphs for the Pericles font.

Text using OpenType stylistic alternate glyphs

Text using OpenType stylistic alternate glyphs

The following markup example shows how to define these other stylistic alternate glyphs.

<Paragraph FontFamily="Pericles">
  <Run Typography.StylisticAlternates="1">A</Run>
  <Run Typography.StylisticAlternates="2">A</Run>
  <Run Typography.StylisticAlternates="3">A</Run>
  <Run Typography.StylisticAlternates="1">C</Run>
  <Run Typography.StylisticAlternates="1">E</Run>
  <Run Typography.StylisticAlternates="1">G</Run>
  <Run Typography.StylisticAlternates="1">O</Run>
  <Run Typography.StylisticAlternates="1">Q</Run>
  <Run Typography.StylisticAlternates="1">R</Run>
  <Run Typography.StylisticAlternates="2">R</Run>
  <Run Typography.StylisticAlternates="1">S</Run>
  <Run Typography.StylisticAlternates="1">Y</Run>
</Paragraph>

Random Contextual Alternates

Random contextual alternates provide multiple substitute glyphs for a single character. When implemented with script-type fonts, this feature can simulate handwriting by using of a set of randomly chosen glyphs with slight differences in appearance. The following text uses random contextual alternates for the Lindsey font. Notice that the letter "a" varies slightly in appearance

Text using OpenType random contextual alternates

Text using OpenType random contextual alternates

The following markup example shows how to define random contextual alternates for the Lindsey font, using properties of the Typography object.

<TextBlock FontFamily="Lindsey">
  <Run Typography.ContextualAlternates="True">
    a banana in a cabana
  </Run>
</TextBlock>

Historical Forms

Historical forms are typographic conventions that were common in the past. The following text displays the phrase, "Boston, Massachusetts", using an historical form of glyphs for the Palatino Linotype font.

Text using OpenType historical forms

Text using OpenType historical forms

The following markup example shows how to define historical forms for the Palatino Linotype font, using properties of the Typography object.

<Paragraph FontFamily="Palatino Linotype">
  <Run Typography.HistoricalForms="True">Boston, Massachusetts</Run>
</Paragraph>

Numerical Styles

OpenType fonts support a large number of features that can be used with numerical values in text.

Fractions

OpenType fonts support styles for fractions, including slashed and stacked.

The following text displays fraction styles for the Palatino Linotype font.

Text using OpenType slashed and stacked fractions

Text using OpenType slashed and stacked fractions

The following markup example shows how to define fraction styles for the Palatino Linotype font, using properties of the Typography object.

<Paragraph FontFamily="Palatino Linotype" Typography.Fraction="Slashed">
  1/8 1/4 3/8 1/2 5/8 3/4 7/8
</Paragraph>
<Paragraph FontFamily="Palatino Linotype" Typography.Fraction="Stacked">
  1/8 1/4 3/8 1/2 5/8 3/4 7/8
</Paragraph>

Old Style Numerals

OpenType fonts support an old style numeral format. This format is useful for displaying numerals in styles that are no longer standard. The following text displays an 18th century date in standard and old style numeral formats for the Palatino Linotype font.

Text using OpenType old style numerals

Text using OpenType old style numerals

The following text displays standard numerals for the Palatino Linotype font, followed by old style numerals.

Text using OpenType old style numeral sets

Text using OpenType old style numeral sets

The following markup example shows how to define old style numerals for the Palatino Linotype font, using properties of the Typography object.

<Paragraph FontFamily="Palatino Linotype">
  <Run Typography.NumeralStyle="Normal">1234567890</Run>
  <Run Typography.NumeralStyle="OldStyle">1234567890</Run>
</Paragraph>

Proportional and Tabular Figures

OpenType fonts support a proportional and tabular figure feature to control the alignment of widths when using numerals. Proportional figures treat each numeral as having a different width—"1" is narrower than "5". Tabular figures are treated as equal-width numerals so that they align vertically, which increases the readability of financial type information.

The following text displays two proportional figures in the first column using the Miramonte font. Note the difference in width between the numerals "5" and "1". The second column shows the same two numeric values with the widths adjusted by using the tabular figure feature.

Text using OpenType proportional and tabular figures

Text using OpenType proportional & tabular figures

The following markup example shows how to define proportional and tabular figures for the Miramonte font, using properties of the Typography object.

<TextBlock FontFamily="Miramonte">
  <Run Typography.NumeralAlignment="Proportional">114,131</Run>
</TextBlock>
<TextBlock FontFamily="Miramonte">
  <Run Typography.NumeralAlignment="Tabular">114,131</Run>
</TextBlock>

Slashed Zero

OpenType fonts support a slashed zero numeral format to emphasize the difference between the letter "O" and the numeral "0". The slashed zero numeral is often used for identifiers in financial and business information.

The following text displays a sample order identifier using the Miramonte font. The first line uses standard numerals. The second line used slashed zero numerals to provide better contrast with the uppercase "O" letter.

Text using OpenType slashed zero numerals

Text using OpenType slashed zero numerals

The following markup example shows how to define slashed zero numerals for the Miramonte font, using properties of the Typography object.

<Paragraph FontFamily="Miramonte">
  <Run>Order #0048-OTC-390</Run>
  <LineBreak/>
  <Run Typography.SlashedZero="True">Order #0048-OTC-390</Run>
</Paragraph>

Using XamlPad to View OpenType Features

A useful technique for learning about OpenType features is to use XamlPad for creating markup that experiments with using different typographic properties. For more information, see XAMLPad.

Testing OpenType fonts with XamlPad

XamlPad displaying OpenType features

Typography Class

The Typography object exposes the set of features that an OpenType font supports. By setting the properties of Typography in markup, you can easily author documents that take advantage of OpenType features.

The following text displays standard capital letters for the Pescadero font, followed by the letters styled as "SmallCaps" and "AllSmallCaps". In this case, the same font size is used for all three words.

Text using OpenType capitals

Text using OpenType capitals

The following markup example shows how to define capitals for the Pescadero font, using properties of the Typography object. When the "SmallCaps" format is used, any leading capital letter is ignored.

<Paragraph FontFamily="Pescadero" FontSize="48">
  <Run>CAPITALS</Run>
  <Run Typography.Capitals="SmallCaps">Capitals</Run>
  <Run Typography.Capitals="AllSmallCaps">Capitals</Run>
</Paragraph>

The following code example accomplishes the same task as the previous markup example.

MyParagraph.FontFamily = new FontFamily("Pescadero");
MyParagraph.FontSize = 48;

Run run_1 = new Run("CAPITALS ");
MyParagraph.Inlines.Add(run_1);

Run run_2 = new Run("Capitals ");
run_2.Typography.Capitals = FontCapitals.SmallCaps;
MyParagraph.Inlines.Add(run_2);

Run run_3 = new Run("Capitals");
run_3.Typography.Capitals = FontCapitals.AllSmallCaps;
MyParagraph.Inlines.Add(run_3);

MyParagraph.Inlines.Add(new LineBreak());

Typography Class Properties

The following table lists the properties, values, and default settings of the Typography object.

Property

Value(s)

Default Value

AnnotationAlternates

Numeric value - byte

0

Capitals

AllPetiteCaps | AllSmallCaps | Normal | PetiteCaps | SmallCaps | Titling | Unicase

FontCapitals.Normal

CapitalSpacing

Boolean

false

CaseSensitiveForms

Boolean

false

ContextualAlternates

Boolean

true

ContextualLigatures

Boolean

true

ContextualSwashes

Numeric value - byte

0

DiscretionaryLigatures

Boolean

false

EastAsianExpertForms

Boolean

false

EastAsianLanguage

HojoKanji | Jis04 | Jis78 | Jis83 | Jis90 | NlcKanji | Normal | Simplified | Traditional | TraditionalNames

FontEastAsianLanguage.Normal

EastAsianWidths

Full | Half | Normal | Proportional | Quarter | Third

FontEastAsianWidths.Normal

Fraction

Normal | Slashed | Stacked

FontFraction.Normal

HistoricalForms

Boolean

false

HistoricalLigatures

Boolean

false

Kerning

Boolean

true

MathematicalGreek

Boolean

false

NumeralAlignment

Normal | Proportional | Tabular

FontNumeralAlignment.Normal

NumeralStyle

Boolean

FontNumeralStyle.Normal

SlashedZero

Boolean

false

StandardLigatures

Boolean

true

StandardSwashes

numeric value – byte

0

StylisticAlternates

numeric value – byte

0

StylisticSet1

Boolean

false

StylisticSet2

Boolean

false

StylisticSet3

Boolean

false

StylisticSet4

Boolean

false

StylisticSet5

Boolean

false

StylisticSet6

Boolean

false

StylisticSet7

Boolean

false

StylisticSet8

Boolean

false

StylisticSet9

Boolean

false

StylisticSet10

Boolean

false

StylisticSet11

Boolean

false

StylisticSet12

Boolean

false

StylisticSet13

Boolean

false

StylisticSet14

Boolean

false

StylisticSet15

Boolean

false

StylisticSet16

Boolean

false

StylisticSet17

Boolean

false

StylisticSet18

Boolean

false

StylisticSet19

Boolean

false

StylisticSet20

Boolean

false

Variants

Inferior | Normal | Ordinal | Ruby | Subscript | Superscript

FontVariants.Normal

See Also

Concepts

Typography in Windows Presentation Foundation

Sample OpenType Font Pack

Packaging Fonts with Applications

Reference

Typography

Other Resources

OpenType Specification