How to embed fonts from a library SWC in Flex 3

Posted by Kristofer Joseph Tue, 30 Jun 2009 18:27:48 GMT

The problem:

You have two or more Flex projects that you want to share fonts between.

Solution:

Add the fonts to a shared library project then reference them in your css… right?

  • create a new library project
  • create an assets folder?This won’t work!
  • you have to add your fonts directly under the src folder
  • Add the fonts to the swc’s build path:

    go to Project Properties > Flex Library Build Path > Assets and check the checkbox next to the font files.

  • in your project you want to use the font in link to the library project:

    go to project properties > Flex Build Path > Library Path > Add Project

The rub:

For some reason Flex Builder can’t seem to find the fonts in the library project if they are in any directory BUT src?!

Usage:

You will then be able to reference your fonts in the linked projects css like so:

@font-face {
src:url("MyriadPro.ttf");
fontFamily: MyriadPro;  
}

Hopefully this saves someone some time.

3 comments |