I'm embedding a font in AS3 with the following command:

[Embed(source="../font/font1.swf", fontName = "FontName1", fontWeight = "bold" )]
private var myEmbeddedFont:Class;

var _tf: TextFormat;

_tf = new TextFormat();
_tf.color = 0x000000;
_tf.size = 18;
_tf.font = "FontName1";

Now I would like to embedd a second font which is the same font but not bold. My problem now is: Both vonts (the bold one and the non-bold) have the same name.

What can I do to use both fonts? In the embedding-command fontName="" must be the "real" name of the font. Is there some Kind of an alias I can set for the font-name?

有帮助吗?

解决方案

you want to use fontFamily and not fontName. Also, why is your font an .swf? here's what I use :

    [Embed(source="../font/font1.ttf", embedAsCFF="false", fontFamily="FontName1")]
    private static const Font:Class;
    [Embed(source="../font/font1_Bd.ttf", embedAsCFF="false", fontFamily="FontName1", fontWeight="bold")]
    private static const FontBold:Class;

With that, AS3 should be able to display both normal anf bold text with your font.

其他提示

There is nothing like you have to set the "Real" name of the font to set, you can use alias for your fonts.

Like : for ARIEL(normal) : font Name : Ariel

for ARIEL(bold) : font Name : Ariel_Bold

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top