Re-check if metrics keys are out of sync?

What’s the best way to tell Glyphs to re-check whether a layer’s metrics are out of sync?

Sometimes after manipulating glyphs and layers via scripting, Glyphs thinks the metrics are in sync when in fact they are not.

For example, in this /e glyph, the leftmost point is at X 24, and therefore the left side bearing is 24, but the UI and API are both incorrectly showing the LSB as 45.
image

In some cases I would like to just correct it with syncMetrics(), but this does nothing because Glyphs thinks the metrics are already synced.

The best solution I have right now is adding something temporary to the layer and then removing it, like this:

def notifyMetrics(layer):
  '''
  Tell Glyphs to re-check whether metrics keys are in sync.
  (I can't find a less ugly way of doing this!)
  '''
  shape = GSComponent()
  layer.shapes.append(shape)
  layer.shapes.remove(shape)

There must be a better way?

1 Like

It should be

layer.setNeedUpdateMetrics()

Thanks! I thought there might be an already existing method for this.