Q.システムフォントが適用できるかどうかを教えてくれる方法が必要ですか? ここに、システム フォントを読み取って、そのフォントがシステム フォントで使用可能かどうかをコンボボックスで確認できるサンプルがあります。以下のコードを見つけてください: -
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var systemFontsCollection:ArrayCollection = new ArrayCollection();
private function getSystemFont():void
{
var fonts:Array = Font.enumerateFonts(true).sortOn("fontName");
for (var i:int = 0; i < fonts.length; i++) {
systemFontsCollection.addItem(new String(fonts[i].fontName));
}
}
private function init():void
{
var fontName:String = fontName.selectedLabel;
if(systemFontsCollection.contains(fontName))
{
trace(" ----System Font is applied ----");
}
else{
trace(" ----System Font is NOT applied ----");
}
}
]]>
</fx:Script>
<mx:Form>
<mx:FormItem label="Font name:">
<mx:ComboBox id="fontName" change="init();" creationComplete="getSystemFont()">
<mx:dataProvider>
<fx:Array>
<fx:String>Arial</fx:String>
<fx:String>ArialEmbedded</fx:String>
<fx:String>Verdana</fx:String>
<fx:String>VerdanaEmbedded</fx:String>
</fx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
</mx:Form>
</s:Application>