简体   繁体   English

具有动态文本字段的Flash自定义字体

[英]Flash Custom Font with Dynamic Text Field

I am creating a textfield using this code: 我正在使用以下代码创建文本字段:

window_title = p.createTextField("border"+diepixWindow.NextBorderDepth, p.getNextHighestDepth(), wx1+TITLE_OFFSETX, wy1+TITLE_OFFSETY, ww, 64); window_title = p.createTextField(“ border” + diepixWindow.NextBorderDepth,p.getNextHighestDepth(),wx1 + TITLE_OFFSETX,wy1 + TITLE_OFFSETY,ww,64);
var fformat:TextFormat = new TextFormat(); var fformat:TextFormat = new TextFormat();
fformat.font = "TF2 Build"; fformat.font =“ TF2 Build”;
fformat.size = 36; fformat.size = 36;
window_title.setTextFormat(fformat); window_title.setTextFormat(fformat);
window_title.setNewTextFormat(fformat); window_title.setNewTextFormat(fformat);

But the problem is, if the client doesn't have the "TF2 Build" font, the font will be Times New Roman. 但是问题是,如果客户端没有“ TF2 Build”字体,则该字体将为Times New Roman。
I would like to know to attach the font to the .swf file. 我想知道将字体附加到.swf文件。

This will fix it: 这将解决它:

window_title.embedFonts = true;

You also need to actually embed the font in the swf file, though. 不过,您实际上还需要将字体嵌入到swf文件中。 If you're using the Flash application, set the font in the properties window and then just check the embed box. 如果您使用的是Flash应用程序,请在属性窗口中设置字体,然后仅选中嵌入框。 If you're using mxmlc, you can embed the font with @Embed. 如果使用的是mxmlc,则可以使用@Embed嵌入字体。

See here: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/ 参见此处: http : //www.adobe.com/devnet/flash/quickstart/embedding_fonts/

You can use the Embed meta tag in plain AS3, too if you're targeting FP10+. 如果您要定位FP10 +,也可以在普通AS3中使用Embed元标记。 For example, in a class add: 例如,在一个类中添加:

[Embed(source="C:\WINDOWS\Fonts\myfontfile.ttf", fontFamily="myFont")]

Then... 然后...

TextField.embedFonts = true;
myTextFormat.font = "myFont";

Check here for a good example: http://marumushi.com/news/embedding-fonts-in-as3 Any way to avoid library font linkage voodoo is a good choice. 在此处查看一个很好的示例: http : //marumushi.com/news/embedding-fonts-in-as3避免库字体链接的任何方法voodoo是一个不错的选择。 Oh, and make sure your font file is an accepted font format. 哦,请确保您的字体文件是可接受的字体格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM