flex 4.5嵌入字体使文本不可见

时间:2012-09-12 21:34:53

标签: flex flex4 flex4.5

我的目标是在Flex应用程序中嵌入Arial字体。 我使用了MX和SPARK组件:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:s="library://ns.adobe.com/flex/spark"
    width="100%" height="100%" >
<mx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";

@font-face {
    src:url("assets/arial.ttf");
    fontFamily: Arial;
    embedAsCFF: true;
}
</mx:Style> 
<s:Button label="Button"/>
<mx:TextArea x="213" y="156" width="264" height="131" fontFamily="Arial"/>
</mx:Application>

按钮显示效果很好。 但textArea有空白字符。如果我将texteArea字体更改为Verdana(未嵌入),它可以正常工作!

我的问题是:如何在Flex中嵌入MX和SPARK组件的字体?

此致

1 个答案:

答案 0 :(得分:1)

您需要为MX和Spark组件指定单独的字体声明。只有Spark组件支持embedAsCFF:true。请参阅Embedding non-CFF versions of fonts for MX components

下面,我将Spark字体声明命名为ArialCFF,并将s | Button fontFamily样式属性设置为ArialCFF。我还将全局默认fontFamily设置为Arial,将mx | TextArea fontFamily设置为Arial。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:s="library://ns.adobe.com/flex/spark"
    width="100%" height="100%" >
<mx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";

global {
    fontFamily: Arial;
}

@font-face {
    src:url("assets/arial.ttf");
    fontFamily: ArialCFF;
    embedAsCFF: true;
}

@font-face {
    src:url("assets/arial.ttf");
    fontFamily: Arial;
    embedAsCFF: false;
}

s|Button {
    fontFamily: ArialCFF;
}

mx|TextArea {
    fontFamily: Arial;
}

</mx:Style> 
<s:Button label="Button"/>
<mx:TextArea x="213" y="156" width="264" height="131"/>
</mx:Application>