Is it possible to use a non-embedded fallback font when using an embedded font with AS3 TextField?
I have an embedded font in my AIR/AS3 app that lacks support for most international characters. Using TextField and StyleSheet with the font-family property, I assumed I would simply need to do this:
font-family: Interstate-Regular, _sans;
This works if TextField.embedFonts = false;
but then Interstate-Regular isn't embedded for users that don't have it on their system. With TextField.embedFonts = true;
the text doesn't even 开发者_开发知识库show up. Is there a way to embed Interstate-Regular and still use _sans as a fallback system font without embedding it as well?
Flash Text Engine has this "fallback" feature, but it is slower than regular TextField
, and more difficult to use it.
Link to the Adobe Manual
You could implement a switch in a custom FontManagement class , if a language is not supported by your main font , revert to a non embedded font. To achieve this , you could use this FontManagement class as a centralized point where to format your TextFields. This could be achieved by creating a public static function which would return a TextField with the relevant format.
//where you need to format a TextField var params:Object = {color:0xffffff , size:12, supported:false , etc...}; var tf:Texfield = FontManagement.formatTextField(tf , params ); public class FontManagement { //A basic example public static function formatTextField( tf:TextField , params:Object ):TextField { //since this is a static function , the Boolean is passed as an argument //but there are other ways to set it, depending on where in your app //the language is identified if( params.supported ) tf.embedFonts = true; else tf.embedFonts = false; //here the rest of your formatting code return tf; } }
精彩评论