Can I use a non-built-in fallback font when using a built-in font with AS3 TextField?

I have a built-in font in my AIR / AS3 application that lacks support for most international characters. Using TextField and StyleSheet with the font-family property, I assumed that I just need to do this:

font-family: Interstate-Regular, _sans;

This works if TextField.embedFonts = false;, but then Interstate-Regular is not built-in for users who do not have it on their system. With the TextField.embedFonts = true;text is not even displayed. Is there a way to embed Interstate-Regular and use _sans as a backup system font without embedding it?

+3
source share
2 answers

Flash Text Engine "" , TextField .

Adobe

+1

FontManagement, , . , FontManagement , . , TextField .

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

Source: https://habr.com/ru/post/1764240/


All Articles