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

Change font from code

1 Answer 813 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Gokhan
Top achievements
Rank 1
Gokhan asked on 21 Dec 2014, 06:17 PM
I can not change fonts of some parts of the documents.
editor.InsertLine(" message")
Some pars of lines tahoma some parts of lines are Times New Roman

Thanks..

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 24 Dec 2014, 02:15 PM
Hello Gokhan,

Thank you for contacting us.

You can change the font family of some particular parts of text by using RadFlowDocumentEditor's CharacterFormatting property. The following code snippet shows how to insert two paragraphs with text - the first one is with font family "Jokerman" and the second one is with font family "Times New Roman":
editor.CharacterFormatting.FontFamily.LocalValue = new ThemableFontFamily("Jokerman");
editor.InsertText("First paragraph is Jokerman.");
editor.InsertParagraph();
editor.CharacterFormatting.FontFamily.LocalValue = new ThemableFontFamily("Times New Roman");
editor.InsertText("Second paragraph is Times New Roman.");

You can find more information about styling the content by following this link to Chaging Current Styles documentation section.

I hope this is helpful. If you have any other questions or concerns do not hesitate to contact us again.

Regards,
Deyan
the Telerik team
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
RRE
Top achievements
Rank 2
Iron
commented on 26 Apr 2023, 12:49 PM

Dear Gokhan,

on your link there are only some example.

At present how can I have a 'bold' style for a run ?

Thank

Renato

Vladislav
Telerik team
commented on 27 Apr 2023, 12:01 PM

Hi Renato,

Here is a small code snippet demonstrating how to make the text: bold, italic, or underlined.

editor.CharacterFormatting.FontFamily.LocalValue = new ThemableFontFamily("Times New Roman");
editor.InsertText("First paragraph is normal.");
editor.InsertParagraph();
editor.CharacterFormatting.FontWeight.LocalValue = FontWeights.Bold;
editor.InsertText("Second paragraph is bold.");
editor.InsertParagraph();
editor.CharacterFormatting.FontWeight.LocalValue = FontWeights.Normal;
editor.CharacterFormatting.FontStyle.LocalValue = FontStyles.Italic;
editor.InsertText("Third paragraph is italic.");
editor.InsertParagraph();
editor.CharacterFormatting.FontStyle.LocalValue = FontStyles.Normal;
editor.CharacterFormatting.UnderlinePattern.LocalValue = Telerik.Windows.Documents.Flow.Model.Styles.UnderlinePattern.Single;
editor.InsertText("Fourth paragraph is underlined.");
editor.InsertParagraph();
editor.CharacterFormatting.UnderlinePattern.LocalValue = Telerik.Windows.Documents.Flow.Model.Styles.UnderlinePattern.None;
editor.InsertText("Fifth paragraph is normal again.");

I hope this helps.

 

RRE
Top achievements
Rank 2
Iron
commented on 27 Apr 2023, 12:46 PM

Thank you,

Perfect!

Renato

Tags
WordsProcessing
Asked by
Gokhan
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or