View Sidebar
Font Embedding in AS3 on Runtime

Font Embedding in AS3 on Runtime

September 26, 2010 23:20

I was experimenting on fonts and found out that in Flex you can embed fonts at compile time using the [Embed] metadata tag in your Actionscript. And fonts can be in an external folder from where they will be embedded.

[Embed(source=”Fonts/Walkway Black.TTF”, fontFamily=”Walkway Black”, fontStyle = “Regular”, mimeType=”application/x-font-truetype”)]

public var WalkwayBlack_Font:Class;

The second line is used to register the embedded font class.

var format:TextFormat = new TextFormat();
format.font = “Walkway Black”;
textfieldf.defaultTextFormat = format;

Then you can directly use the font name in the font poperty of  TextFormat and use the format as default text format.

source  files

If you like the article please share

Comments are closed