Sandbox
I will rewrite this code irregularly.
/**
* Copyright matacat ( http://wonderfl.net/user/matacat )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/j5wb
*/
package
{
import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFormat;
[SWF(width = 465, height = 465, frameRate = 60)]
public class FontListUp extends Sprite
{
//[Embed(source = "../assets/cinecaption227.TTF", fontName = "cinecaption")]
//private const testfont:Class;
private const GUESS_JA:Boolean = false;
private const TEST_STR:String = "ใ";
public function FontListUp()
{
var txf:TextField = new TextField();
var fmt:TextFormat = new TextFormat("Meiryo UI", 12);
var lst:Vector.<Font> = Vector.<Font>(Font.enumerateFonts(true));
txf.border = true;
txf.multiline = true;
txf.width = stage.stageWidth - 1;
txf.height = stage.stageHeight - 1;
txf.defaultTextFormat = fmt;
txf.text = "Length: " + lst.length.toString() + "\nใในใ\n";
for (var i:int = 0, l:int = lst.length, f:Font; i < l; i++) {
f = lst[i];
//Font.registerFont(Class(f));
if (GUESS_JA) {
if (!f.hasGlyphs(TEST_STR)) continue;
}
fmt.font = f.fontName;
txf.defaultTextFormat = fmt;
txf.appendText(i.toString() + ": " + f.fontName + " (" + f.fontStyle + "/" + f.fontType + ")\n");
}
addChild(txf);
}
}
}