Leon Gaban
Leon Gaban

Reputation: 39018

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

Upvotes: 4

Views: 4014

Answers (3)

Andy Li
Andy Li

Reputation: 6034

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.

Upvotes: 2

resolveaswontfix
resolveaswontfix

Reputation: 1175

Yes make sure you check the Aliasing, but if that doesn't do it I would try calling:

tsLogo.setTextFormat(tsFont)

Right after you set the text. That function will apply the font to the text in the field.

Upvotes: 1

Riccardo Bartoli
Riccardo Bartoli

Reputation: 21

Try to add this code:

tsLogo.antiAliasType = flash.text.AntiAliasType.NORMAL;

or

tsLogo.antiAliasType = flash.text.AntiAliasType.ADVANCED;

Upvotes: 2

Related Questions