Joe Howard
asked on
Set custom font WPF
I'm trying to use a custom font of my WPF project, embedding it in the app so it does not have to be installed locally.
I've followed the instructions here to the letter but for some reason it still doesn't work. The proper font is not used.
This is my App.xaml:
I tried this too, but it didn't make a difference either:
And this is how I'm trying to use it:
Notes:
1. The names of the fonts that I have used are the names of the fonts, not the file names.
2. The font can be found here.
3. I tried using the same method with a locally installed font and it didn't work either.
I'd appreciate any help I can get here as I am quite baffled.
I've followed the instructions here to the letter but for some reason it still doesn't work. The proper font is not used.
This is my App.xaml:
<Application x:Class="WPFTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFTest"
StartupUri="MainWindow.xaml">
<Application.Resources>
<FontFamily x:Key="Assistant ExtraLight">pack://application:,,,/Fonts/#Assistant ExtraLight</FontFamily>
<FontFamily x:Key="Assistant Light">pack://application:,,,/Fonts/#Assistant Light</FontFamily>
<FontFamily x:Key="Assistant Regular">pack://application:,,,/Fonts/#Assistant</FontFamily>
</Application.Resources>
</Application>
I tried this too, but it didn't make a difference either:
<Application x:Class="WPFTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFTest"
StartupUri="MainWindow.xaml">
<Application.Resources>
<FontFamily x:Key="Assistant ExtraLight">./Fonts/Assistant ExtraLight.ttf#Assistant</FontFamily>
<FontFamily x:Key="Assistant Light">./Fonts/Assistant Light.ttf#Assistant</FontFamily>
<FontFamily x:Key="Assistant Regular">./Fonts/Assistant.ttf#Assistant</FontFamily>
</Application.Resources>
</Application>
And this is how I'm trying to use it:
<TextBlock FontFamily="{StaticResource Assistant Light}" FontSize="35" >Let's see if this works</TextBlock>
Notes:
1. The names of the fonts that I have used are the names of the fonts, not the file names.
2. The font can be found here.
3. I tried using the same method with a locally installed font and it didn't work either.
I'd appreciate any help I can get here as I am quite baffled.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER