How to embed fonts from a library SWC in Flex 3 5

Posted by Kristofer Joseph Tue, 30 Jun 2009 17: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.

Comments

Leave a comment

  1. Todd Rothe 1 day later:

    Now that’s practical knowledge straight from the trenches. thanks!

  2. Will about 1 month later:

    Thanks for this post. I’m also using a .swf file as the application’s backgroundImage, set the css.

    It seems the .swf also to be directly under the src folder.

  3. Kieran 7 months later:

    Thanks dude, really useful spot on that src directory thing for fonts.

  4. krzyzowki about 1 year later:

    This is the greatest topic I have read today

  5. programy about 1 year later:

    I think this is one of the most important information for me. And i’m glad reading your article. But wanna remark on few general things, The website style is great, the articles is really excellent. Good job, cheers

Comments