other tags

ajax /  arcball /  AS3 /  attractors /  awards /  barcelona /  book /  brighton /  carnivore /  choroq /  clustering /  code /  color visualization /  conference /  conversation /  cover /  dojo /  email /  email visualization /  exhibit /  fitc /  flashcom server /  fluid dynamics /  fonts /  fotb /  gaming /  globe /  gps /  graph /  heteml /  information visualization /  ink /  inspiration /  instalation /  installation /  interaction design /  interview /  ivrea /  javascript /  life /  livesearch /  mediatemple /  mobile media /  moblog /  mysql /  network /  network activity /  network visualization /  news visualization /  pencil /  phidgets /  physical computing /  publication /  research /  school /  sketches /  social network /  space perception /  telepresence /  time visualization /  timeline /  tokyo /  treemap /  treemaps /  vector field /  visualization /  website /  work /  workshop / 

tags / fonts

October 29, 2005

Embedding fonts in AS3

I love this! ... library, be-gone!

package {
	
import flash.util.describeType;
import flash.display.MovieClip;
import flash.display.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
  
   public class Test extends MovieClip {
    
      // be sure this is pointing to a ttf font in your hardrive
      [Embed(source="C:\WINDOWS\Fonts\somefont.ttf", fontFamily="foo")] 
      public var bar:String;
      			
      public function Test() {
                	
          var format:TextFormat	      = new TextFormat();
          format.font		      = "foo";
          format.color                = 0xFFFFFF;
          format.size                 = 130;
						
          var label:TextField         = new TextField();
          label.embedFonts            = true;
          label.autoSize              = TextFieldAutoSize.LEFT;
          label.antiAliasType         = AntiAliasType.ADVANCED;
          label.defaultTextFormat     = format;
          label.text                  = "Hello World!";
          addChild(label);
       }
    }
}