Checking if metric is up to date

Is there a way to check if a sidebearing is updated (see if the value is red)? Do I need to do the math myself?

Also leftMetricsKeyUI (and right) is not always reliable, as it sometimes report just numbers where they need to be auto (n). In other words it’s not good at telling me whether it’s an auto value or not. Run this script for example:

font = Glyphs.font
selectedLayers = font.selectedLayers
for thislayer in selectedLayers:
	g = thislayer.parent
	print g.name
	print "\tLSB"
	for l in g.layers:
		print "\t\t%s: %s" % (l.name, l.leftMetricsKeyUI())
	print "\tRSB"
	for l in g.layers:
		print "\t\t%s: %s" % (l.name, l.leftMetricsKeyUI())
	print

This is a hack I have come up with. The color class used in the UI is different:

reportstring = "Metric Keys not in sync:"
thisFont = Glyphs.font
for g in thisFont.glyphs:
	for l in g.layers:
		if g.leftMetricsKey or l.leftMetricsKey():
			if type(l.leftMetricsKeyColor()) == NSCalibratedRGBColor:
				reportstring += "\n/%s  (%s)" % ( g.name, l.name )
thisFont.newTab(reportstring)

The stupid thing is that this is only available for the LSB. :frowning:

And a kind of slow solution would be to create a copy of the layer, update the metrics of the copy and see if the side bearings have changed.

There is a property leftMetricsKeyIsInSync.

I know, I tried it but never got it to work.
‘NSKVONotifying_GSLayer’ object has no attribute ‘leftMetricsKeyIsInSync’

try myLayer.leftMetricsKeyIsInSync_(None)

It reports the same as MetricsKeyUI (again, unreliably) and does not tell you if the metrics are out of sync.

The method I suggested will be available in version 2.3.
But both other methods should work. Can you send me a font where is don’t?