embed fonts in as3 from resource file
I'm creating a generic flash navigation. I'd like to allow people to use their own fonts like sIFR. I know i开发者_C百科 can just create a swf file with a font embedded but i'd like to make it as easy as possible for someone to swap fonts so an existing method of creating a swf font file would be preferred.
Don't know if it helps, but Ştefan Isarie has quite a few sIFR fonts ready for use.
Maxmc's suggestion looks fine. Would you be able to generate the swf on the server via the Flex Module for Apache/IIS ?
Hopefully you won't get in trouble with special characters.
Also, just as a backup plan, have you considered alternatives ?
HTH, George
You could define the font swfs in a xml file, <font id="Futura" src="fonts/futura.swf" />
then load the xml at runtime, load the defined font.swf and use Font.registerFont
with the the loaded swf.
Note that you can't easily load original font formates like ttf. (which would be to big anyway) You need to complile them to swf in order to be able to load and register them in your application.
[Embed(source = 'fonts/futura.ttf', fontName = 'Futura')]
public class Futura extends Font {}
精彩评论