package { import flash.display.MovieClip; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import org.libspark.font.AnotherFontLoader; import org.libspark.font.data.RawFont; import org.libspark.font.render.GlyphShape; public class RuntimeFontParser extends MovieClip { private var _loader:AnotherFontLoader private var _typeface:RawFont; private var _myGlyph:Sprite; private var _glyph_ar:Array; private var _glyph:GlyphShape; /** * example usage of some classes within the RuntimeFontParser packages */ public function RuntimeFontParser() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; _loader = new AnotherFontLoader( "AppleSimple.ttf" ); _loader.addEventListener( Event.COMPLETE, drawGlyphs ); } private function drawGlyphs(evt:Event):void { _typeface = _loader.font; /* _typeface.effects.lineStyle( 15, 0xff0000, 1, true, "normal", null, null, 1 ); _typeface.effects.beginFill( 0xffffff, 1 ); _myGlyph = _typeface.effects.drawGlyph( Math.random()*200 ); _myGlyph.x = 100; _myGlyph.y = 50; _myGlyph.scaleX = _myGlyph.scaleY = .2; addChild(_myGlyph); */ _glyphs = []; // try just drawing this shape drawLetter( 50, 100, 100 ); drawLetter( 51, 200, 100 ); drawLetter( 52, 300, 100 ); drawLetter( 53, 400, 100 ); // drawLetter( 54, 500, 100 ); // drawLetter( 55, 600, 100 ); // drawLetter( 56, 700, 100 ); // drawLetter( 57, 800, 100 ); // drawLetter( 58, 900, 100 ); // } /** * draw a physical letter */ private function drawLetter( char:Number, x:Number, y:Number ):void { _glyph = new GlyphShape(); _glyph.data = _typeface; _glyph.drawPhysicalGlyph( char ); _glyph.x = x; _glyph.y = y; //_glyph.scaleX = _glyph.scaleY = .2; //_glyph.rotation = 180; //_glyph.x = 1000; //_glyph.y = 200; addChild(_glyph); _glyphs.push(_glyph); this.addEventListener(Event.ENTER_FRAME, spinGlyphs ); } private var _glyphs:Array; private function spinGlyphs(evt:Event):void { for(var i:int=0;i<_glyphs.length;i++) { GlyphShape(_glyphs[i]).rotationY += 3; } } } }