Skip to main content
Camussx
Inspiring
September 30, 2009
Question

Embed font with smoothing in TextLayout

  • September 30, 2009
  • 2 replies
  • 2059 views

Hi..

I need your help again...

I try to embed a font into my TextFlow, I try by diferent ways and this works for me:

In flex I build a swc:

package
{
    public class FontsFontsFonts
    {
            [Embed(source="C:/Windows/Fonts/ctmgoodgirl.ttf", fontFamily="GoodGirl", embedAsCFF="true")]
            public const GoodGirlFont:Class;


    }
}

then, in a class of my Flash Project I put this:

private function textConfiguration():Configuration
        {
           
            var myFont:Font = new FontsFontsFonts_GoodGirlFont();
           
            var config:Configuration = new Configuration();
           
            var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
            textLayoutFormat.fontFamily = fmt.font;
            textLayoutFormat.color = 0x000000;
            textLayoutFormat.fontSize = 14;
            textLayoutFormat.kerning = Kerning.ON;
            textLayoutFormat.fontStyle = FontPosture.NORMAL;
            textLayoutFormat.textAlign = TextAlign.LEFT;
           
            config.textFlowInitialFormat = textLayoutFormat;
           
            return config
        }

And all works fine, my textFlow can use GoodGirl font, but exist a problem, this font is showed without smoothness

How can I enabled smoothness in TLF?

This topic has been closed for replies.

2 replies

a_circulo
Participating Frequently
October 14, 2009

Hi Camuss

I think your problem is very simple, your font may just not be registered in the Font list.

To check which font and style is embedded use this:

var myEmbeddedFonts:Array = Font.enumerateFonts(false);

var f:Font;

for (i=0; i<myEmbeddedFonts.length; i++){

     f = myEmbeddedFonts;

     trace (i+"---"+f.fontName+"---normal/normal = "+FontDescription.isFontCompatible(f.fontName, "normal", "normal"));

     trace (i+"---"+f.fontName+"---normal/italic = "+FontDescription.isFontCompatible(f.fontName, "normal", "italic"));

     trace (i+"---"+f.fontName+"---bold/normal = "+FontDescription.isFontCompatible(f.fontName, "bold", "normal"));

     trace (i+"---"+f.fontName+"---bold/italic = "+FontDescription.isFontCompatible(f.fontName, "bold", "italic"));

}

If your font is not embedded register it with:

Font.registerFont(yourFontConstName);

But just in case here is my full code for a project I'm doing as an example:  (not sure, but you problably need the mimeType="application/x-font")

[Embed(source="/Users/andrefelipe/FontExplorer X/Font Library/M/MetaPro-Norm/MetaPro-Norm.otf",

               fontFamily="Meta Pro",

               fontWeight="Normal",

               mimeType="application/x-font",

               embedAsCFF="true",

               unicodeRange="U+0020-U+0040,U+005B-U+007E,U+00A1-U+00BF,U+00E0-U+00FF,U+2013-U+2044,U+FB00-U+FB04")]

private const MetaPro_Normal:Class;

//Font.registerFont(MetaPro_Normal);   ** please note if you happen to embed the font in the same class you don't need to register it, its automatic. And if you do register it gets duplicated. (that's why my register is commented)

If your font is embedded maybe try to use the fontFamily real name as:  textLayoutFormat.fontFamily = "GoodGirl";

then make sure you set your fontLookup as:  textLayoutFormat.fontLookup = FontLookup.EMBEDDED_CFF;

Adobe Employee
October 2, 2009

Are you setting the TextLayoutFormat's fontLookup to EMBEDDED_CFF?

- robin

Camussx
CamussxAuthor
Inspiring
October 2, 2009

hi Robin...

In fact, I put in my ".as" file:

textLayoutFormat.fontLookup = FontLookup.EMBEDDED_CFF;
textLayoutFormat.renderingMode = RenderingMode.CFF;

But, this is something curious, if I put this lines, my text appears like Arial font, if I delete this lines, then appears GoodGirl font but without smoothing...

I don't know what is my mistake.

This is my code:

private function textConfiguration():Configuration
        {
           
            var myFont:Font = new FontsFontsFonts_GoodGirlFont();
                              
            var config:Configuration = new Configuration();
               
            var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
            textLayoutFormat.color = 0x000000;
            textLayoutFormat.fontLookup = FontLookup.EMBEDDED_CFF;
            textLayoutFormat.renderingMode = RenderingMode.CFF;
            textLayoutFormat.fontFamily = myFont.fontName;
            textLayoutFormat.fontSize = 14;
            textLayoutFormat.kerning = Kerning.ON;
            textLayoutFormat.fontStyle = FontPosture.NORMAL;
            textLayoutFormat.textAlign = TextAlign.LEFT;
           
            config.textFlowInitialFormat = textLayoutFormat;
           
            return config
        }

And, when I create my textFlow I use this:

myTextFlow=new TextFlow(textConfiguration());

Can you see anything?

Camussx
CamussxAuthor
Inspiring
October 5, 2009

Any idea, please?