Getting a list of embedded fonts

I’m kind of curious to know which fonts come embedded with OpenFl; I’ve been trying to get a list of them with openfl.text.Font.enumerateFonts() but the array only seems to get populated if you end up using it, e.g. in the AddingText example:

var format = new TextFormat ("Katamotz Ikasi", 30, 0x7A0026);
var textField = new TextField ();
trace(Font.enumerateFonts() + " is the value for enumerateFonts()");

And then on the browser it prints out:

AddingText.js:6107 Main.hx:19: [{
		src : null, 
		name : Katamotz Ikasi
	}] is the value for enumerateFonts()

Otherwise the array is empty.

Is there another way to get a list of the fonts, or are they documented somewhere?

Ah never mind - I didn’t realised that the AddingText example had that font in the assets, so looks like there aren’t any embedded fonts OpenFl includes by default!

No, not currently. Later we may add better support for finding/using system fonts, but currently its best to include your own fonts

EDIT: However, we do map to installed system fonts by default when “_sans”, “_serif” or “_typewriter” are used as your font name :slight_smile:

1 Like

Thank singmajesty - it defaults to Times New Roman on my machine when the font isn’t there, but that is useful to know for getting some text variations without doing anything extra :slight_smile:

You should able to also get Arial (or its equivalent) and Courier New (or something similar) using “_sans” or “_typewriter”