Skip to main content
Frédéric C.
Inspiring
November 25, 2017
Question

Italic and Bold fonts don't work if loaded dynamically

  • November 25, 2017
  • 1 reply
  • 890 views

Hi,

Until now, I was using embedded fonts, and sucessfully used the <b> and <i> html tags. Indeed, while embedding the fonts, I was able to set the font style, while still using the same font name. Like this:

[Embed(source="../EmbeddedAssets/BKANT.ttf", fontName="Book Antiqua", mimeType="application/x-font-truetype", embedAsCFF="false")]

public var Font1:Class;

     

[Embed(source="../EmbeddedAssets/ANTQUAB.ttf", fontName="Book Antiqua", fontWeight = "bold", mimeType="application/x-font-truetype", embedAsCFF="false")]

public var Font2:Class;

     

[Embed(source="../EmbeddedAssets/ANTQUABI.ttf", fontName="Book Antiqua", fontStyle = "italic", mimeType="application/x-font-truetype", embedAsCFF="false")]

public var Font3:Class;

But now I need to load those fonts dynamically instead. The fonts are embedded in a SWF file. I can get their class and register them successfully, but when I enumerate them, I get:

Book Antiqua

Book Antiqua Bold

Book Antiqua Italic

As you can see, when loaded dynamically, each font has its own unique name, so the regular <b> or <i> html tags don't work any longer. I could specify the exact font face in the html code, like "<font face='Book Antiqua Bold'>" (and it works), but I'd rather use the standard <i> or <b> tags for versatilty. Is there a way to fix this and be able to use those tags with a dynamically loaded font?

Thank you!

This topic has been closed for replies.

1 reply

Inspiring
November 27, 2017

Which platform are you talking about? Used <b> and <i> with what kind of class? You are leaving out all the information needed to help you.

Frédéric C.
Inspiring
November 27, 2017

Hmm, indeed, I forgot some important elements, sorry.

What I mean is that I display an HTML text using a TextField. If all the font variants (regular, bold and italic) are imbedded via code, like described in my first post, <b> and <i> html tags work correctly in the TextField. But if, instead of embedding the fonts, I load an external SWF file containing them, then RegisterFont() those font classes, the Italic and Bold variants have their distinctive names, and the <i> and <b> tags don't work any longer (only the standard font is found by AIR and used).

If think it is due to the fact that in the embed code solution, you can specify the same font name for all variants. On the other hand, when you load the fonts from an external SWF, each variant gets a different name, and AIR can't know they belong to the same font family.

AIR versions 27 and 28 beta do the same thing.

I hope it is clearer now. Thanks!

prakasku
Adobe Employee
Adobe Employee
December 1, 2017

Hi,

Could you please help us with a sample application with which we can reproduce this issue at our end.

You can email me directly at prakaskuATadobeDOTcom

Thanks

Prakash Kumar

Adobe AIR Team