Hi all,

My setup to load embedded fonts into Flex 2.0.1 based app is as follows:

 I declare 3 fonts that I want to embed in <mx:Style> tag:

<mx:Style>

@font-face {
    src:url("assets/fonts/arial.ttf");
    fontFamily: Arial;
}
/* CSS file */
@font-face {
    src:url("assets/fonts/pala.ttf");
    fontFamily: Palatino;
}

/* CSS file */
@font-face {
    src:url("assets/fonts/trebuc.ttf");
    fontFamily: Trebuchet;
}
 </mx:Style>

Later in the code, I use the following function to assign the HTML
tagged text to my mx:Text field instance 'textField':

------------------------------------------------------------------
private function assignText() : void {
                                textField.setStyle("fontFamily", "Trebuchet");  
                        
                                textField.htmlText = "<TEXTFORMAT LEADING='2'>" 
+
                                "<P ALIGN='LEFT'><FONT FACE='Trebuchet' 
SIZE='18' COLOR='#0B333C'
LETTERSPACING='0' KERNING='0'>Example line of text</FONT></P>" +
                                "<P ALIGN='LEFT'><FONT FACE='Palatino' 
SIZE='18' COLOR='#0B333C'
LETTERSPACING='0' KERNING='0'>Example line of text</FONT></P>" +
                                "<P ALIGN='LEFT'><FONT FACE='Arial' SIZE='18' 
COLOR='#0B333C'
LETTERSPACING='0' KERNING='0'>Example line of text</FONT></P>" +
                                "</TEXTFORMAT>";                                
}
------------------------------------------------------------------

And it works! It works because I change the style 'fontFamily' for
Text textField.setStyle("fontFamily", "Trebuchet") prior to setting
value to the htmlText field!

All 3 lines of text are correctly displayed using glyphs from 3
various embedded fonts, but if I remove the line
textField.setStyle("fontFamily", "Trebuchet") from the code, then the
text is displayed using device fonts, not embedded ones.

Why is that?

Why do I have change the style 'fontFamily' of Text component prior to
setting value of the 'htmlText' property of mx:Text in order to get
embedded fonts to be working?

And the attribute value for the style "fontFamily" should the valid
identificator of any of 3 fonts successfully loaded - Trebuchet,
Palatino or Arial.

--
Med venlig hilsen / Best regards
Andriy Panas
[EMAIL PROTECTED]

Reply via email to