Loading Fonts at Runtime : Font : TextField Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » TextField » Font »

 

Loading Fonts at Runtime


 
package {
  import flash.display.*;
  import flash.text.*;

  // Embed fonts for use by any .swf file that loads this file
  public class Main extends Sprite {
    [Embed(source="c:/windows/fonts/verdana.ttf",
           fontFamily="Verdana")]
    private var verdana:Class;

    [Embed(source="c:/windows/fonts/verdanab.ttf",
           fontFamily="Verdana",
           fontWeight="bold")]
    private var verdanaBold:Class;

    // Constructor
    public function Main() {
      // Register this class's embedded fonts in the global font list
      Font.registerFont(verdana);
      Font.registerFont(verdanaBold);
    }
  }
}
  class Fonts extends flash.display.Sprite {
    [Embed(source="c:/windows/fonts/verdana.ttf",
           fontFamily="Verdana")]
    private var verdana:Class;

    [Embed(source="c:/windows/fonts/verdanab.ttf",
           fontFamily="Verdana",
           fontWeight="bold")]
    private var verdanaBold:Class;
  }

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo TextField
» Font