Setting font on text field inside swf

I have a little bit of a strange bug that I was hoping someone could make sense of. I’ve simplified it down to the following.

I have a swf (built with Animate CC), that has one MovieClip with a named textfield inside it. I embed the swf from my project.xml like this:

<library path="assets/assets.swf" type="swflite" generate="true" preload="true" />

The MovieClip has been set to “Export for ActionScript” and is given the class “ClipFromSWF”.

The TextField’s font is set to “Segoe UI” (But I will change the font though code anyway), and is called “tfield”.

I also have a font in my assets folder.

Then I have the following haxe code:

var body:String = 'This should really work for both text fields.';
var format:TextFormat = new TextFormat(Assets.getFont("fonts/KievitOT-Book.otf").fontName);

// Create a text field from scratch and set the font. It works!
var workingTf = new TextField();
addChild(workingTf);
workingTf.defaultTextFormat = format;
workingTf.embedFonts = true;
workingTf.text = body;

// Use the text field from the swf, and use the same text format. Not working!
var fromSwfMc = new ClipFromSWF();
fromSwfMc.y = 50;
addChild(fromSwfMc);
fromSwfMc.tfield.defaultTextFormat = format;  // Delete to see text
fromSwfMc.tfield.embedFonts = true;
fromSwfMc.tfield.text = body;

The example should show two text fields, but the second one (from the swf) does not display. If the line setting the defaultTextFormat is removed, then the text will display, but obviously it will not have the font from the new TextFormat.

Has anyone ran into this before? This is how I would have done it with AS3, so not sure what is going wrong.

BTW, I am targeting Flash for now.

Could you try a non-Flash target?

Targeting Flash, you probably need to set the font to embed the glyphs you need in Adobe Animate.

I have the same problem right now. I’ve asked about that Joshua one week ago. I tried everything but it doesn’t work for flash but it does work fine for HTML5 and CPP. Currently what i’ve done for flash is to put a textfield on the stage of embedded SWF file will all characters i need for the font i want to load. ¯\_(ツ)_/¯