Hi.
I would think about using the [Embed] directive in pure AS3 code to
create font swf files. You can have one or more fonts in a swf which
does not matter and you can load them in a runtime dynamically.
Here is an example of a Font file - you can setup a project in
FlashDevelop that will compile this as the main class in a SWF file.
For multiple Fonts, just duplicate the [Embed] line and the static
variable for it (with a different name.
Using an FLA - it does not embed the font ranges in the same way. I
found there were only a certain range of characters in the IDE created
SWF even when I changed the range to be embedded - only by de-compiling
the SWF and looking at the glyphs embedded with Sothink's tool!
If you need unicode ranges, this page is really useful:
http://www.zenoplex.jp/tools/unicoderange_generator.html
Also lots of links I have used to piece together my methods:
http://blog.arwidthornstrom.com/2009/04/embedded-fonts-that-work-with-flash-ide-and-flex-sdk/
http://troyworks.com/blog/2008/09/12/flash-runtime-font-sharing-embedding-with-only-partial-character-sets-how-to/
http://www.betriebsraum.de/blog/2007/06/22/runtime-font-loading-with-as3-flash-cs3-not-flex/
http://developer.yahoo.com/flash/articles/runtime-fonts-as3.html
http://www.ultrashock.com/forums/actionscript/font-embedding-using-flash-as3-and-flex-3-a-109509.html
http://www.aaronwest.net/blog/index.cfm/2009/3/16/Lee-Brimelow-on-Creating-Runtime-Loaded-Fonts-in-Flash-CS4
http://mx.coldstorageonline.com/index.php?bid=48
The font is shown below - this is added to my config file - my
application automatically loads any ".swf" files at startup (it is
local, not net as a 7MB font with Traditional Chinese will strain your
connection). If I change languages, my XML file may specify a font to
find -
IMPORTANT - the "fontName" in the XML matches the fontName in the Embed
statement!
My Application "Screens" all use a public static variable called
_defaultFont, which can be changed at runtime by the following function
and all my components can access the defaultFont variable should they
wish to use it (a snippet of XML is shown at the bottom).
Hope this helps - you can follow the links and work it out yourself if
you want, or peek below:
Glen
protected function _findLanguageFont():void {
var langXML:XML = languages.language.(attribute("lang") ==
languageCode)[0];
debug(this, "will check for languageCode " + languageCode +
" in " + languages.language.toXMLString());
_defaultFont = null;
if (langXML) {
if(0 != langXML.attribute("fontName").length()) {
debug(this, "Language has font " + langx...@fontname);
var fonts:Array = Font.enumerateFonts(false);
for(var i:int = 0;i < fonts.length;i++) {
var fnt:Font = fonts[i];
if (fnt.fontName == langx...@fontname) {
_defaultFont = fnt;
debug(this, "Language set _defaultFont to "
+ defaultFont.fontName);
break;
}
}
}
}
}
package {
import flash.display.Sprite
import flash.text.Font;
/**
* Times font embedding class example.
* Whatever you set the "fontName" property to is what you use as
the fontName property in the config file for the app.
*
* This is different to embedding fonts with Flash because you can:
*
* 1. Set the unicodeRange - specify certain characters / ranges
to embed, reducing file size.
* 2. Choose your own fontName to avoid "font clashes" at runtime.
* 3. Register the font in the file - the contstructor is called
as the swf is loaded because this class is the
* document class, so all you need to do is look for your font by
fontName in your app.
*
* NB - Adobe's UnicodeTable.xml file was used to get the ranges
for unicode, which omit the ? and a few other chars, so
* this was doctored to include those (basically
U+0300-U+030A,U+0041-U+005A was combined into U+0030-U+005A.
*
* @author Glen
*/
public class _Times extends Sprite {
//Basic Latin characters + some punctuation - don't use the
Adobe UnicodeTable for Basic Latin - it misses "?" = 0x030F
[Embed(source = "C:/WINDOWS/Fonts/TIMES.TTF", fontName =
"_Times", fontFamily = "Times", mimeType = "application/x-font-truetype",
unicodeRange =
'U+0020-U+002F,U+0030-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
public static var _font:Class;
public function _Times():void {
trace("Font Loaded:: _Times");
Font.registerFont(_font);
}
}
}
Sample XML config file for the application - the asset called
symName="com.robothespian.screen.LanguagesScreen" startscreen="true"
sho