Category / Section
How to use custom font in WPF RichTextBox (SfRichTextBoxAdv) control?
1 min read
In the SfRichTextBoxAdv control, you can use any custom font to render text content apart from the fonts installed on your machine.
Add the required font as a resource file in your project.
You can use the custom font by specifying the font name with its reference path and “#” as a prefix.
The following code example demonstrates how to use a custom font in the SfRichTextBoxAdv control.
XAML
<richtextboxadv:sfrichtextboxadv x:name="richTextBoxAdv" fontfamily="Assets/MyFont.ttf#MyFont">
<richtextboxadv:documentadv>
<richtextboxadv:documentadv.characterformat>
<richtextboxadv:characterformat fontfamily="Assets/MyFont.ttf#MyFont">
</richtextboxadv:characterformat>
</richtextboxadv:documentadv.characterformat>
</richtextboxadv:documentadv>
</richtextboxadv:sfrichtextboxadv>
A complete working sample of using a custom font in the WPF RichTextBox can be downloaded from GitHub.