How to use embed font in your ActionScript Flash application
To use embed font in your Flash application you need to do next:
1. Declare font and show TTF font location
[Embed(source="../../../../../../assets/fonts/MyFont.ttf", fontFamily="MyFont",fontWeight="normal", mimeType="application/x-font-truetype", embedAsCFF="false")]
private var MyFont:Class;
take care about embedAsCFF=”false”. This is important part of code.
2. Create TextFormat object and use embed font it in.
var textFormat:TextFormat = new TextFormat();
textFormat.font = "MyFont"; // Here is font attached
textFormat.italic = false;
textFormat.color = 0x000000;
textFormat.size = 12;
textFormat.bold = false;
3. Create TextField object and start using TextFormat object BEFORE setting any text for TextField
var textField:TextField = new TextField();
textField.embedFonts = true;
textField.antiAliasType=AntiAliasType.ADVANCED;
textField.defaultTextFormat = textFormat;
textField.selectable = false;
textField.autoSize = TextFieldAutoSize.LEFT;
textField.text = "Here is text with embed font"
That’s all!
Please tell me if you know better solution, thanks.
1 Comment
target coupon · 19 January, 2014 at 21:30
Everything is very open with a really clear description of the issues.
It was truly informative. Your site is useful. Many thanks for sharing!