Posted By

Wiederkehr on 03/21/09


Tagged

textmate embed as3 embedding embedFonts


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

loric
tspitzr


Text Embedding in AS3


 / Published in: Other
 

  1. package {
  2. //--------------------------------------
  3. // IMPORT
  4. //--------------------------------------
  5. import flash.display.*;
  6. import flash.text.*;
  7.  
  8. public class embedTest extends Sprite {
  9.  
  10. [Embed(
  11. source='/fonts/DINOT-Regular.otf',
  12. fontName="DINOT-Regular",
  13. mimeType="application/x-font-truetype"
  14. )]
  15. private var pFont:Class;
  16.  
  17. /**
  18. * @Constructor
  19. */
  20. public function untitled():void{
  21. // DEFINITIONS
  22. //--------------------------------------
  23. Font.registerFont(pFont);
  24. }
  25. private function createLink() : void {
  26. tf = new TextField();
  27. tf.text = 'foo';
  28. formatText(tf, T_COLOR, 12, true);
  29. tf.embedFonts = true;
  30. this.addChild(tf);
  31. }
  32. private function formatText(_tf:TextField, _color:Number, _size:Number, _bold:Boolean = false) : void {
  33. var tFormat:TextFormat = new TextFormat();
  34. tFormat.font = 'DINOT-Regular';
  35. tFormat.color = _color;
  36. tFormat.size = _size;
  37. tFormat.bold = _bold;
  38. _tf.setTextFormat(tFormat);
  39. }
  40. } // END embedTest Class
  41. } // END package

Report this snippet  

You need to login to post a comment.