1 Reply Latest reply on Sep 25, 2009 10:10 AM by Flex harUI

    embedded fonts & htmlText

    michael nieuwenhuizen Level 1

      I'm trying to use embedded fonts in htmlText.  I've embedded the font in the Style tag:

       

           @font-face {
                  src: url("someFont.ttf");
                  fontFamily: "myFont";

           }

       

      Now if I add it to a Text component like:

       

           <mx:Text id="myText" htmlText="This is some text" fontFamily="myFont" />

       

      it all works fine.  If I try to use the <font> tag inside the htmlText like

       

           myText.htmlText = "<font face='myFont'>This is some text</font>";

       

      with a component <mx:Text id="myText" /> it doesn't work.  If I use a font that's not embedded like

       

           myText.htmlText = "<font face=Georgia'>This is some text</font>";

       

      it works fine. So my question: how can I use the <font face=.. > tag in htmlText with embedded fonts?

        • 1. Re: embedded fonts & htmlText
          Flex harUI Adobe Employee

          The underlying flash.text.TextField that actually does the display of text needs to have a flag flipped to tell it to use embedded fonts.  By specifying an embedded fontFamily in the MXML, the Flex framework figures out that it is embedded and flips that flag.

           

          If you want to use different font tags in your html, all of the fontFamily specified must be in the same SWF and all must be embedded.  Then specify in the MXML one of the embedded fonts and override that font with the font tags in the html.  You can also call setStyle("fontFamily", "myFont") before setting the htmlText in ActionScript.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui