在移动设备应用程序中嵌入字体
可以嵌入要在移动设备应用程序中使用的字体,但有一些限制条件。
由于 Label 控件使用 FTE(因此使用 CFF 字体),在移动设备应用程序中嵌入字体时应使用具有基于 TextField 外观的 TextArea 或 TextInput 控件。不能嵌入具有基于 StageText 外观的字体。通常情况下,在移动设备应用程序中应避免使用 FTE。
在您的 CSS 中,将 embedAsCFF 设置为 false,并应用基于 TextField 的外观,如下例所示:
<?xml version="1.0" encoding="utf-8"?>
<!-- mobile_text/Main.mxml -->
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
firstView="views.EmbeddingFontsView">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@font-face {
src: url("../assets/MyriadWebPro.ttf");
fontFamily: myFontFamily;
embedAsCFF: false;
}
.customStyle {
fontFamily: myFontFamily;
fontSize: 24;
skinClass: ClassReference("spark.skins.mobile.TextAreaSkin");
}
</fx:Style>
</s:ViewNavigatorApplication>
EmbeddingFontView 视图的 TextArea 控件应用类型选择器:
<?xml version="1.0" encoding="utf-8"?>
<!-- mobile_text/EmbeddingFontsView.mxml -->
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Embedded Fonts">
<s:layout>
<s:VerticalLayout paddingTop="20" paddingLeft="20" paddingRight="20"/>
</s:layout>
<s:TextArea id="ta1"
width="100%"
styleName="customStyle"
text="This is a TextArea control that uses an embedded font."/>
<s:TextArea id="ta2"
width="100%"
text="This TextArea control does not use an embedded font."/>
</s:View>
如果使用类选择器(例如 s|TextArea)应用样式(或嵌入字体),请在主应用程序文件中定义类选择器。不能在移动设备应用程序的视图中定义类选择器。
有关更多信息,请参阅嵌入字体。

浙公网安备 33010602011771号