This is a migrated thread and some comments may be shown as answers.

Changing default font

2 Answers 338 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 18 Dec 2017, 05:24 PM

Hello,

My typical use case requires importing saved html into the editor. The problem I am having is that sometimes that HTML isn't always perfect and will not have a font family specified. This causes the editor to default to Verdana. For the life of me, I can't seem to figure out how to change that to be some other font. Can someone tell me where Verdana is set as the default font? I've tried setting pretty much every font property I can find, but it doesn't seem to matter when I do the html import.

Thanks!

-Tom

2 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 20 Dec 2017, 04:42 PM
Hello Tom,

The font family is applied through the default styles used when the content doesn't define styling. You can change that by modifying the default style which, when importing HTML documents, is Normal Web. Here is an example of how to achieve that:
this.radRichTextBox.Document.StyleRepository["NormalWeb"].SpanProperties.FontFamily = new FontFamily("Arial");

Please, note that the default styles are created for each document and if you would like to always have a different than the default font family, you will need to attach to the DocumentChanged event of RadRichTextBox and set the property as demonstrated above in the handler of this event.

Hope this is helpful.

Regards,
Tanya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Tom
Top achievements
Rank 1
answered on 20 Dec 2017, 04:52 PM
Thank you! The "NormalWeb" style is exactly what I was looking for.
Tags
RichTextBox
Asked by
Tom
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Tom
Top achievements
Rank 1
Share this question
or