Mega Code Archive

 
Categories / Flex / Graphics
 

List embedded fonts

<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="listFonts()">     <mx:Style>     @font-face {       src:url("a.ttf");       fontFamily: myFont;       flashType: true;     }     @font-face {        src:url("a.ttf");        fontFamily: myFont;        fontWeight: bold;        flashType: true;     }     @font-face {        src:url("a.ttf");        fontFamily: myFont;        fontStyle: italic;        flashType: true;     }     .myPlainStyle {        fontSize: 32;        fontFamily: myFont;     }     .myBoldStyle {        fontSize: 32;        fontFamily: myFont;        fontWeight: bold;     }     .myItalicStyle {        fontSize: 32;        fontFamily: myFont;        fontStyle: italic;     }     </mx:Style>     <mx:Script>     private function listFonts():void {     var fontArray:Array = Font.enumerateFonts(false);        for(var i:int = 0; i < fontArray.length; i++) {           var thisFont:Font = fontArray[i];           if (thisFont.fontType == "embedded") {               trace("name: " + thisFont.fontName +"; typeface: " + thisFont.fontStyle + "; type: " + thisFont.fontType);           }        }     }   </mx:Script>     <mx:VBox>        <mx:Label text="Plain Label" styleName="myPlainStyle"/>        <mx:Label text="Italic Label" styleName="myBoldStyle"/>        <mx:Label text="Bold Label" styleName="myItalicStyle"/>     </mx:VBox> </mx:Application>