If your font resource file is a file in .ttf(.otf) format, you could try to use the resource font by following the steps below.
1.Adding a font file to Resources.resx(the circled part will automatically appear) and rename the resource to Pacifico.
Project and resource path structure:
2.Right click on the .ttf file, select Properties and set Build Action to Resource:
Dictionary1.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<FontFamily x:Key="PacificoFont">pack://application:,,,/Resources/#Pacifico</FontFamily>
<Style x:Key="lbl_demo" TargetType="{x:Type Label}">
<Setter Property="FontFamily" Value="{StaticResource PacificoFont}"/>
</Style>
</ResourceDictionary>
App.xaml:
<Application x:Class="ResourceFont.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ResourceFont"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="Dictionary1.xaml"/>
</Application.Resources>
</Application>
MainWindow.xaml:
<Window.Resources>
<Style x:Key="font" TargetType="Label">
<Setter Property="FontFamily" Value="Resources/#Pacifico"/>
</Style>
</Window.Resources>
<StackPanel>
<Label Style="{DynamicResource font}" Content="hello"/>
<Label Style="{StaticResource lbl_demo}" Content="hello"/>
</StackPanel>
Result:
If the answer is the right solution, please click Accept Answer and kindly upvote it. If you have extra questions about this answer, please click Comment.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.