在AS3 TextField中使用嵌入字体时,是否可以使用非嵌入式回退字体?

时间:2010-09-10 21:43:51

标签: actionscript-3 actionscript air

我的AIR / AS3应用程序中有一个嵌入式字体,缺少对大多数国际字符的支持。使用TextField和StyleSheet以及font-family属性,我假设我只需要这样做:

font-family: Interstate-Regular, _sans;

这适用于TextField.embedFonts = false;但是Interstate-Regular不会嵌入到系统中没有它的用​​户身上。使用TextField.embedFonts = true;时,文本甚至都不显示。有没有办法嵌入Interstate-Regular并且仍然使用_sans作为后备系统字体而不嵌入它?

2 个答案:

答案 0 :(得分:1)

Flash文本引擎有这个"后备"功能,但它比常规TextField慢,并且更难以使用它。

Link to the Adobe Manual

答案 1 :(得分:0)

如果主要字体不支持某种语言,则可以在自定义FontManagement类中实现切换,还原为非嵌入字体。为此,您可以使用此FontManagement类作为格式化TextField的集中点。这可以通过创建一个公共静态函数来实现,该函数将返回具有相关格式的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;
    }
}
相关问题