Axis id changes after reloading the font

Hi!

I’m working on a plugin that relies on the axis identifier. However, it appears that the identifier can change after reloading the file.

Here’s how to reproduce the issue:

Step 1. Create a new font, add a single axis, and check ids:

print([a.id for a in Glyphs.font.axes])
['A0D42D38-DA43-411C-8FEE-4339DFE1D297']

Step 2. Save and reopen the Glyphs file.
Step 3. Check the axis id again

print([a.id for a in Glyphs.font.axes])
['a01']

Is this the expected behavior? If so, how can I force Glyphs to recalculate the final id?

Thank you!

Yes, that is how Glyphs deals with new axes internally. It will create a unique id first. When you reopen the file that id will be resolved to something more reasonable by still being unique along the other axes.

I guess you should not use the long identifier, as they are basically throway-ids.

1 Like

You probably should use the axis tag to identify the axis. Or do you need something else.

1 Like

Mark, Georg, thank you for your responses. I’ll use the axis tag as id.

However, persistent identifiers would be a great feature for Glyphs.

Can you give an example, that would benefit from it?

For example, I want to build a custom designspasce relying on additional axes properties. Consequently, I need to extend the behaviour of the axis class.

Being able to reference an axis by its ID would enable me to add new functionality to the axis object without modifying its code.

You mean code-wise?

Sounds like a subclass task or extension/category (depending on what language you’re working) to me?

Depends what you like to put into the axis.

I added [GSAxis userData]. But that can only be added to the next big update because of source compatibility.

What properties are that?

Thank you, Georg!

[GSAxis userData] will work in my case: for boolean property “mode”.

Thank you, Mark. For example, decorator class are good examples of permanent ID applications.