Skip to main content
Known Participant
March 13, 2021
Question

Apply an embedded font to TextField created via script?

  • March 13, 2021
  • 2 replies
  • 208 views

I have a movie that uses imported fonts:

 

 

 

In want to create TextFields via AS3 and use this improted font on it:

var tf:TextField = new TextField();

var format: TextFormat = new TextFormat();
format.font = "$ColdDefaultFont";
tf.text = "Some text";
tf.setTextFormat(format);
			
addChild(tf)

However the font is never displayed (just shows as squares). If i manually add a TextField to the stage and set it's character font to use this embedded font it works fine.

 

So what am I doing wrong here?

 

Thanks

    This topic has been closed for replies.

    2 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    March 14, 2021

    Hi.

     

    In my experience I learned that it's easier to place a text field instance inside of a Movie Clip or Sprite container and then add this container to the display list and let Animate handle the font embedding.

     

    If you are not going to add dozens or hundreds of texts, I think the impact on the performance will be irrelevant.

     

    Please tell us what you think.

     

    Regards,

    JC

    Known Participant
    March 14, 2021

    Thanks for the response. Yes, this is actually exactly what I'm currently doing. It just seemed like a bit of a hack to me, however it does appear to work fine.

     

    Cheers

    Known Participant
    March 13, 2021

    I guess we can't edit previous posts on this forum (to correct typos, etc)???