fonts not being embedded Flash CS4 AS3

mga picture mga · Jan 17, 2010 · Viewed 7k times · Source

Maybe you can help me with a problem I am having. The URL of the project is: http://www.mauriciogiraldo.com/vgline/beta/

It is a Drupal-powered, AMFPHP-connected AS3 web app. The data goes through to Flash with no problems, I have verified that UTF-8 is fine and all. The problem can be better seen in these URLs:

http://www.mauriciogiraldo.com/vgline/beta/#/146

A plaintext version of that link:

http://www.mauriciogiraldo.com/vgline/node/146

(Note the name of the guy)

The font is Inconsolata although I could use any monospace open-source font if necessary. You can see that I have embedded the font (I even opted for the dynamic textfields to embed the whole thing, full charset) as well as the "New Font" menu in the library. Inconsolata shows up with an asterisk in the CS4 authoring tool (which according to Adobe documentation means the thing is embedded).

I have tried other font embedding options to no avail. Inconsolata seems to have that "ō" character when used in the authoring but it is not showing up in the dynamic texts.

Another problem I am having: if I use static text fields the font doesn't get embedded (WTF). I have to convert the field to dynamic and then it works ("the videogame history timeline" top left is a dynamic text field although I would prefer it not to be... that and others). If I use static text field the font gets converted to some sort of Times New Roman font.

The text is AS3-created (as well as the search results).

I am embedding the text via HTML (.htmlText) and styling with CSS.

The whole code is open source and can be found here:

http://code.google.com/p/vgline/

An example of how I fill in a text field can be found here:

http://code.google.com/p/vgline/source/browse/trunk/src/TLDetail.as

A snippet of such code is:

 var ss:StyleSheet = new StyleSheet();
 var css:String = ".title { color:#333333; font-family:Inconsolata; font-size:16; leading:2; } ";
 css += ".date { color:" + StringUtils.rgb2web(data.color.r, data.color.g, data.color.b) + "; font-family:Inconsolata; font-size:14; leading:4; } ";
 css += ".text { color:#333333; font-family:Inconsolata; font-size:11; leading:4; } ";
 css += ".link { color:#000000; font-family:Inconsolata; font-size:11; leading:4; text-decoration:underline; } ";
 css += "a:hover { text-decoration:none; } ";
 ss.parseCSS(css);
 var fechahtml:String = "<span class='date'>";
 if (data.mes != null && data.dia != null) {
         fechahtml += data.dia + " " + StringUtils.month2name(data.mes) + " " + data.anotext;
 } else if (data.mes != null) {
         fechahtml += StringUtils.month2name(data.mes) + " " + data.anotext;
 } else {
         fechahtml += data.anotext;
 }
 fechahtml += "</span>";
 date_txt = new TextField();
 date_txt.width = 275;
 date_txt.embedFonts = true;
 date_txt.antiAliasType = "advanced";
 date_txt.styleSheet = ss;
 date_txt.htmlText = fechahtml;
 date_txt.x = 8;
 date_txt.y = 3;

 addChild(date_txt);

ANY help will be greatly appreciated. I really don't know what to do.

Thanks

Answer

nikc.org picture nikc.org · Apr 15, 2010

Font embedding is one of my favourite enemies of all time when creating flash. But I found a way to reduce the amount of holes in my walls (and bumps on my head).

  1. Embed the font into the Library
  2. Link the font symbol (in the Library) to a custom class extending the Font-class (lets call it MyFont for now)
  3. Create a TextFormat object (let's call it frmt)
  4. Set frmt.font = new MyFont().fontName
  5. Create a TextField (let's call it tf)
  6. Assign tf.embedFonts = true and tf.defaultTextFormat = frmt

Hope this helps.