How to set the active layer for a glyph in a text tab

Is this possible? I.e. I have a script that detects overlaps and when it comes a glyph that has a bracket or brace glyph, and finds a positive result there, I want to also report that in the text tab when I display all the glyphs that return positive.

Based on the Glyphs Python API it appears you can do this:

Alternatively, you can set (and read) a list of GSLayer objects. These can be any of the layers of a glyph. OpenType features will be applied after the layers have been changed.

Here’s a quick test I ran to verify this, just adding glyphs or in this case layers to a new tab if there is an active brace layer, but this should work the same for something like if overlaps == True: :

import re

font.newTab().layers = []

for glyph in font.glyphs:
	for layer in glyph.layers:
		if re.match('{.*\d}', layer.name) != None:
			font.tabs[-1].layers.append(layer)
1 Like