Skip to content

Instantly share code, notes, and snippets.

@grumpydev
Created August 5, 2011 14:17
Show Gist options
  • Select an option

  • Save grumpydev/1127620 to your computer and use it in GitHub Desktop.

Select an option

Save grumpydev/1127620 to your computer and use it in GitHub Desktop.
<Window x:Class="FontFallbackTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:FontFallbackTest="clr-namespace:FontFallbackTest"
xmlns:Generic="clr-namespace:System.Collections.Generic;assembly=mscorlib" Title="MainWindow" Height="550" Width="525">
<Window.Resources>
<FontFallbackTest:TestFont x:Key="TestFont2"/>
</Window.Resources>
<Grid>
<TextBlock FontSize="48" FontFamily="{StaticResource TestFont}">This is some text</TextBlock>
<TextBlock Margin="0,100,0,0" FontSize="48" FontFamily="c:\windows\fonts\GOTHIC.TTF#Century Gothic, Wingdings">This is some text</TextBlock>
<Label Content="This is some text" FontSize="48" Margin="0,200,0,0">
<Label.FontFamily>
<FontFamily xmlns:sys="clr-namespace:System;assembly=mscorlib">
<FontFamily.FamilyNames>
<sys:String x:Key="en-US">Century, Century Gothic, Century Schoolbook</sys:String>
</FontFamily.FamilyNames>
<FontFamily.FamilyMaps>
<FontFamilyMap Target="Century Gothic" />
<!-- used when Century Gothic is not available -->
<FontFamilyMap Target="Arial" />
</FontFamily.FamilyMaps>
</FontFamily>
</Label.FontFamily>
</Label>
<Label Margin="0,150,0,0" FontSize="48" FontFamily="{StaticResource TestFont2}">This is some text</Label>
</Grid>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment