flex - How to use fonts in external SWF files -
what flex app, uses fonts available in external swf. have succeded far is:
to create class hat holds embedded font:
package { import flash.display.sprite;
public class _arial extends sprite { [embed(source='c:/windows/fonts/arial.ttf', fontname='_arial', unicoderange='u+0020-u+002f,u+0030-u+0039,u+003a-u+0040,u+0041-u+005a,u+005b-u+0060,u+0061-u+007a,u+007b-u+007e')] public static var _myarial:class; }
}
compiled swf following command:
mxmlc.exe -static-link-runtime-shared-libraries=true _arial.as
when try load font flex app, fails following error message:
argumenterror: error #1508: value specified argument font invalid. @ flash.text::font$/registerfont() @ valueobjects::fontloader/fontloaded()[c:\documents , settings\nutrina\adobe flash builder 4\flex_pdf\src\valueobjects\fontloader.as:33]
this code try load swf file:
package { import flash.display.loader; import flash.display.sprite; import flash.events.event; import flash.net.urlrequest; import flash.text.*; import mx.collections.arraycollection; import mx.core.fontasset; public class fontloader extends sprite { public function fontloader(url:string) { super(); loadfont(url); } private function loadfont(url:string):void { var loader:loader = new loader(); loader.contentloaderinfo.addeventlistener(event.complete, fontloaded); loader.load(new urlrequest(url)); } private function fontloaded(event:event):void { var fontlist:arraycollection = new arraycollection(font.enumeratefonts(true)); var fontlibrary:class = event.target.applicationdomain.getdefinition("_arial") class; trace("fontlist: " + fontlist) trace("fontlibrary: " + fontlibrary) trace("fontlibrary._arial: " + fontlibrary._myarial) font.registerfont(fontlibrary._myarial); fontlist = new arraycollection(font.enumeratefonts(true)); trace("font list: " + fontlist) } } }
the font file not corrupt because if put _arial class code above flex application, embedding works. guess missed compilation options?
i using adobe flash builder 4.
i appreciate on matter.
thanks, gerald
could problem class name conflicts. wrestled external font loading issue hours. turns out font class called "main", , application trying load it. font never got registered correctly.
Comments
Post a Comment