Hi,
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?
1 Answer, 1 is accepted
0
Accepted
Nikolay Demirev
Telerik team
answered on 30 Aug 2012, 02:59 PM
Hello,
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())
{
FontManager.UnregisterFont(font);
}
List<FontFamily> myFonts = new List<FontFamily>() { new FontFamily("Arial"), newFontFamily("Verdana"), new FontFamily("Comic Sans MS") };
foreach (var font in myFonts)
{
FontManager.RegisterFont(font);
}
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" >