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

Round the font size on radribbonbutton

1 Answer 22 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 30 Aug 2012, 09:55 PM
Hi,

I am using the radribbonbutton to increment the font size.
 <telerik:RadRibbonButton telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=IncrementFontSizeCommand}"  telerik:ScreenTip.Description="Increase the font size." telerik:ScreenTip.Title="Grow Font" Size="Small" SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/font-increasesize.png" />

But the html in string format has the following output.
<p class="Normal "><span style="font-weight: bold;font-size: 14.3333333333333px;">hello world</span></p>

As we notice above the font size is into 14.33333px. Is there a way that we can only allow :10,13,16,18,24,32 and 48.

Please let us know ASAP if this is possible on the button to restrict this value.

Thanks in Advance,
Steve.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 31 Aug 2012, 05:41 PM
Hello Steve,

The Increment and DecrementFontSizeCommand change the font size of the current text in the editor by 2 points. At this point, the behavior of the two commands cannot be customized so that user-defined values could be used.

As for the HTML output, HtmlFormatProvider uses pixels as a measuring unit when exporting the font size of the spans. In order to convert points to pixels, the value is multiplied by 4/3, for example:
1 pt = 1.33 px
12 pt = 16 px
14 pt = 18.67 px
16 pt = 21.33 px

This is why the values do not appear as whole numbers.

On the other hand, in order to have the values 10,13,16,18,24,32 and 48 px in the exported HTML, the following values must be set to the spans in the document and visible in the UI of the editor:
10 px = 7.5 pt
13 px = 9.75 pt
16 px = 12 pt
18 px = 13.5 pt
and so on, which are not whole numbers again.

We have decided that it would be better to use whole numbers in the editor, as this creates a better user experience. Could you share some details as to why you would like to use the values you listed?

All the best,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Steve
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or