There are lots of typographic features of WPF. These features include improved quality and performance of text rendering, OpenType typography support, enhanced international text, enhanced font support, and new text application programming interfaces (APIs).
Here we discuss about some basic typographic properties use in WPF.
Code using Typographic Properties
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Typography_Samp.Page1"
WindowTitle="Typography Variants Sample">
<FlowDocument Name="tf1" FontSize="18" ColumnWidth="600.0">
<Paragraph FontSize="20" Margin="0,0,0,10">Typography Variants Sample</Paragraph>
<Paragraph Margin="0,0,0,50">
May I help you
</Paragraph>
<Paragraph>
<StackPanel Orientation="Horizontal" Margin="10" HorizontalAlignment="Center">
<Button Click="changeComicSansMS">Comic Sans MS</Button>
<Button Click="changePalatino">Palatino Linotype</Button>
<Button Click="changeJokerman">Jokerman</Button>
<Button Click="changeVerdana">Verdana</Button>
</StackPanel>
<LineBreak/
The
<Run Typography.Variants="Superscript">superscript</Run>
and
<Run Typography.Variants="Subscript">subscript</Run>
H
<Run Typography.Variants="Inferior">2</Run>
SO
<Run Typography.Variants="Inferior">4</Run>
</Paragraph>
</FlowDocument>
</Page>
Code behind VB window
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Namespace Typography_Samp
Partial Public Class Page1
Inherits Page
Public Sub changeComicSansMS(ByVal sender As Object, ByVal e As RoutedEventArgs)
tf1.FontFamily = New FontFamily("Comic Sans MS")
End Sub
Public Sub changePalatino(ByVal sender As Object, ByVal e As RoutedEventArgs)
tf1.FontFamily = New FontFamily("Palatino Linotype")
End Sub
Public Sub changeJokerman(ByVal sender As Object, ByVal e As RoutedEventArgs)
tf1.FontFamily = New FontFamily("Jokerman")
End Sub
Public Sub changeVerdana(ByVal sender As Object, ByVal e As RoutedEventArgs)
tf1.FontFamily = New FontFamily("Verdana")
End Sub
End Class
End Namespace
OUTPUT
You see here some text is written and now we using typographic properties we apply different types of fonts on text, notice that the hole text changes its font.
Result after click on Jokerman
Result after click on Palatino Linotype
CONCLUSION
I hope you will enjoy this.