Skip to main content
Inspiring
November 21, 2013
Question

Embedding Font in FB 4.7 AIR 3.9

  • November 21, 2013
  • 1 reply
  • 601 views

Hello,

Is there a different way to embed fonts with Air 3.9 or FB 4.7? I've recently upgrading and I am experience tempremental results with embedding fonts.

With FB 4.6 and Air 3.7 the following works fine -

[Embed(source="/assets/fonts/SEGOEUIL.TTF", fontName="Segoe UI Light", mimeType="application/x-font-truetype")]

                    public static var EverydayFont:Class;

                                        var textFormat:TextFormat = new TextFormat();

                                        var mainFont:Font = new EverydayFont();

                                        textFormat.font = mainFont.fontName;

                              var textfield:TextField = new TextField();

                              textfield.mouseEnabled = false;

                              textfield.selectable = false;

  textfield.defaultTextFormat = textFormat;

                              textfield.multiline = false;

                              textfield.border = true;

                              textfield.embedFonts = embedFont;

                              textfield.width = width;

  textfield.antiAliasType = antiAliasStyle;

                              textfield.htmlText = label;

However now with the latest versions the text box is just blank..??

This topic has been closed for replies.

1 reply

Inspiring
November 21, 2013

Have you tried using textfield.setTextFormat(textFormat)?

FunkyJunkAuthor
Inspiring
November 22, 2013

Thanks for your reply. I have tried that and unfortunetly it makes no difference...I've had to revert back to Air 3.7 and FB 4.6

Inspiring
November 22, 2013

Ok, I'm gonna give you the code that worked for me when I was working on a project back than, cause I also had a simillar, if not the same (can't remember), problem.

So here it goes:

[Embed(source="SuchFont.ttf", fontName="SuchFont", mimeType="application/x-font", embedAsCFF="true")]

public static var SuchFont:Class;

var font:Font = new SuchFont;

var format:TextFormat = new TextFormat(font.fontName, 20, 0xFFFFFF, true, null, null, null, null, TextAlign.LEFT);

awesomeText = new TextField;

awesomeText.defaultTextFormat = format;

awesomeText.embedFonts = true;

awesomeText.width = 158;

awesomeText.height = 56;

awesomeText.x = 106;

awesomeText.y = 420;

I think the trick is using embedAsCFF="true", but the issue here could be that you're using htmlText, have you tried with text?