I’m trying the keep my bracket layers in sync with its “parent master layer”. It’s pretty easy with layer.syncMetrics()
but only helps with linked key metrics. So I’d like to copy metrics from main master layer to child layers containing brackets in the name. How can I fetch a bracket-layer’s master’s metrics?
This is all I have at the moment.
font = Glyphs.font
glyphs = font.glyphs
brackets = ('[',']')
for glyph in glyphs:
for layer in glyph.layers:
for bracket in brackets:
if bracket in layer.name:
# Print layer name containing brackets
print layer.name
# Copy metric from parent master layer
Never mind, I think I just figured it out.
font = Glyphs.font
glyphs = font.glyphs
masters = font.masters
brackets = ('[',']')
for glyph in glyphs:
for layer in glyph.layers:
for bracket in brackets:
if bracket in layer.name:
# Parent master layer
pMaster = masters[layer.associatedMasterId]
pMasterLayer = glyph.layers[pMaster.id]
# Copy metric from parent master layer
layer.LSB = pMasterLayer.LSB
layer.RSB = pMasterLayer.RSB
# Stop checking for brackets
break
You can simplify it a bit:
font = Glyphs.font
glyphs = font.glyphs
brackets = ('[',']')
for glyph in glyphs:
for layer in glyph.layers:
for bracket in brackets:
if bracket in layer.name:
# Parent master layer
pMasterLayer = glyph.layers[layer.associatedMasterId]
# Copy metric from parent master layer
layer.LSB = pMasterLayer.LSB
layer.RSB = pMasterLayer.RSB
# Stop checking for brackets
break
Ah, thats definitely prettier. Thanks for the tip.
Hi, I was looking for the same solution, but I wanted to ask why “Re-Interpolate Metrics” interpolates the metrics at the point on the axes where the bracket layer is defined, rather than simply copying the metrics from the parent master. Wouldn’t that make more sense?