Francis
Francis

Reputation: 792

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"  />

Upvotes: 0

Views: 556

Answers (2)

UI Dev
UI Dev

Reputation: 699

can you try for .otf instead of .ttf Here is some code which is working for both spark & mx

@font-face {
   src: url('assets/fonts/HelveticaNeue-Roman.otf');
   font-family: "Helvetica Neue";
   embedAsCFF: false;
}

@font-face {
   src: url('assets/fonts/HelveticaNeue-Bold.otf');
   font-family: "Helvetica Neue Bold";
   embedAsCFF: false;
}

Upvotes: 2

Francis
Francis

Reputation: 792

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.

Upvotes: 1

Related Questions