Skip to main content
Inspiring
Nov 21, 2013 2:12 PM UTC
Question

Embedding Font in FB 4.7 AIR 3.9

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 is closed to new replies. Start a new post to keep the conversation going.

3 replies

Inspiring
Nov 21, 2013 10:18 PM UTC

Have you tried using textfield.setTextFormat(textFormat)?

Translate
FunkyJunkAuthor
Inspiring
Nov 22, 2013 11:15 AM UTC

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

Translate
Inspiring
Nov 22, 2013 2:26 PM UTC

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?

Translate