Created
February 4, 2014 02:52
-
-
Save girasquid/8797423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.Sprite; | |
import flash.text.Font; | |
import flash.text.TextField; | |
import flash.text.TextFormat; | |
public class FontDetector extends Sprite { | |
[SWF(width='640', height='480', backgroundColor='#FFFFFF', frameRate='60', pageTitle="What fonts are on your system?")] | |
public function FontDetector():void { | |
// http://stackoverflow.com/a/10837614/240418 | |
for each(var font:Font in Font.enumerateFonts()) { | |
var fontSample:TextField = new TextField(); | |
fontSample.embedFonts = true; | |
fontSample.text = font.fontName; | |
fontSample.x = 50; | |
fontSample.y = 25 * Font.enumerateFonts().indexOf(font); | |
var fontFormat:TextFormat = new TextFormat(); | |
fontFormat.font = font.fontName; | |
fontFormat.size = 16; | |
fontSample.setTextFormat(fontFormat); | |
addChild(fontSample); | |
} | |
var fontCount:TextField = new TextField(); | |
fontCount.text = String(Font.enumerateFonts().length); | |
fontCount.x = 50; | |
fontCount.y = 50; | |
addChild(fontCount); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment