Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be a tricky thing to get just right. I had to fight with this about 10 days ago and only though trying several combinations of names and parameters to the embed could I get it to work.</p> <p>I read blog reports that had anecdotal advice that you had to include the fontStyle if you need bold or whatnot. Here is the incantation that worked for me:</p> <pre><code>[Embed(source="assets/HelveticaBold.ttf", fontName="HelveticaBold", fontWeight="bold", 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')] private static var HelveticaBold:Class; </code></pre> <p>I don't think <code>unicodeRange</code> is strictly necessary but I didn't need the entire font and the above gives you the equivalent of "Basic Latin" in the IDE.</p> <p>When I want to use the font I do so like this:</p> <pre><code> var titleFormat:TextFormat = new TextFormat(); titleFormat.font = "HelveticaBold"; titleFormat.bold = true; titleFormat.color = 0x0; titleFormat.size = 18; var errorTitle:TextField = new TextField(); addChild(errorTitle); errorTitle.embedFonts = true; errorTitle.autoSize = TextFieldAutoSize.LEFT; errorTitle.antiAliasType = AntiAliasType.ADVANCED; errorTitle.x = 5; errorTitle.y = 5; errorTitle.defaultTextFormat = titleFormat; </code></pre> <p>I can't believe I missed the most important piece. The above didn't work until I forced the mxmlc compiler to use a custom font manager.</p> <p>Add the following as a compiler option:</p> <pre><code>-managers=flash.fonts.AFEFontManager </code></pre> <p>There is an Adobe technote on <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_10.html" rel="nofollow noreferrer">troubleshooting fonts in Flex 3</a> that lists the available font managers. Try them until you find one that works.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload