haxenme/swf — pull request #2 by dogles (2013-01-18 17:50:45+00:00)
Title: Fix for TextField fonts

A small fix to ensure that dynamic textfields will retain font information from the resulting SWF.

It's unclear how to actually render using the font embedded in the SWF. Right now, I'm working around this with something like the following when loading a MovieClip, where I replace the font with a font embedded via the nmml:

static function fixFonts(obj:DisplayObject) : Void {
if ( Std.is(obj, DisplayObjectContainer) ) {
var doc = cast(obj, DisplayObjectContainer);
for ( i in 0...doc.numChildren ) {
var child = doc.getChildAt(i);
if ( child != null ) fixFonts(child);
}
} else if ( Std.is(obj, TextField) ) {
var tf = cast(obj, TextField);
var fmt = tf.defaultTextFormat;
fmt.font = Assets.getFont("data/ProximaNova-Bold.otf").fontName;
tf.defaultTextFormat = fmt;
}
}