Reduce the available fonts in the RadRichTextBoxRibbonUI

2 posts, 1 answers
  1. papadi
    papadi avatar
    35 posts
    Member since:
    Nov 2008

    Posted 29 Aug 2012 Link to this post

    I'm using RadRichTextBoxRibbonUI to handle a richtext box. By default the control creates a drop down list with all the available fonts of the system. I would like to restrict my user and provide him/her with specific ones. How do I do that?
  2. Answer
    Nikolay Demirev
    Nikolay Demirev avatar
    102 posts

    Posted 30 Aug 2012 Link to this post


    The RadRibbonComboBox showing the font families is by default bound to the RegisteredFonts of the FontFamiliesProvider class. The FontFamilyProvider checks what fonts are installed on the machine and adds them to the RegisteredFonts collection. The same collection is also used by the default SelectionMiniToolBar.

    In case you would like both the RibbonUI and the SelectionMiniToolBar to use your set of fonts, you can keep the binding and only change the RegisteredFonts like this:

    foreach (var font in FontManager.GetRegisteredFonts().ToList())
    List<FontFamily> myFonts = new List<FontFamily>() { new FontFamily("Arial"), newFontFamily("Verdana"), new FontFamily("Comic Sans MS") };
    foreach (var font in myFonts)

    This should be done right after the InitializeComponent() method in the constructor of the page. 

    If you want to change the fonts only in the RibbonUI, you can do so by removing the binding of the RadRibbonComboBox from the XAML of the page. After that, you can bind the combo box to a set of font families you wish to use or just add them as different ComboBoxItems like this:
    <telerik:RadRibbonComboBox CanAutocompleteSelectItems="False" CanKeyboardNavigationSelectItems="False" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedValue.Tag}" Height="21" IsReadOnly="True" OpenDropDownOnFocus="True" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontFamilyCommand}" telerik:ScreenTip.Description="Change the font family." telerik:ScreenTip.Title="Font" Width="132" >
        <telerik:RadRibbonComboBoxItem Content="Arial" Tag="Arial" />
        <telerik:RadRibbonComboBoxItem Content="Comic Sans MS" Tag="Comic Sans MS" />
        <telerik:RadRibbonComboBoxItem Content="Verdana" Tag="Verdana" />

    I hope this helps.

    All the best,
    Nikolay Demirev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
Back to Top