简体   繁体   中英

Use external Font Swf to change font of a dynamic text Field in AS3

I am working on a as3 project in which the user select a font from Combo Box and that font SWF should be loaded Dynamically and then i need to change the font of the Dynamic text field.

I have swf font files downloaded from www.isarie.com

My question is that how can i load the font swf dynamically from server and add them to the library and how can i use that swf to change the font of dynamic text field.

if there are embedded fonts in library then i can access them using this-

var fontList:Array = Font.enumerateFonts();
for( var i:int=0; i<fontList.length; i++ ){
    trace( "font: " + fontList[ i ].fontName );
} 

But How to use dynamically loaded Font swf as a font type.

If you know font class name, so:

 var fontClass:Class = swfLoader.contentLoaderInfo.applicationDomain.getDefinition("FontClassName") as Class;
    Font.registerFont(fontClass);

otherwise you can use FontLoader class by Denis Kolyako, you can get it here: http://etcs.ru/pre/FontLoaderDemo/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM