actionscript 3 as3 flash AIR font embed external

196 Views Asked by At
[Embed(source='/assets/calibri.ttf', fontName="Font", mimeType="application/x-font-truetype" embedAsCFF="false")]
private static var calibri:String;

I Looking from tutorial and get code like above and look like it's must on Class? can I use it without class? or maybe an example for font loaded class please?

1

There are 1 best solutions below

2
On

Use the embed param fontFamily. This string you can use to set the font.

[Embed(source='/assets/calibri.ttf', fontFamily="calibri", mimeType="application/x-font-truetype" embedAsCFF="false")]
var CalibriFont:Class;

var tf:TextField = new TextField();    
tf.embedFonts = true;
addChild(tf);

var tff:TextFormat = new TextFormat();           
tff.font = "calibri";

tf.defaultTextFormat = tff;
tf.htmlText = "HELLO";