#259 – Setting Typography Properties for Text Rendered with an OpenType Font
March 28, 2011 1 Comment
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>
Pingback: #842 – The Differences Between Label and TextBlock | 2,000 Things You Should Know About WPF