I am thinking that I can dynamically embed fonts in Flex. I want to embed different fonts for different users, so I do not want to embed all possible fonts into a single Flex file. If this is possible, you can please post the sample code.
You can do this in the action script. I have used this trick primarily to use opentepe fonts which were not supported with the compiler in the Flash IDE, and to create a font library that can be lazy loads (only when necessary), but you can select it You can also use it to load fonts. If you had a mxmlc compiler on your server, you can also create the fontlib.as file and compile it at the command.
// fontlib.as // font library file package {import flash.display .Sprite; Public class fontlib sprite ([source = 'font / path / fontfile.otf', fontname = 'fontfile', unicoderenz = 'U + 0020-U + 007E, U + 00Ab, etc ...']] Fixed var fontfile: class; public static property: FontFile_name: string = "fontfile"; // mail 'fontName' embed font in public function Lib () {}}}
be compiled You can use it in your application like this:
mxmlc fontlib.as
// main.as // Document class package {import flash.text.Font; Import Flash.Display.Loader; Import Flash.events.Event; Import Flash System .App Domains; Import Flash Text. style sheets, public Wars fonts loader: loader; public var fontFile: string = ""; public var ss: StyleSheet; public function main () {fontsLoader = new loader (); Fontloder Kantentloderinfo.adent Lostonr (Event. Comple, _onFontsLoadComplete) ;} Private Functions _onFontsLoadComplete (E: Event): Zero {var fontlib: VERS C = e.target.applicationDomain.getDefinition ('fontlib'); Font.registerFont (fontlib.FontFile); // register font font file = fontlib.fontFile_name; // Font was loaded as the name. The use of font looks like this: ss = new StyleSheet (); Ss.parseCSS ("div {fontFamily:" + fontFile + ";}"); }}
Comments
Post a Comment