Search code examples
actionscript-3apache-flexmxml

Embedded font not working in mxml, despite following embed-as-CFF advice


I'm trying to embed a font face in mxml/flex

I've read the articles that talk about embed-as-cff: true being for spark components and embed-as-cff: false being for mx.

I've tried using all 4 possible combinations of mx:label, s:label, embed-as-cff: true and embed-as-cff: false, but nothing doing

<fx:Style>
    @font-face { 
    src: url("assets/fonts/EXO2-LIGHT.TTF"); 
    fontFamily: exo2; 
    embed-as-cff: true;
     }
 @font-face { 
    src: url("assets/fonts/EXO2-LIGHT.TTF"); 
    fontFamily: exo3; 
    embed-as-cff: false;
  }
  </fx:Style>
  ...

    <s:Label styleName="applicationTitle" 
      fontFamily="exo2"  top="0" text="Service Capacity Forecast" 
      buttonMode="true"      useHandCursor="true"  />

Solution

  • Finally nailed it after a lot of trial and error. The styleName attribute referred to a style containing

    fontWeight:bold;
    

    and the font type I am using does not include a bold type. Instead of defaulting to the non-bold (regular) font, Flex decided that respecting the bold attribute was more important than the fontFamily.