Adding glyphs via python script

I’m trying to add glyphs to a font with the following script:

for key in brahmi_numbers:
	print(key, "->", brahmi_numbers[key])
	myGlyph = GSGlyph() = 'uni'+key 
	myGlyph.unicode = key
	myGlyph.color = 8
	myGlyph.script = 'brahmi'
	myGlyph.storeScript = True
	myGlyph.sortName = key
	myGlyph.storeSortName = True
	myGlyph.category = "Number"
	myGlyph.storeCategory = True

The glyphs get added. However, they are not displayed in a single row

(attached image) How can I make them appear continuously without those breaks?

Answering my own question. I fixed it by dropping the script and sortName properties :blush:

1 Like

Can you send me that list of unicodes?

I’ll email you the python script. You can run it on a new font in Glyphs 3

I found the issues. The sort name is used in a special way for numbers. Set it like this:

		myGlyph.sortName = 'bn%.05d' % int(key, 16)

and it will work.
But instead of writing a script like this, you could set up a GlyphData.xml for the brahmi glyphs. And add a custom sidebar entry and setting up a new font will be one mouse click away.

I got the GlyphData.xml working. However, when I add the glyphs via the sidebar, the added glyphs were missing all other data except the glyph name. No Unicode, no script name etc. I’ll send you (back) the xml via email :slight_smile: