O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fonts and Text Rendering

By default, Flash Player displays text using device fonts. Device fonts are fonts that are installed on the end user's system. When Flash Player displays text with a device font, it completely delegates the text-rendering process to the local environment (i.e., operating system). For example, consider the following simple HelloWorld application, which creates a text field formatted with the font Arial:

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

  public class HelloWorld extends Sprite {
    public function HelloWorld () {
      var fontFormat:TextFormat = new TextFormat();
      fontFormat.font = "Arial";

      var t:TextField = new TextField();
      t.text = "Hello world";
      t.setTextFormat(fontFormat);

      addChild(t);
    }
  }
}

When that code runs, Flash Player adds t to the display list, and prepares to update the screen. To display the characters "Hello world," Flash Player passes the string "Hello world" to the operating system's text renderer, and asks it to render those characters using the system font "Arial." The operating system then renders the characters directly to Flash Player's frame buffer. For example, on Microsoft Windows XP, the string "Hello world" is rendered using Microsoft's ClearType renderer.

If the preceding HelloWorld application runs on two different computers with two different operating systems, those computers may have two different native text renderers, and perhaps even two different versions of the font Arial. Hence, even when the required font is available, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required