ActionScript & Flash

Embed fonts at compile time

Embedded fonts make text appearance independent of the fonts installed on a player’s computer. The font must be included in the build, and the text field must be configured to use embedded glyphs. Selecting a font name alone does not embed its outlines.

Choose only the characters the interface needs when build size matters. A score display can use digits and punctuation; a dialogue system may need a much wider character set. Test accented characters, symbols and localized strings rather than only the English alphabet.

Create a TextFormat with the embedded font’s registered family name, assign it to the field and enable embedFonts. For readable HUD text, check alignment, line height and contrast at the actual display size.

Try the idea

import flash.text.Font;

[Embed(source="../assets/GameFont.ttf",
  fontName="GameFont", embedAsCFF="false")]
private var GameFont:Class;

Font.registerFont(GameFont);
field.embedFonts = true;
field.defaultTextFormat = new TextFormat("GameFont", 20, 0xffffff);
field.text = "SCORE 1200";