Embedded Fonts Won't Appear

1.6k views Asked by At

I'm trying to embed a font in FlashDevelop. My folder structure is

FlashDevelop Folder Structure

My embed metadata is

[Embed(source = 'resources/04B08.TTF', fontName = '04b08')] public var _04b08:Class;

My code is

    public var titleFormat:TextFormat;
    public var titleText:TextField;

    private function init(e:Event = null):void 
    {
        // entry point
        titleText = new TextField();
        titleFormat = new TextFormat();
        titleFormat.font = "04b08";
        titleFormat.color = 0xFFFFFF;
        titleFormat.size = 72;

        //titleText.embedFonts = true;
        titleText.autoSize = TextFieldAutoSize.LEFT;
        titleText.antiAliasType = AntiAliasType.NORMAL;
        titleText.defaultTextFormat = titleFormat;
        titleText.text = "TEST";

        titleText.x = 10;
        titleText.y = 10;

        addChild(titleText);
    }

If I use this, I get

TEST

But I uncomment the titleText.embedFonts = true; line, I get

enter image description here

This is the method that all of the guides I can find use. What should I do to get it to work?

1

There are 1 answers

1
Miha On BEST ANSWER

You should try a method registerFont() before using it:

import flash.text.Font;
Font.registerFont(_04b08);

Also, try other metadata parameters like embedAsCFF='false' and fontFamily='fontName', and then use titleFormat.font = "fontName";.

For more reliably testing don't have the font installed in your OS.