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>
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?
Gaurav, thanks for pointing it out. You can specify unicode range in css itself. Here is a useful link: http://livedocs.adobe.com/flex/3/html/help.html?c…
great artical