I need my WPF app to use a true-type font for a different language. I have the font located in a folder called 'fonts' inside the project. The font I'm using is available for free download here
Since the font is installed in my system i first tried
FontFamily="FMBasuru"
I've read the post here and tried doing (this is the exact markup I'm using including font name)
<Window.Resources>
<Style x:Key="SinhalaFont">
<Setter Property="TextElement.FontFamily" Value="fonts/#FMBasuru"/>
</Style>
</Window.Resources>
...
<TextBlock Style="{DynamicResource SinhalaFont}">r</TextBlock>
...
I made sure that I'm using the correct font name instead of the font filename. What could have I got wrong?
The FontSize, FontFamily, FontWeight, FontStyle, and FontStretch properties are used to set the font size, family, weight, style and stretch to the text of a TextBox. The code snippet in Listing 6 sets the font properties of a TextBox.
In WPF, the default font family for text displayed on controls (like Label and Button) is Segoe UI, with a default size of 12.0 device-independent units.
Updated: Create a folder name Fonts and copy the font which you want and change the BuildAction to Resource
<Window.Resources>
<FontFamily x:Key="test" >/Fonts/#Pirulen</FontFamily>
</Window.Resources>
<Grid>
<TextBlock FontSize="25" HorizontalAlignment="Center"
FontFamily="{StaticResource test}">Kishore Kumar</TextBlock>
</Grid>
just refer this document
WPF - Add Custom Font
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With