Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - Add Custom Font

I'm trying to add a custom font as a resource in my application. I have a "CustomFont" directory in the application and all the fonts inside of it are set to "Resource"

<Window.Resources>
    <Style x:Key="Gotham-XLight">
        <Setter Property="TextElement.FontFamily" 
                Value="/CustomFonts;Component/#Gotham-XLight" />
    </Style>
</Window.Resources>

And then on my TextBlock I have this: (inside a grid)

<TextBlock x:Name="TimeTextBlock" Style="{DynamicResource Gotham-XLight}" 
           TextAlignment="Center" FontSize="25" FontWeight="Bold" 
           Foreground="White" Text="TextBlockTimer" 
           Margin="105,242.974,0,226.975" HorizontalAlignment="Left" 
           Width="221.919" />

But I'm not seeing my font as people say. Am I doing something wrong?

like image 774
John Batdorf Avatar asked Dec 11 '08 05:12

John Batdorf


People also ask

How do I add a font to Objective C project?

Make sure you use the correct name, in the font application (after clicking twice and installing your font in your computer, you can see this information) tap CMD + i, and check the "PostScript name" of your font, that is how you will call it.


1 Answers

You may want to check the name of the font, you need to specify the name of the font not the name of the file.

Double click on the font file and it should show a "Font name:" that's what you want to make sure is specified in your style.

like image 153
joshperry Avatar answered Sep 19 '22 17:09

joshperry