Export different masters into one export

Hey,

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.

Cheers and thank you for all the work
Bruno

1 Like

What do you have in those masters?

If it is just different styles of the same font, this might help: Suitability of Using Multiple Masters for Display Font - #2 by SCarewe

Thank you for the answer!!

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:

Would this work?
So green with pink or blue with green or all 3 colors together

1 Like

This should help: Creating a layered color font | Glyphs

Hy Georg,

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:


1 Like

Then just export one instance per master.

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.

1 Like

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?

1 Like

Can you send me the filter plugin and the .glyphs file?

1 Like

Hi Georg!

Sure, here it is:
https://www.dropbox.com/scl/fo/1n254lkogg7o789fidx3m/AFK2_5LGSNhFDVV7MLlp3NM?rlkey=bbda3r9z6t51m406guaogrlpv&st=bgepzace&dl=0
Only the A has different shapes for the three masters.

@GeorgSeifert not to bother you but did you have any thoughts on what I’m doing wrong there / how to approach this problem? :o)

love from morocco :morocco:

I’ll have a look at it. Thanks for the reminder.

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:

CombineMasters; Double; Serif, Mono; include: A

meaning: FilterName; Target Master; Source Masters (comma separated); include: (optional)

2 Likes

this works great, thanks for sharing this ‘hidden gem’ of an API, Georg,
have a great weekend !