Professional, Software

Custom Fonts

I wanted to use some custom fonts in application. Karen sent me this link to some free custom fonts. I downloaded one of them to use in my application. It took me a while to figure out the exact syntax to get it working so I thought I would write a short blog post.

  1. I added the font that I downloaded to my project
  2. I marked BuildAction = Resource in the properties tab for the font file
  3. Then I refer to  that Font just like any other resource in the FontFamily property
    1. so here is the part i was stuck for a while. The FontFamily property should take a value “<Uri to Font file>#<Font Family Name>. I was having hard time figuring out what the font family would be for downloaded font. Mark told me that I should just double click on the font and then it opens up in FontViewer and shows the name of the font.

So the only thing in code changes was

<TextBox 
            Grid.Column="1" Grid.Row="1" Margin="40,10,120,10" 
            Text="TextBox" 
            x:Name="txtSearch" 
            Background="{StaticResource TextBoxBackgroundBrush}" 
            FontFamily="Fontin-Bold.ttf#Fontin" FontSize="20"/>

Advertisements
Standard

3 thoughts on “Custom Fonts

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