Embeding fonts in as3


/ Published in: ActionScript 3
Save to your folder(s)

Embeding fonts in as3


Copy this code and paste it in your HTML
  1. package DatePercent.Samples
  2. {
  3. import flash.display.Sprite;
  4. import flash.text.TextField;
  5. import flash.text.TextFormat;
  6.  
  7. public class EmbededFonts extends Sprite
  8. {
  9. // embed the font.ttf file from the same folder as this swf
  10. [Embed(source="assets/FontSample.ttf",
  11. fontName = "myFont",
  12. mimeType = "application/x-font",
  13. fontWeight="normal",
  14. fontStyle="normal",
  15. advancedAntiAliasing="true",
  16. embedAsCFF="false")]
  17. private var fontFontSample:Class;
  18.  
  19.  
  20. public function EmbededFonts()
  21. {
  22. super();
  23.  
  24. var textFormat:TextFormat = new TextFormat();
  25. textFormat.font = "myFont";
  26. textFormat.bold = true;
  27. textFormat.letterSpacing = 10;
  28.  
  29. var textField:TextField = new TextField();
  30. textField.width = 300;
  31. textField.embedFonts = true
  32. textField.text = "Use embeded font";
  33. textField.textColor = 0x0000ff;
  34. textField.setTextFormat(textFormat);
  35.  
  36. this.addChild(textField);
  37. }
  38. }
  39. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.