Listing and viewing fonts

by yonatan forked from Listing Fonts (diff: 25)
♥0 | Line 22 | Modified 2010-04-08 14:25:15 | MIT License
play

ActionScript3 source code

/**
 * Copyright yonatan ( http://wonderfl.net/user/yonatan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/b9UI
 */

<?xml version="1.0" encoding="utf-8"?>
<!-- forked from 9re's Listing Fonts -->
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    creationComplete="init();" 
    paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0">

  <mx:DataGrid
      id="fontList"
      itemClick="changeFont();"
      width="100%"
      height="100%" />

  <mx:Script><![CDATA[
  import flash.text.Font; 
  import mx.core.FlexGlobals;
  
  private function init():void { 
    fontList.dataProvider = Font.enumerateFonts(true).sortOn("fontName", Array.CASEINSENSITIVE);
  }

  private function changeFont():void {
    fontList.setStyle("fontFamily", fontList.selectedItem["fontName"]);
  }

  ]]></mx:Script>
</mx:Application>