GSFontMaster.metricValues change in 3232 and up

Hello,

We are currently experiencing a lot of errors with our processes involving the metrics.

font = Glyphs.font

for master in font.masters:
	for metric in master.metrics:
		print(metric)

This used to work just fine, now it gives:

Traceback (most recent call last):
  File "<macro panel>", line 6
TypeError: 'objc.native_selector' object is not iterable

Taking this from the documentation:



Font = Glyphs.font

for metric in Font.masters[0].metrics:
	if metric.metric.type == GSMetricsTypexHeight and metric.metric.filter is None:
		metric.position = 543
		metric.overshoot = 17

gives us this:

Traceback (most recent call last):
  File "<macro panel>", line 5
TypeError: 'objc.native_selector' object is not iterable

The changelog for 3232 states:

improve GSFontMaster.metricValues in python wrapper

Unfortunately we couldn’t find any more information on how things were improved and it leads all our scripts and plugins to crash.

Any advice what we can do on our side except downgrade Glyphs again?

Hello, just in case you didn’t pursue this further: You need to add () after the .metrics now.

So it needs to read

for metric in Font.masters[0].metrics():
...

Thanks Sebastian :slight_smile:

We didn’t pursue it further since it wasn’t documented anywhere. Glad you found out and shared with us :slight_smile:

Thanks for this - of course if you make this change and then try to use the script on a version of Glyphs <3232, you now get __NSArrayM object is not callable.

I’m resorting to this to get it working in both versions:

            if Glyphs.buildNumber >= 3232:
                zipobject = zip(preview_master.metrics(), master.metrics())
            else:
                zipobject = zip(preview_master.metrics, master.metrics)
            for new, old in zipobject:

It’s disgusting, but that’s what we have to do with unstable APIs.