Skip to main content
Known Participant
May 10, 2010
Question

textLayoutFormat.fontLookup =FontLookup.EMBEDDED_CFF breaks font?

  • May 10, 2010
  • 2 replies
  • 3487 views

Hi,

My Flash Player version:   10,1,50,433   (Debug version)

My Flex SDK: 4.5 downloaded from the trunk.  SVN Status shows no updates required.

Font embedding is not working.   I read some other threads on this, but  it's pretty confusing stuff. Perhaps I just need confirmation if there is a bug in Flex 4.5 and if it's not currently possible to embed fonts in Flex (if that is indeed the case).

Here is some my code:

    [Embed(source="/assets/MyriadPro-Bold.otf", fontFamily="Myriad Pro Bold",  embedAsCFF="true")]

    private var  _MyriadProBoldSubset:Class;

public function FontTest()

{

Font.registerFont(_MyriadProBoldSubset);

        textLayoutFormat = new TextLayoutFormat();

        textLayoutFormat.color = 0xFFFFFF;

        textLayoutFormat.renderingMode = RenderingMode.CFF;

        // Turning this off makes the text bold, turning it off makes non-bold. This indicates that font embedding is not working, so it falls back to some other font.

        textLayoutFormat.fontLookup = FontLookup.EMBEDDED_CFF;  

        textLayoutFormat.textAlign = "center";

    textLayoutFormat.fontFamily = "Myriad Pro Bold";

textLayoutFormat.fontSize = 12;

textLayoutFormat.fontWeight = FontWeight.BOLD;

   var fonts = Font.enumerateFonts();

   var fooFont:Font = fonts[0];

//  Traces out "Myriad Pro Bold :: true" .   This seems to confirm that the font is embedded and has the glyph I need for my "CC" button

   trace(fooFont.fontName + " :: " + fooFont.hasGlyphs("C"));

    textFlow= new TextFlow();

        paragraph = new ParagraphElement();

        span = new SpanElement;

        paragraph.addChild(span);

        textFlow.addChild(paragraph)

        var controller:ContainerController = new ContainerController(cc_btn, 18, 17);

        textFlow.flowComposer.addController(controller);

        textFlow.hostFormat = textLayoutFormat; 

        span.text = "CC";

        textFlow.flowComposer.updateAllControllers();

This topic has been closed for replies.

2 replies

p0ndusAuthor
Known Participant
May 11, 2010

I found the problem.  I had this setting in my project, which is sometimes neccessary when embedding with "Classic" text

-managers=flash.fonts.AFEFontManager

Adobe Employee
May 10, 2010

Because you are embedding a bold font I believe you also need to specify fontWeight="bold" in the Embed metadata.

Richard

p0ndusAuthor
Known Participant
May 11, 2010

I was hopeful that this might be it, but if I add your suggested metadata tag, I get:

exception during transcoding: Font for alias 'Myriad Pro' with bold weight was not found at: file:/src/assets/MyriadPro-Bold.otf