【问题标题】:Embedded font makes TextField invisible嵌入字体使 TextField 不可见
【发布时间】:2013-03-05 13:15:55
【问题描述】:

我不明白为什么当我使用嵌入字体时我的文本字段不显示:

[Embed(source="../resources/fonts/h55.ttf", fontName="h55", mimeType="application/x-font", unicodeRange =
'U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
public static const h55embed:Class;

public function animate():void
{
        var myformat:TextFormat = new TextFormat('h55embed',24);
        myformat.color = 0xffffff;
        myformat.align="center";


        var text:TextField = new TextField();

        text.embedFonts = true; // very important to set
        text.text = 'my text';
        text.setTextFormat(myformat);

        text.autoSize = TextFieldAutoSize.LEFT;
        text.x = (this.stage.width/2) - (text.width/2);
        text.y = this.stage.height - text.height - 20;



        this.stage.addChild(text);


}

这段代码有什么问题?

【问题讨论】:

    标签: actionscript-3 flash actionscript fonts embed


    【解决方案1】:

    创建TextFormat时不需要使用相同的fontName吗?

    var myformat:TextFormat = new TextFormat('h55',24);
    

    也可以尝试在您的嵌入元标记中使用 embedAsCFF

    这适用于我的应用程序:

    [Embed(source = "../../../../Knights Quest.ttf", fontName="Knights", mimeType = 'application/x-font', embedAsCFF = "false")]
    public static const KNIGHTS:Class;
    

    【讨论】:

    • 我使用 'h55embed' 因为我声明了一个常量 'public static const h55embed:Class;'引用嵌入的字体。即便如此,我尝试使用“h55”和“h55embed”声明 TextFormat,但都不会导致我的文本出现。
    猜你喜欢
    • 1970-01-01
    • 2013-07-17
    • 2012-07-31
    • 2012-11-09
    • 2016-12-01
    • 1970-01-01
    • 2015-04-13
    • 2014-06-28
    • 2014-05-23
    相关资源
    最近更新 更多