Embedding fonts in your Flex project has several advantages. Main reason would be if you use a font that's not wide-spread on the users' machines, another reason might be the anti-aliasing which enables fading of text, etc... However, embedding a font in Flex quickly adds up a few hundreds of Kb to the filesize of your SWF, especially if you embed your font in different styles (italic, bold, italic+bold). Bottomline is that you need to make sure you always limit the range of characters to optimize SWF filesize. Check out the Flex documentation, or the W3C page on unicode ranges for help in defining the character range you need.
Below, you have an example of how to embed Arial normal, italic, bold & italic bold for the Latin 1 character range (and U+20AC for the Euro sign €). Please note the custom name "myEmbeddedArial" for the embedded font. In all the style definitions, we need to refer to the custom name "myEmbeddedArial" as fontFamily to use the embedded font.
/**
* FONTS
*/
@font-face
{
src: url(../../assets/fonts/arial.ttf);
fontFamily: myEmbeddedArial;
advancedAntiAliasing: true;
unicodeRange:
U+0000-U+00FF,U+20AC-U+20AC; /*a-Z,0-9,punctuation,Latin 1,€*/
}
@font-face
{
src: url(../../assets/fonts/arialbd.ttf);
fontFamily: myEmbeddedArial;
fontWeight: bold;
advancedAntiAliasing: true;
unicodeRange:
U+0000-U+00FF,U+20AC-U+20AC; /*a-Z,0-9,punctuation,Latin 1,€*/
}
@font-face
{
src: url(../../assets/fonts/ariali.ttf);
fontFamily: myEmbeddedArial;
fontStyle: italic;
advancedAntiAliasing: true;
unicodeRange:
U+0000-U+00FF,U+20AC-U+20AC; /*a-Z,0-9,punctuation,Latin 1,€*/
}
@font-face
{
src: url(../../assets/fonts/arialbi.ttf);
fontFamily: myEmbeddedArial;
fontWeight: bold;
fontStyle: italic;
advancedAntiAliasing: true;
unicodeRange:
U+0000-U+00FF,U+20AC-U+20AC; /*a-Z,0-9,punctuation,Latin 1,€*/
}
Naturally, you can make a list of character ranges by separating the ranges with a comma.
What also may come in handy is that you can use the flex-config.xml to define & name character ranges globally for the project (again, check out the Flex doc).
I'm also convinced that it's a good idea to copy the True Type Font files into a subdirectory of your Flex project. This way, a fellow developer checking out the project from your source versioning software's repository (that will most likely be Subversion) will immediately have all the necessary fonts to build the project.

