我已经嵌入了一些字体并在我的移动应用程序中使用它们,除了我尝试用于“ActionBar”的那些外,它们都在工作.他们在其他地方工作,用“Comic Sans MS”代替“titleCGF”将其改为Comic Sans.那么为什么它不适用于我的自定义fontFamily?
<fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @font-face { src: url("assets/Comic_Book.ttf"); fontFamily: comic; embedAsCFF: false; } /****************************** @font-face{ src: url("assets/CGF_Locust_Resistance.ttf"); fontFamily: titleCGF; embedAsCFF: false; } @font-face{ src: url("assets/CGF_Locust_Resistance.ttf"); fontFamily: titleCGF; embedAsCFF: true; } **********************************/ .titleStyle{ fontFamily: titleCGF; color: #FFFFFF; } .comicMessage{ fontFamily: titleCGF; color: #838689; fontSize: 14; } s|IconItemRenderer{ fontFamily: comic; color: #FEBA03; fontSize:18; } s|ActionBar{ defaultButtonAppearance: beveled; accentColor: #FEBA03; } s|ActionBar #titleDisplay{ fontFamily: "titleCGF"; } </fx:Style>
这就是我得到的:
编辑:我试图制作自己的皮肤,部分预先编写的代码是这样的:
<!-- SkinParts name=titleGroup,type=spark.components.Group,required=false name=actionGroup,required=false name=navigationGroup,required=false name=titleDisplay,type=spark.core.IDisplayText,required=false -->
当我尝试定义像前三个< s:Group ... />这样的东西时,它工作正常.但没有任何东西出现在spark.core.IDisplayText中. ie,< s:IDisplayText ... />什么都没有…
解决方法
这是两次嵌入字体的示例,一次使用embedAsCFF = false并再次使用embedAsCFF = true.查看
http://blogs.adobe.com/jasonsj/2011/08/embedding-fonts-in-flex-mobile-projects.html的完整说明.
编辑1:修复了字体文件名
/* StyleableTextField,regular */ @font-face { src: url("assets/COMIC.TTF"); fontFamily: "comic"; embedAsCFF: false; } /* StyleableTextField,bold */ @font-face { src: url("assets/COMICBD.TTF"); fontFamily: "comic"; fontWeight: bold; embedAsCFF: false; } /* Label,regular */ @font-face { src: url("assets/COMIC.TTF"); fontFamily: "comicCFF"; embedAsCFF: true; } /* Label,bold */ @font-face { src: url("assets/COMICBD.TTF"); fontFamily: "comicCFF"; fontWeight: bold; embedAsCFF: true; } s|Label { fontFamily: "comicCFF"; } s|ActionBar { fontFamily: "comic"; } s|LabelItemRenderer { fontFamily: "comic"; }