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

change the font size of the editor

6 Answers 987 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Roman
Top achievements
Rank 1
Iron
Roman asked on 10 Jan 2020, 12:14 PM
Hello

I have a small problem which I couldn't find any solution, even though it sounds so simple... The font in my RichTextEditor is too big (see the attached image for an example how it looks). I'm wondering how it's possible to change this font size to a smaller font. I tried several things such as

txtText.ChangeFontSize(4);

or

txtText.RichTextBoxElement.ChangeFontSize(4);

I couldn't find anything about it in the documentation. Is it even possible to change the displayed font size?

Best Regards,
Roman

6 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 10 Jan 2020, 01:18 PM

Hello Roman,

ChangeFontSize method is the right way to change the font size of the RichTextEditor. I suppose that you have added some text in the document and then you use the ChangeFontSize method. If you do so and you already have a text added to the document I can suggest you to select it all before calling the ChangeFontSize method. 

this.radRichTextEditor1.Document.Selection.SelectAll();
this.radRichTextEditor1.RichTextBoxElement.ChangeFontSize(8.5);

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Roman
Top achievements
Rank 1
Iron
answered on 10 Jan 2020, 02:32 PM
Hi Nadya,

Thank you for the quick response.

Since I already tested the code in your answer I had another look at the rest of my code. I've seen that the Text is overwritten at some place (programmatically). This seems to reset the font style, is that correct? If I comment this piece of code where the text is overwritten, it works using your solution. So do I need to do call ChangeFontSize() everytime I overwrite the text programmatically?

Regards,
Roman
0
Nadya | Tech Support Engineer
Telerik team
answered on 13 Jan 2020, 05:48 AM

Hello Roman,

According to your description, it is not clear how exactly do you add the text programmatically. Could you please clarify that? I can suggest you using the span that represents an inline object which allows you to display formatted text.

Section section = new Section();
Paragraph paragraph = new Paragraph();
Span span = new Span("Span declared in code-behind");
paragraph.Inlines.Add(span);
section.Blocks.Add(paragraph);
this.radRichTextEditor1.Document.Sections.Add(section);
span.FontSize = 8.5;

I am looking forward to your reply.

Regards,
Nadya
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Roman
Top achievements
Rank 1
Iron
answered on 13 Jan 2020, 06:15 AM
Hi Nadya,

I'm setting the text like this:

txtText.Text = "Whatever";

Is the span recommended? Why not simply using the Text property?

Regards,
Roman
0
Accepted
Dimitar
Telerik team
answered on 13 Jan 2020, 11:57 AM

Hi Roman,

Setting the Text property will create a new RadDocument and this is why the styles are overridden. However, it is possible to set the default fonts. You can use the following properties for this:   

radRichTextEditor1.RichTextBoxElement.DocumentInheritsDefaultStyleSettings = true;
radRichTextEditor1.RichTextBoxElement.Font = new Font("Segoe Script", 8, FontStyle.Regular);

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Roman
Top achievements
Rank 1
Iron
answered on 13 Jan 2020, 12:08 PM
Hi Dimitar,

Thanks for the answer. This is good to know. Your solution works as well, thanks.

Best Regards,
Roman
Tags
RichTextEditor
Asked by
Roman
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Roman
Top achievements
Rank 1
Iron
Dimitar
Telerik team
Share this question
or