Find/replace side bearing formulas?

I would find it useful to have an option or tool that would let me replace suffixes in sidebearing references when I replace them in glyph names. For example if I’ve made small caps from my regular caps, I want the left sidebearing of C.c2sc to be set to O.c2sc, not O. Is there a way to automate the process of changing those?

This is probably best done with a script.

Paging Dr. Mekkablue…

I tried but neither of these methods seem to have a lasting effect on the metrics key:

g.setRightMetricsKey_( “=X” )
g.rightMetricsKey = “=X”

I can read out g.rightMetricsKey right afterwards, and it will yield “=X”. But in the GUI, there is no change, and ctrl-cmd-M will use the original value.

Oh, now I get it, the metrics keys that count seem to be on the layer level. Will try again.

eliason
There is a new script “Find and Replace in Metrics Keys” in my GitHub repository. You’ll find it in the Metrics subfolder.

The metrics key is stored in the glyph or the layer. this makes it a bit tricky.

The script now focusses on the layer. Setting the key on the glyph level produced no visible result. But I only tested with single-layer font, I must admit.

If the layer has a key, the key of the glyph is not visible.