I have a file with different masters (around 5) and would like to export them on their own and combined into different exports. I found the copy layer to layer mekkablu script and I feel like what color fonts are doing is helpful but I haven’t found the right tool/option yet.
No, maybe an example:
There is a skeleton master and an outline master and then there is a master that has just Serifs s and I would like to export every combination of these 3 masters exported.
Here is an Image with the 3 masters with different master colors:
thanks for the answer. Maybe the colors were a bit misleading. You are right I followed the color tutorial as I have worked with it before and have the font set up like this. But in the end I am not looking for a color font to export but different combinations of the different layers exported into single files:
So for example I would like to have the single layers as instances/exports and these combinations for example:
However, for the combinations, I’m not sure you can do this easily upon export. You might need to do this with a script or filter that imports the outlines from the different masters.
Ah that is what I feared. Does anyone know if someone has done this before? I have very small scripting knowledge but it doesn’t seem like its the most complicated thing.
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 had a look at the plugin.
One big problem is that it relies on the currently active font to get to the original glyph with all layers (PreFilters are called after the interpolation, so all other layers are gone already).
There is a (kind of hidden) API that is called before the interpolation. It needs to be set up with a “PreInterpolationFilter”. Copy paste “PreInterpolationFilter” into the custom parameter popup and press “Add” even if the list is empty.
And the filter needs to implement a different callback:
from GlyphsApp.plugins import FilterWithoutDialog
class CombineMasters(FilterWithoutDialog):
def processGlyph_withArguments_(self, glyph, arguments: list):
font = glyph.parent
target_master_name = arguments[1].strip()
source_master_names = [item.strip() for item in arguments[2].split(",")]
target_master = font.fontMasterForName_(target_master_name)
target_layer = glyph.layers[target_master.id]
for source_master_name in source_master_names:
source_master = font.fontMasterForName_(source_master_name)
source_layer = glyph.layers[source_master.id]
for shape in source_layer.shapes:
target_layer.shapes.append(shape.copy())
And the filter parameter string needs to like this: