Home > Quick Tip > Quick Tip – Font embedding in Flex 3.0 – II

Quick Tip – Font embedding in Flex 3.0 – II

There is so much to font embedding that I keep getting new problems and resolutions :)
The problem: Embedding font on textfield which renders HTML text.

...
instancetextObj.htmlText = "<font size='28' face='Arial' >Hello <b>How</b> <font
size='28' face='SomeOtherFontFace' >Are </font> You</font>"
...
<mx:Text id="instancetextObj" />

I ensured that the fonts used above are embedded. My css look like:

@font-face {
    src      : url("asset/font/embed_fonts.swf");
    font-family    :  "SomeOtherFontFace";
}

@font-face {
    src      : url("asset/font/embed_fonts.swf");
    font-family    :  "Arial"; 

}

The swf has all the necessary fonts embedded (all required font-weight/typefaces). But somehow it didn’t worked.

Solution:
The solution is that the texfield requires a default font family defined which is embedded
So if you make a simple change to the mxml definition of your textfield like this:

<mx:Text id="instancetextObj" fontFamily="Arial" />

It will work. :)
The better solution is to defined the font family in a “global” style name in css

global
{
     font-family   :   "Arial"
}

I hope this might save your few hours!

<span style=”font-family: Arial;”>Hello <strong>How</strong> <span style=”font-family: Dadhand;”>Are </span> You</span>

Categories: Quick Tip Tags: ,
  1. Seth
    July 9th, 2010 at 20:03 | #1

    Shakher i think you forget to tell how to embed a particular range of the charecters, like if i wan tto add the german charset then how i will add only that?

  2. Sachin
    September 7th, 2010 at 14:59 | #3

    great artical

  1. No trackbacks yet.