Having seen a few users getting into trouble with this obscure, hard to master, tecnique,
and having already tried to explain via email to somebody how to achieve success,
I decided that a quick note about the argument was necessary.
Take into account that it’s 3.12 am, I’m on a deadline, and I’m dead tired myself.
My editor for english (Yes, I have one: Angela) will probably have some work to do tomorrow.
We’re gonna use Aral Balkan’s article as a starting point;
Adding fonts to your SWF with FAMES
you’re going to need the sources for this project, since it’s too late to retype code or else.
download sources
these files are nothing but Aral’s ones with changes to the XML and one single change to the FontTest.as file.
I removed the reference to FlashOut, since you might want to be able to compile this using just SWFMill and MTASC (as the title of this little article says).
so let’s start.
I have to say that Aral’s example never worked for me from the beginning.
After a few minutes worrying (well… let’s be honest… a few hours), I decided to hack the thing and try to solve the issue.
From my experience with the Flash IDE, multi-lingual flash projects, dynamic sites etc,
I learned that the only way to have a font successfully usable through ActionScript, you need to:
- Import the font into the library using the “New Font” command on the library panel
- export the font using “linkage” and give it a name (I use the same font name with no spaces and adding emb_ at the beginning of the linkage name
- set the field that has to use the embedded font to .embedFonts=true;
once all the steps are taken, there’s no way for the process to fail.
Now let’s get back to Aral’s example xml file
<?xml version="1.0" encoding="iso-8859-1"?>>
<movie width="200" height="70" framerate="30">>
<background color="#ffffff"/>>
<frame>>
<font
id="kharon"
import="library/kharon.ttf"
glyphs="Helo,Wrd!"
/>>
</frame>>
</movie>>
this XML file doesn’t define any linkage for the font, plus it’s missing the node.
that’s why it didn’t work for me.
so after investigating on how to export a symbol for actionscript using SWFMill, I found out that you simply have to use an EXPORT directive, hence, define an EXPORT node containing a list of library objects to export.
then Aral’s XML became mine
<?xml version="1.0" encoding="iso-8859-1"?>
<movie width="200" height="70" framerate="30">
<background color="#ffffff"/>
<library>
<font id="kharon" import="library/kharon.ttf"/>
</library>
<Export>
<symbols>
<Symbol objectID="1" name="kharon"/>
</symbols>
</Export>
<frame/>
</movie>
now, be sure that both mtasc and swfmill are in your system’s PATH, so you don’t have to provide a full path to the binaries, follow these steps
- open a system SHELL
- move to the folder where all the sources are
- type in
swfmill simple FontTest.xml FontTest.swf
- type in
mtasc -main FontTest.as -swf FontTest.swf
- test the result launching your swf using a browser or a standalone plugin
have fun with it
Popularity: 4% [?]