/ Published in: ActionScript 3

Embeding fonts in as3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package DatePercent.Samples { import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFormat; public class EmbededFonts extends Sprite { // embed the font.ttf file from the same folder as this swf [Embed(source="assets/FontSample.ttf", fontName = "myFont", mimeType = "application/x-font", fontWeight="normal", fontStyle="normal", advancedAntiAliasing="true", embedAsCFF="false")] private var fontFontSample:Class; public function EmbededFonts() { super(); var textFormat:TextFormat = new TextFormat(); textFormat.font = "myFont"; textFormat.bold = true; textFormat.letterSpacing = 10; var textField:TextField = new TextField(); textField.width = 300; textField.embedFonts = true textField.text = "Use embeded font"; textField.textColor = 0x0000ff; textField.setTextFormat(textFormat); this.addChild(textField); } } }
Comments
