Embedding a font in CSS and compile it with Ant to a SWF for a Flex application

2 03 2010

To embed a font in a CSS one uses the @font-face directive. An example is shown below.

@font-face {
src: url("../../../framework/assets/gilr35w.TTF");
fontFamily: GillSansLight;
advancedAntiAliasing: true;
}

Be sure that you make a relative path from the location of the CSS file to your font or else your Ant file won’t compile and will throw an error like:

“unable to resolve … for transcoding”

It’s also possible that you get the same error for assets which have been embedded into the Flex application by using the @Embed feature. Be sure that you place a ‘/’ in front of the location where the source of the asset should be or else you’ll get this error.

In the Ant file you place an mxmlc execution block inside a target as shown below and it should work like a charm:

<mxmlc file="${APP_ROOT}/${CSS_SRC_PATH}/productSelector.css"
output="${OUTPUT_ROOT}/${CSS_DEST_PATH}/productSelector.swf" >
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
</mxmlc>

One can use the mxmlc execution tag by loading the flexTasks.jar as a resource in the Ant file.

<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/flexAnt/flexTasks.jar" />

Advertisement

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.