views:

885

answers:

2

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);
var fformat:TextFormat = new TextFormat();
fformat.font = "TF2 Build";
fformat.size = 36;
window_title.setTextFormat(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.
I would like to know to attach the font to the .swf file.

+1  A: 

This will fix it:

window_title.embedFonts = true;

You also need to actually embed the font in the swf file, though. If you're using the Flash application, set the font in the properties window and then just check the embed box. If you're using mxmlc, you can embed the font with @Embed.

See here: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/

It works! Thank you so much!
M28
+1  A: 

You can use the Embed meta tag in plain AS3, too if you're targeting FP10+. 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. Oh, and make sure your font file is an accepted font format.

borducks