FREE BOOK

Chapter 9: OpenType Font Support

Posted by Manning Publication Free Book | Silverlight January 19, 2012
In this chapter, we’ll take a look at OpenType support including ligatures, alternatives and stylistic sets, font capitals, fractions and number formats, and variants including superscript and subscript.

A ligature is one or more characters joined together as a single glyph. Typically this is done with two characters linked together based upon context. In traditional printing, the ligature would be a single printing block. In computer typography, the font defines how the ligature is handled. Not only does this look more refined, but it often increases readability.

The most common ligatures revolve around the letters following the letter "f". For example, figure 1 shows both the no-ligature version and the version using OpenType ligatures using the Gabriola font included in Windows 7.



Figure 1 Standard ligatures in the OpenType Gabriola font. Pay particular attention to the dots on the i and j characters, the cross bar in the t and f, and the tops of the lowercase f characters and how they connect to the next character.

The use of ligatures removes the awkward splicing of the cross bar on the lowercase "f" and "t" characters (a combination I see often due to typing out my employer's name "Microsoft"). It also removes the dots on the lowercase "i" and "j" characters, since those mash up against the f. Finally, you'll notice that the top of the 'f" is handled differently when followed by other tall characters such as "f" and 'l".

If the font supports it, Silverlight enables or disables the use of standard ligatures such as those shown here through the Typography.StandardLigatures attached property. Listing 1 shows the markup required to set this property.

Listing 1 Using ligatures

<Grid x:Name="LayoutRoot" Background="White">
  <StackPanel>
    <TextBlock Text="ft fi fj fl ff ffi ffj ffl"
               HorizontalAlignment="Center"
               FontSize="100"
               FontFamily="Gabriola"
               Typography.StandardLigatures="False" /> #A
    <TextBlock Text="ft fi fj fl ff ffi ffj ffl"
               HorizontalAlignment="Center"
               FontSize="100"
               FontFamily="Gabriola"
               Typography.StandardLigatures="True" /> #B
  </StackPanel>
</Grid>
#A Disabled
#B Enabled


In addition, if the OpenType font supports them, Silverlight enables contextual ligatures, discretionary ligatures, and historical ligatures through the
ContextualLigatures, DiscretionaryLigatures and HistoricalLigatures properties, respectively. You use these the same way you use the StandardLigatures property.

Historical ligatures are ones that were once standard, but are no longer commonly used. If you're looking to make your app appear classical (or maybe steampunk) and the font supports them, historical ligatures can add real character.

Contextual ligatures are ones that the font designer believes are appropriate for use with the font. Enabling both standard and contextual ligatures will give you the complete set the font designer felt were appropriate for normal use.

Discretionary ligatures are ones that the font designer included for specific situations and which may not apply to general use throughout the entire body of your text.
Ligatures can help increase the readability and aesthetics of your text. Another way to really fancy things up is to use contextual alternates and stylistic sets.

Total Pages : 7 12345

comments