Glyphs-Scripts icon indicating copy to clipboard operation
Glyphs-Scripts copied to clipboard

"Change Metrics by Percentage" – make it work when glyphs are used as components, without anchor attachment

Open arrowtype opened this issue 8 months ago • 0 comments

Problem

"Change Metrics by Percentage" and "Adjust Sidebearings" break alignment on glyphs that use a base glyph as a component, plus a drawn contour.

For example, both scripts have a problem here:

Image Image

I want to start by saying that I didn’t draw this font, and I think it’s a bit of a surprising specific example to see an /h drawn with an /n component plus a rectangle contour. Still, I do sometimes mix components and drawn contours, in glyphs such as /hbar (/h component, drawn bar), and it’s probably a relatively common practice.

Basically, the /n glyph gets updated spacing, it also moves over as a component in /h, misaligning it from the ascender rectangle.

Proposed potential solution

This PR updates "Change Metrics by Percentage" to find where a layer is referenced, and adjusts that component positioning to account for sidebearing changes to the parent.

It also looks for reflected components and reverses the positioning adjustment, in cases such as a /p being used for the /q, and the /q being used in /qhook.

image

Current problems

This script is much slower than the original, because it loops over the full font many times. It takes maybe 10 seconds to run on 850 glyphs. So, it could probably be much more efficient.

This script probably doesn’t solve for RTL scripts well, as it only adjusts components based on LSB changes.

This PR only changes "Change Metrics by Percentage", but the problem also exists in "Adjust Sidebearings," which is probably more widely used. (I certainly use it more often.)

Why I’m submitting this PR

I’m mostly submitting this as something of a more direct issue report. I’m also partly submitting it as a way to track the version of the script I used in a current particular project.

I will try to improve this further, if time or necessity permits. Also, though, I very much welcome edits by maintainers. Or, if it’s obvious to you how to correct for this, without this PR, I am happy for this PR to be closed in favor of a faster change.

Thanks so much!

arrowtype avatar May 15 '25 16:05 arrowtype