Alternative to embedding a font in as3
I have quite a basic question to ensure I am not missing something obvious!
Does anyone know of an alternative to embedding fonts? I am developing a global app which will change the font for Asian languages. If these fonts are embedded 开发者_如何学编程it will result in a massive SWF file, I would like to get the font, when it goes on the Asian system from the windows/fonts folder.
Cheers
You can do this by embeding the font in external SWF files.
for example you have:
Arial_EN.swf
Arial_RU.swf
Arial_JP.swf
Arial_DE.swf
Then in your configuration file you a defining which swf to load. After you load SWF
<!-- english Arial -->
<o n="font">
<o n="path">swf/Arial_DE.swf</o>
<!-- Styles, under which names your fonts are exported while emebeded -->
<o n="style">bold</o>
<o n="style">bold_italic</o>
<o n="style">italic</o>
<o n="style">regular</o>
</o>
Load the swf:
var fontLoader:Loader = new Loader ();
//all the eventlistener and functions for it
fontLoader.load ( xml.font.path )`
After you load the swf and you have the style names just register the font, if you will be using embedFonts=true
option
Font.registerFont ( fontLoader.getClass ( xml.font.style ) );
I have had success with using system fonts such as Arial or simply _sans for languages that have special characters. Just make sure to set embedFonts to false.
You can embed the different fonts that you will require in different swf asset files and only load in the required fonts at runtime.
精彩评论