我不明白为什么在使用嵌入字体时我的文本字段不显示:
[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);
}
此代码有什么问题?
答案 0 :(得分: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;