Using text areas in ActionScript 3 application has always been a hassle, right?
Adobe’s Text Layout Framework (introduced in Flash Player 10/AIR 1.5) offers elaborate ways of working with text, including text that flows between several columns, text input, undo capabilities and improved font rendering. To use TLF, the font embed tag requires the “embedAsCFF” attribute to be set to true.
Though, when trying to embed the beautiful font Lato, we ran into transcoding errors:
ERROR /src/fonts/Lato.as[8:3]: unable to build font 'LatoRegular' [Embed( ^ ERROR /src/fonts/Lato.as[8:3]: Unable to transcode ../../assets/fonts/lato/Lato-Reg.otf. [Embed( ^
This is the embed tag we used:
[Embed( source="../../assets/fonts/lato/Lato-Reg.otf", fontName="LatoRegular", embedAsCFF="true") ] public static var LatoRegular : Class;
It turns out that the embed tag is correct. The compiler uses the wrong font manager by default, which is why you need to supply an additional compiler argument:
Very well. Last thing to do: telling your TextLayoutFormats to use embedded CFF fonts.
var format : TextLayoutFormat = new TextLayoutFormat(); format.fontFamily = "LatoRegular"; format.fontLookup = FontLookup.EMBEDDED_CFF; format.renderingMode = RenderingMode.CFF;
It’s just a few lines of code, but it took me several hours to find out. I hope this saves you some time…