tailedmouse
tailedmouse

Reputation: 365

How to Embed Fonts in Action script 3

I am trying to get a specific Font family into my application, but i am unsure on how to embed my fonts properly?

I did follow this tutorial

but I am getting error at this line:

[Embed(source="C:\\WINDOWS\\Fonts\\Bebas_Neue_Regular.OTF", fontFamily="Bebas_Neue")]

The error is :

Scene 1, Layer 'Code', Frame 3, Line 2  An Embed variable must not have an existing value.

This app is for Air Ios. What am I doing wrong?

Upvotes: 0

Views: 774

Answers (1)

Jason Sturges
Jason Sturges

Reputation: 15955

Programmatically in code, when linking to a font file or system font I follow the pattern:

/**
 * U+0020-U+002F,  Space + Punctuation [ !"#$%&'()*+,-./ ]
 * U+0030-U+0039,  Numbers [0..9]
 * U+003A-U+0040,  Special Chars [ :;<=>?@ ]
 * U+0041-U+005A,  Upper-Case [A..Z]
 * U+005B-U+0060,  Special Chars [ [\]^_` ]
 * U+0061-U+007A,  Lower-Case a-z
 * U+007B-U+007E,  Special Chars [ {|}~ ]
 * U+00A1-U+00A1,  Latin Character: ¡
 * U+00A3-U+00A3,  British Pound Symbol
 * U+00A9-U+00A9,  Copyright Symbol
 * U+00AE-U+00AE,  Registered Symbol
 * U+00B0-U+00B0,  Degrees Symbol
 * U+00BC-U+00BE,  Fractions Symbols
 * U+00BF-U+00BF,  Latin Character: ¿
 * U+00C0-U+00FF,  Latin Characters
 * U+2013-U+2014,  EN Dash, EM Dash
 * U+2018-U+2019,  Directional Single Quotes
 * U+201C-U+201D,  Directional Double Quotes
 * U+2022-U+2023,  Bullets
 * U+2120-U+2120,  SM
 * U+2122-U+2122   Trade mark (TM)
 */
[Embed(systemFont = "Arial", fontWeight = "Regular", fontName = "Arial", mimeType = "application/x-font", embedAsCFF = "false", unicodeRange = "U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+00A1-U+00A1,U+00A3-U+00A3,U+00A9-U+00A9,U+00AE-U+00AE,U+00B0-U+00B0,U+00BC-U+00BE,U+00BF-U+00BF,U+00C0-U+00FF,U+2013-U+2014,U+2018-U+2019,U+201C-U+201D,U+2022-U+2023,U+2120-U+2120,U+2122-U+2122")]
private static const ArialClass:Class;

Then, a TextFormat may be created as:

Font.registerFont(ArialClass);

var tf:TextFormat = new TextFormat();
tf.font = "Arial";
tf.bold = bold;
tf.size = size;
tf.color = color;
tf.align = TextFormatAlign.LEFT;

With Flash Pro, fonts can be dragged and dropped on the library, or right-click and select New Font...

new-font

Properties may be set from the Font Embedding window:

font-embedding

Flash Pro's GUI makes font embedding easy, and fonts can be published as a SWC for linkage to other projects outside of the Flash Pro authoring environment.

Upvotes: 2

Related Questions