#259 – Setting Typography Properties for Text Rendered with an OpenType Font

WPF includes a Typography class, which allows setting various attached properties for textual elements.  These properties only affect text that is rendered using an OpenType font.

The Typography class lets you specify things like:

  • Superscripts and subscripts
  • Use of capitals and spacing between capitals
  • Ligatures (combined glyphs)
  • Swashes (decorative elements)
  • Alternate glyphs
  • Historical glyphs
  • Proportional spacing for numerals
  • Turning kerning off/on

For example, we can specify that some text be rendered using small capitals, as follows.

		<TextBlock Margin="20" Width="250" Height="55"
		    FontFamily="Constantia" FontSize="14"
		    TextWrapping="Wrap">
			We secure our friends not by accepting favors but by doing them.
			<Run Typography.Capitals="SmallCaps">--Thucydides</Run>
		</TextBlock>

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #259 – Setting Typography Properties for Text Rendered with an OpenType Font

  1. Pingback: #842 – The Differences Between Label and TextBlock | 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: