If you are building a Flex4 application and want to use the cool CFF fonts you will be frustrated pretty soon.
Strangely I didn't seem to have any problems with embedding Fonts with Flexmojos3 but with Flexmojos4 I didn't get any errors or warnings, I simply couldn't use the fonts.
Here comes the code in my CSS file that was enough to embed my fonts with Flexmojos3:
@font-face { src: url("/assets/fonts/HypatiaSansPro-Semibold.otf"); font-family: "MainFont"; font-weight: normal; advanced-anti-aliasing: true; embedAsCFF: true; /* Embeding fonts as CFF makes it nessecary to set the textFieldClass of mx:Labels to "mx.core.UIFTETextField" */ } |
As I mentioned, with Flexmojos4 I was no longer able to use my fonts but there were no errors or warnings to get me on the right track.
Most tutorials on the web said, that you need to add some dependencies to the plugin and manually install some Flex SDK jars as these are not provided per default. This seems not to be true anymore. I could perfectly integrate my custom fonts without installing a single jar-file to my repository.
The second step most tuorials tell you, is to add a configuration option to your flexmojos plugin section:
<fonts> <managers> <manager>flash.fonts.AFEFontManager</manager> <manager>flash.fonts.JREFontManager</manager> <manager>flash.fonts.BatikFontManager</manager> </managers> </fonts> |
But unfortunately they are all missing the one manager you need (CFFFontManager). My builds work perfectly without these 3 managers:
Use this instead:
<fonts> <managers> <manager>flash.fonts.CFFFontManager</manager> </managers> </fonts> |
I remember that mx components were not able to use my CFF fonts without modification. In Flashbuilder automatically a special CSS file (MXFTEText.css) is included into the build that exchanges the textLabelClass to use a CFF capable implementation. Here is an example of its content:
mx|Label { textFieldClass: ClassReference("mx.core.UIFTETextField"); } |
I had some problems embedding Fonts in my Skin project as FM4 was throwing "unable to transcode" errors at me. I had two reasons for the Transcoding from failing: