Search code examples
flashactionscript-3textfontsantialiasing

Problem embedding font and displaying it correctly in Flash


I'm looking for the right textfield parameters or work-around for my latest problem here dealing with Flash fonts & text fields.

I have a textFormat and textField generation some text using the Font: Franklin Gothic Book point size 8. Currently this is how the font will look when I run the movie:

alt text
(source: flickr.com)

The bottom ®MYLOGO is a jpg from Photoshop, clean and how it should look. Next up is the font directly typed on the stage in Flash, and the very top ®MYLOGO is generated from my code.

What parameters am I missing to make the code generated copy look as close as possible to the Jpeg?

My Code below:

var tsFont = new TextFormat();
    tsFont.font = FranklinGothic;
    tsFont.size = 8;
    tsFont.color = 0xFFFFFF;
    tsFont.align = TextFormatAlign.LEFT;

var tsLogo:TextField = new TextField();
    tsLogo.defaultTextFormat = tsFont;
    tsLogo.selectable = false;
    tsLogo.mouseEnabled = false;
    tsLogo.x = 18;
    tsLogo.y = 98;
    tsLogo.width = 64;
    tsLogo.height = 16;
    tsLogo.text = "®MYLOGO";

    addChild(tsLogo);

You guys may remember this code from my last question X_x


FIXED WORKING CORE: thx to Andy Li

var tsFont = new TextFormat();
    tsFont.font = (new FranklinGothic() as Font).fontName;
    tsFont.size = 8;
    tsFont.color = 0xFFFFFF;
    tsFont.align = TextFormatAlign.LEFT;

var tsLogo:TextField = new TextField();
    tsLogo.selectable        = false;
    tsLogo.mouseEnabled      = false;
    tsLogo.embedFonts        = true;
    tsLogo.antiAliasType     = flash.text.AntiAliasType.NORMAL;
    tsLogo.gridFitType       = "pixel";
    tsLogo.sharpness         = 400
    tsLogo.x                 = 6;
    tsLogo.y                 = 5;
    tsLogo.width             = 600;
    tsLogo.height            = 40;
    tsLogo.text              = "®MYLOGO";
    tsLogo.setTextFormat(tsFont)

Graphic Examples:

NORMAL

alt text

ADVANCED

alt text


Solution

  • Controlling text rendering in Flash is painful sometime...

    You need to play around several properties: antiAliasType, gridFitType, sharpness, thickness of the TextField. Try Adobe's example. Or a even more detailed tutorial.