Does each GSFont have a unique ID?

Glyph, layer, and font master objects all have an id attribute—a computer-generated string to distinguish between similar objects. Do font objects have a similar attribute?

What do you need it for?

I’m developing a plugin to generate a proof for any open font. It has a simple Vanilla UI with a dropdown menu to choose from the list of open fonts. Without a unique ID for each font, my plugin needs to use the index of the user-chosen font in Glyphs.fonts. Those indexes can change, and I have found too many scenarios where my list of open fonts gets out of sync despite tracking DOCUMENTCLOSED, DOCUMENTOPENED, and DOCUMENTACTIVATED. I cannot make my plugin’s font chooser dropdown work based on font family name (might be the same for multiple fonts) or document file path (doesn’t work for new, unsaved documents) or the ID of the first master (could potentially change without notice). What I really need is a permanent ID for the font—just like how Glyphs assigns one to each font master.

I’m sure my needs are one of many possible situations where a permanent font document ID would be useful to a developer. This is pretty fundamental. There is no other 100% reliable way of identifying (and differentiating between) two font objects, without storing entire copies of them.

Just use the font object as such. Those are unique and will not change.

Or build the plugin as a modal dialog that you open (with a fresh list of fonts), choose your settings and generate the proof. So you don’t need to update any UI.

Or is there a reason you need to keep that dialog open all the time.

And you could use bindings to Glyphs.fontDocuments. That will update the popup automatically.

The plugin UI is a panel that needs to remain open.

Could you provide an example of how I could bind a Vanilla PopUpButton to Glyphs.fontDocuments? That sounds ideal but I didn’t realize it was possible.

Can you send me a screenshot of you dialog (send a private message if you can’t publish it)?
I’ll build an example.

Thank you so much. I just sent you a private message.

Just to give another option, you can generate IDs yourself and store them in font.userData

No need for an id, just use the object. All the other objects can be replaced so an persistent ID is useful.