Thursday, August 14, 2008

Embedding Fonts Bug

When embedding fonts do not name fontName or fontFamily the filename or the text will not appear if you set TextField::embedFonts to true. The filename is probably the device font name which can only be used if TextField::embedFonts is false.

All variations produce the same results:
[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontFamily="Arial")]

[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontName="Arial")]

[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontFamily="Arial", mimeType="application/x-font-truetype")]

[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontName="Arial", mimeType="application/x-font-truetype")]

TextField::text
TextField::htmlText

Test:
[Embed(source="../assets/ARIAL.TTF", fontName="Arial")]
private const EMBED_ARIAL:Class;

var tf:TextField = new TextField();
var format:TextFormat = new TextFormat("Arial");
addChild(tf);

tf.embedFonts = true;
tf.defaultTextFormat = format;
tf.text = "Test";

OR

tf.embedFonts = true;
tf.text = "Test";
tf.setTextFormat(format);

You will see no text.

No comments: