Alternative to embedding a font in as3

别来无恙 提交于 2019-12-17 21:19:21

问题


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


回答1:


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 ) );



回答2:


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.




回答3:


You can embed the different fonts that you will require in different swf asset files and only load in the required fonts at runtime.



来源:https://stackoverflow.com/questions/6735556/alternative-to-embedding-a-font-in-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!