23
Nov
07

Populating the nested font family ComboBox control in a Flex RichTextEditor control

The following example shows you how you can edit the font family combo box in the RichTextEditor control in Flex.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/11/23/populating-the-nested-font-family-combobox-control-in-a-flex-richtexteditor-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Array id="fontFamilyArr">
        <mx:String>Arial</mx:String>
        <mx:String>Verdana</mx:String>
        <mx:String>Comic Sans MS</mx:String>
    </mx:Array>

    <mx:RichTextEditor id="richTextEditor"
            fontFamilyArray="{fontFamilyArr}" />

</mx:Application>

View source is enabled in the following example.

You can also set the fontFamilyArray property using ActionScript, as seen in the following snippet:

richTextEditor.fontFamilyArray = fontFamilyArr;

Or, you can set the data provider on the ComboBox control directly, as seen in the following snippet:

richTextEditor.fontFamilyCombo.dataProvider = fontFamilyArr;

2 Responses to “Populating the nested font family ComboBox control in a Flex RichTextEditor control”


  1. 1 Christian May 28th, 2008 at 11:26 am

    Where is it grabbing the Comic Sans font from? The system? I’m trying to define a custom font for the RichTextEditor and have gotten it to display in the editor, but the bold and italics don’t react. Have been able to define a custom font?

  2. 2 a_[w] Jun 4th, 2008 at 8:42 am

    Hi! How i can add embedded font to RichTextEditor?
    I’m trying this solution
    .fontFamilyArray = [’Arial’, ‘Verdana’, ‘VerdanaEmbeded’];
    and many others but they not works.

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".