Compartilhar via


Recursos de fontes OpenType

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

Este tópico contém as seguintes seções.

  • OpenType Font Format
  • Variants
  • Capitals
  • Ligatures
  • Swashes
  • Alternates
  • Numerical Styles
  • Typography Class
  • Tópicos relacionados

OpenType Font Format

The OpenType font format is an extension of the TrueType® font format, adding support for PostScript font data. O OpenType formato de fonte foi desenvolvido em parceria pela Microsoft e Adobe Corporation. OpenTypeServiços de fontes e o sistema operacional que suporte OpenType fontes fornecem aos usuários uma maneira simples de instalar e usar fontes, se as fontes que contêm TrueType contornos ou contornos CFF (PostScript).

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.

Observação

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 Pacote Exemplo de fontes OpenType.

Consulte o OpenType especificação para obter detalhes sobre o OpenType formato de fonte.

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. A maioria dos OpenType fontes exponham somente um subconjunto do total OpenType recursos disponíveis. OpenTypefontes oferecem os seguintes recursos.

  • 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

Texto usando sobrescritos OpenType

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

Texto usando subscritos OpenType

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

Texto usando sobrescritos e subscritos OpenType

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. Normalmente, quando o texto é processado como todas em maiúsculas, o espaçamento entre letras pode aparecer muito apertado e a espessura e a proporção das letras muito pesadas. OpenTypeoferece suporte a diversos formatos de estilo para maiúsculas, incluindo versalete, maiúsculas petite, títulos e espaçamento de capital. 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

Texto usando maiúsculas OpenType

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>

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

Texto usando maiúsculas de título OpenType

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

Texto usando espaçamento de maiúsculas OpenType

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

Ligaduras são dois ou mais glifos que são transformados em um único glifo para criar mais de texto legível ou atraente. OpenTypefontes oferecem suporte a quatro tipos de ligaduras:

  • 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

Texto usando ligaturas padrão OpenType

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

Texto usando ligaturas discricionárias OpenType

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>

Por padrão, OpenType fontes em Windows Presentation Foundation (WPF) permitem ligaduras padrão. 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

Texto usando ligaturas padrão OpenType

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

Texto usando ligaturas padrão OpenType desabilitadas

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

Texto usando glifos padrão e de caracteres ornamentados OpenType

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

Texto usando caracteres ornamentados OpenType

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

Texto usando caracteres ornamentados contextuais OpenType

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

Alternativas são os glifos podem ser substituídos por um glifo padrão. OpenTypefontes, como, por exemplo, a fonte de Pericles usadas nos exemplos a seguir, podem conter glifos alternativos, você pode usar para criar aparências diferentes para o texto. The following text displays standard glyphs for the Pericles font.

Text using OpenType standard glyphs

Texto usando glifos padrão OpenType

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

Texto usando glifos alternativos estilísticos OpenType

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

Texto usando glifos alternativos estilísticos OpenType

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

Texto usando alternativas contextuais aleatórias OpenType

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

Texto usando formas históricas OpenType

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

Texto usando frações verticais e com barras diagonais OpenType

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

Texto usando numerais de estilo antigo OpenType

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

Text using OpenType old style numeral sets

Texto usando conjuntos de numerais de estilo antigo OpenType

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

Texto usando valores proporcionais e tabulares OpenType

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

Texto usando numerais zero cortados OpenType

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>

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

Texto usando maiúsculas OpenType

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

            Dim run_1 As New Run("CAPITALS ")
            MyParagraph.Inlines.Add(run_1)

            Dim run_2 As New Run("Capitals ")
            run_2.Typography.Capitals = FontCapitals.SmallCaps
            MyParagraph.Inlines.Add(run_2)

            Dim run_3 As New Run("Capitals")
            run_3.Typography.Capitals = FontCapitals.AllSmallCaps
            MyParagraph.Inlines.Add(run_3)

            MyParagraph.Inlines.Add(New LineBreak())
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)

Valor padrão

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

Consulte também

Referência

Typography

Conceitos

Tipologia no WPF

Pacote Exemplo de fontes OpenType

Empacotando Fontes com Aplicações

Outros recursos

Especificação de OpenType