how to change the default FontFamily for the RadRichTextBox?

4 posts, 0 answers
  1. ji
    ji avatar
    3 posts
    Member since:
    Jan 2009

    Posted 19 Oct 2010 Link to this post

    <telerik:RadRichTextBox.Document >
                        <telerik:RadDocument>
                            <telerik:Section>
                                <telerik:Paragraph FontSize="12" />
                            </telerik:Section>
                        </telerik:RadDocument>
                    </telerik:RadRichTextBox.Document>

    -----------
    this code can not change FontFamily 
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 20 Oct 2010 Link to this post

    Hi ji,

    You can set the FontSize at Paragraph level, but FontFamily, FontWeight, FontStyle and a few other properties are available only at Span level. This is how they can be set:
    <telerik:RadRichTextBox >
        <telerik:RadRichTextBox.Document>
            <telerik:RadDocument>
                <telerik:Section>
                    <telerik:Paragraph FontSize="14">
                        <telerik:Span FontFamily="Arial Black" FontStyle="Italic" Text="example" />
                    </telerik:Paragraph>
                </telerik:Section>
            </telerik:RadDocument>
        </telerik:RadRichTextBox.Document>
    </telerik:RadRichTextBox>

    If you have any other questions, feel free to get back to us.

    All the best,
    Iva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. tj
    tj avatar
    3 posts
    Member since:
    Oct 2010

    Posted 27 Oct 2010 Link to this post

    Thanks for your reply!

    Is there a way to do it code-behind? I tried to set it in the document, but I cannot find the property.
  4. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 29 Oct 2010 Link to this post

    Hello Tj,

    We have planned to introduce properties to change the default font settings in the next official release (in a couple of weeks).
    Until then, you can set them in code-behind like this:
    For Q2 2010 SP2:
    this.Dispatcher.BeginInvoke(() =>
                {
                   Span firstSpan = this.radRichTextBox.Document.Sections.First.Paragraphs.First.Inlines.First as Span;
                   firstSpan.FontStyle = FontStyles.Normal;
                   firstSpan.FontFamily = new System.Windows.Media.FontFamily("Comic sans MS");
                   firstSpan.FontSize = 20;
                });

    For Q3 2010 Beta:
    this.Dispatcher.BeginInvoke(() =>
               {
                   Section firstSection = this.radRichTextBox.Document.Sections.First;
                   Span firstSpan = (firstSection.Blocks.First as Paragraph).Inlines.First as Span;
                   firstSpan.FontStyle = FontStyles.Normal;
                   firstSpan.FontFamily = new FontFamily("Comic sans MS");
                   firstSpan.FontSize = 20;
               });

    This piece of code can be added in your handler of the Loaded event, for example.
    If you have any other questions, feel free to contact us again.

    Greetings,
    Iva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top