Editing Alignment Zones via Python in Glyphs 3

Hi there! I’m updating some of my own scripts from Glyphs 2 to Glyphs 3.

I am getting some attribute errors when I try to modify the alignments zones of a master. Are they now stored as a tuple?

How would one remove, and add, alignment zones via Python in Glyphs 3?

Thanks!

CC @GeorgSeifert @mekkablue

There are no alignment zones any more. The info is now in the metrics:
The documentation for how that works is not really good, yet. I’ll add some examples in the docu.

Thank you, please let me know when this is available!

The Python implementation in the wrapper will take some more time. Until then here some code that might help:

# Adding a "metric" 
master.setMetricPosition_overshoot_type_name_filter_(200, 16, metricsType, None, "script == 'arabic'")

(the metricType is an integer. The values you can find in GSMetric.h in Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework/Versions/A/Headers/GSMetric.h)

# changing a metric
metric = font.objectInMetricsWithType_withName_filter_(metricsType, name, filter)
metricValue = master.valueForMetric_(metric)
metricValue.position = 123
metricValue.overshoot = 21

I am finally getting around to implementing this. I am not seeing a file named GSMetric.h.

Did this change?

The file is there. Right click the app, “Show Package Contents” > open Content > Frameworks > Right click GlyphsCore.framework > Version > A > Headers.

@GeorgSeifert
Screen Shot 2023-03-07 at 1.47.43 PM

Here is a screenshot of the folder I see at that location, which includes GSMetricsValue.h, but no GSMetric.h file. This is an alphabetized view.

What version of Glyphs is that?

I have 3.1.2 (3151).

My screenshot is from that version.

I have one other question if you have a moment! I need to set some stem values within a master, via scripting.

I am familiar with master.stems, but I am not able to easily set those values. Can you give me a sense of how to do this? Thanks!

does this help: Glyphs.app Python Scripting API Documentation — Glyphs.app Python Scripting API 3.0.4 documentation