[Embed(source='/assets/calibri.ttf', fontName="
Calibri",
// TextFormat object
mimeType="application/x-font-truetype")]
private static var _calibri:String;
var format :TextFormat = new TextFormat();
format.font = "Calibri"; // Here is where the magic happens
format.color = 0xffffff;
format.size = 12;
// TextField object
var txt :TextField = new TextField();
txt.embedFonts = true;
txt.antiAliasType = flash.text.AntiAliasType.ADVANCED;
txt.defaultTextFormat = format;
txt.text = "Testing my embedded Calibri font";
addChild(txt);
Basically, we need to understand a couple things about the nature of
the embedded font in Actionscript. First, it must be assigned to a
String in order to store all the character references. Next, you will
quickly find that creating and implementing a TextFormat object to
attach the font and styles to the different places in which it will be
used is ideal. Finally, keep in mind that attaching several fonts to a
single application can significantly increase the file size, so try to
consolidate and style for variety as much as possible instead of
selecting a boat load of different font faces.
Saturday, May 15, 2010
Embedding Fonts into Actionscript Only Project (AS3)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment