3
votes

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?

2

2 Answers

1
votes

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

0
votes

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;
    }
}