Skip to content

Instantly share code, notes, and snippets.

@girasquid
Created February 4, 2014 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save girasquid/8797423 to your computer and use it in GitHub Desktop.
Save girasquid/8797423 to your computer and use it in GitHub Desktop.
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