Good afternoon Glyph-heads,
It just so happens that by complete coincidence I am currently trying to solve the same problem by writing a filter plugin that pulls in shapes from other masters / layers for an instance during export.
My problem is the code works only when I run the plugin manually from the edit view, but it does not work when adding the filter as a PreFilter or Filter Custom Parameter to an instance to be exported.
The code of my filter function is as follows:
def filter(self, layer, inEditView, customParameters):
combine_targets = customParameters.values()
combine_all = False
if len(combine_targets) == 0:
print("No targets specified, combining all masters")
combine_all = True
print("Combine targets:", combine_targets)
glyph = Glyphs.font.glyphs[layer.parent.name]
for other_layer in glyph.layers:
print("Checking", other_layer.master.name)
if other_layer == layer:
continue
if other_layer.master.name in combine_targets or combine_all:
print("Combining", other_layer.master.name)
print("Layer has shapes:", len(layer.shapes))
for shape in other_layer.shapes:
layer.shapes.append(shape.copy())
print("Shapes after combining:", len(layer.shapes))
return layer
I’m setting the filter up like this:
And the macro logs from my script indicate the shapes have been added
Combine targets: dict_values(['Serif', 'Mono'])
Checking Double
Checking Mono
Combining Mono
Layer has shapes: 7
Shapes after combining: 11
Checking Serif
Combining Serif
Layer has shapes: 11
Shapes after combining: 14
However the exported font file does not contain the extra shapes, any ideas what I am missing?
