Font Embedding in Flash CS5
Flash CS5 introduces a new way of emebdding fonts and unfortunately it breaks the older way of embedding fonts :( . The older way of embedding fonts which can be found here , does not work anymore for Flash IDE projects though that will still work for pure AS3 projects. I was using this method only in my project but as soon as I upgraded to flash CS5, text disappeared in my compiled movie. Googling pointed me to these two:
- Characters missing from text in Flash CS4 file when opened in Flash CS5
- Flash CS5 font embedding – it’s totally different
Updated on – 10/18/2010
Embed fonts for consistent text appearance
Do you enjoy this blog? Do you find the information helpful? Then go ahead and treat me to a coffee or send me a tip! I love Barista's Cappuccino Cookie n Cream . Choose any amount you wish, whatever you feel this blog is worth to you.-
-
-
I’ve been searching for the solution to this for months and I’m still not able to implement this css text on my personal website that once worked in CS4. I have set up a empy document, with 4 weights of Univers exported for ActionScript from the library. Here’s my timeline code:
var css: StyleSheet; function init():void{ //these are 4 versions of Univers i have exported in my library. some sources say they must be registered, some say they dont. /*Font.registerFont(UniversLC); Font.registerFont(UniversLCO); Font.registerFont(UniversBC); Font.registerFont(UniversBCO);*/ var cl:URLLoader=new URLLoader(new URLRequest("test.css")); cl.addEventListener(Event.COMPLETE, cssLoaded); } function cssLoaded(evt:Event):void{ css=new StyleSheet(); css.parseCSS(evt.target.data); var xl:URLLoader=new URLLoader(new URLRequest("test.xml")); xl.addEventListener(Event.COMPLETE, xmlLoaded); } function xmlLoaded(evt:Event):void{ var xmlData: XML=new XML(evt.target.data); var tf:TextField=new TextField(); tf.multiline=true; tf.width=tf.height=500; addChild(tf); tf.styleSheet=css; //some sources have said to add this line, some say not to: //tf.embedFonts=true; tf.htmlText=xmlData.here; } init();Locally, the text shows up fine, but apparently it is not pulling the font from the library but rather from what is installed on my system, as on most other computers all the text will show up as just Times. If I set the embedFonts to true, I get NO text, and whether or not I use the register fonts commands appears to have no affect. Unfortunately there appears to be no official documentation on this problem that is helpful, and I am getting conflicting help from the very few blogs that touch on this. If anyone is able to help, you can have my firstborn child, or really anything that is mine. I am desperate. I’ve zipped up the fonts, css, xml, and fla if anyone is feeling extra helpful. It is available here: http://danehansen.com/temp/test.zip
Thanks in advance.
-
Hi Dane,
Unfortunately I have never coded in timeline so I made some changes
1. Moved to code to an external action script file from the fla.
2. Some changes to the way fonts were being embedded.
3. Changed the stylesheet.
4. Also at least for me, if I set the embed font property to true for a text field, any text which is not having a style using the embed font does not get displayed. So the first line in your sample XML file was not getting displayed with embed font set to true unless it was also moved inside the body tag and then, well as body tag was using the Univers font, it gets displayed in the same font. If you want to show it in some other font, you will have to emb that font as well even if you are sure that it will be available on the target system. At least that is how it worked for me.Anyways here is the link to updated file.
Updated FLA and other files.
Link to published exampleTested in one other machine which did not have this font installed and text seemed fine to me. If there is any problem, let me know.
-
-
-
Well, AFAIK you will have to export the class if you want to use it in your AS3 code. And though I have not checked it myself but looks like you can delay the exporting of classes to some other frame instead of the first frame to some other frame by going to “Publish Settings” ==> “Flash” ==> “Script Settings” and on that screen change the value for the field “Export classes in frame”. You can see more on this here and here. The adobe documentation is for CS3 and talks about AS2, but as I see these option available in CS5 as well, am guessing that it may work for you.
-
- Comment Feed for this Post

I really like this post thanks you are sharing a great article info