How to add system Fonts in your application – Font.enumerateFonts()

How to add system Fonts in your application

systemFonts.mxml

<?xml version="1.0? encoding="utf-8??>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml " layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init()">
	<mx:Script>
		<![CDATA[
		import flash.text.Font;
		private function init():void
		{
			arr = Font.enumerateFonts(true);
			arr.sortOn("fontName", Array.CASEINSENSITIVE);
		}
		]]>
	</mx:Script>
	<mx:Array id="arr" />
	<mx:String id="str">Check the font style in datagrid.</mx:String>
	<mx:String id="str1?>Check the font style in combobox.</mx:String>
	<mx:Label text="Number of installed fonts: {arr.length}" />

	<mx:DataGrid id="dataGrid" dataProvider="{arr}">
	<mx:columns>
	<mx:DataGridColumn dataField="fontName" width="200? itemRenderer="mx.controls.Label" />
	<mx:DataGridColumn dataField="fontStyle" />
	<mx:DataGridColumn dataField="fontType" />
	</mx:columns>
	</mx:DataGrid>

	<mx:Label id="lb2? text="{str1}" width="{cb.width}" height="32? fontFamily="{cb.selectedItem.fontName}" fontSize="16? />
	<mx:Label id="lbl" text="{str}" width="{dataGrid.width}" height="32? fontFamily="{dataGrid.selectedItem.fontName}" fontSize="16? />
	<mx:ComboBox id="cb" dataProvider="{arr}" labelField="fontName"/>
</mx:Application>