Single glyph interpolation

Hi there!

I’m more familiar with the Robofab API, which gives the ability to interpolate not only between two RFont objects, but also between two RGlyph objects.

What is the recommended way to achieve this within the glyphs object map/API?

As an example scenario:

Say I have a glyphs file with 3 masters: light, regular and bold. How do I describe that I’d like only the "a" glyph in the regular master to be an interpolation between the light and bold masters, at a certain factor?

If the light master is 0, and the bold mater is 1, how do I describe that the regular master’s “a” drawing/spacing should be interpolated at 0.8? Or 0.2?

Furthermore, does the Glyphs API provide a way to interpolate GSLayer objects?

Thank you!

There is not direct API for this, yet (will be in the next version). I tried if the robofab wrapper in Glyphs could be used but it is not compatible in this point.

When you like to re-interpolate a master layer, you can use this

layer = glyph.layers[font.masters[1].id]
glyph.replaceLayerWithInterpolation_(layer)

As of G3 3.2+ this is now spelt glyphs.replaceLayersWithInterpolations_([layer, layer2, ...]). Here’s a fun little snippet to “fill in” any empty masters for a glyph:

glyph = Glyphs.font.selectedLayers[0].parent
emptyLayers = [l for l in glyph.layers if len(l.shapes) == 0]
glyph.replaceLayersWithInterpolation_(emptyLayers)
1 Like