Metric keys for decomposed prebuilt fractions

If I decompose fractions automatically composed with components, they helpfully try to set up the proper keys for metrics, but I find that both LSB and RSB are keyed to the numerator. For example decomposing /onethird produced a LSB of =one.numr and a RSB of =one.numr. It would be more sensible, if possible, to have the RSB be set to =three.dnom.

I’ll have a look.

Why do you decompose them?

Because I didn’t want to kern numerators and denominators so that they would remain tabular, but I figured if I decompose the prebuilt ones I could nudge the fraction bar left or right to try to even out the spacing (keeping the overall advance width).
Are there better solutions for retaining tabular widths but adjusting kerning?

Is this a monospace font?

No, I was just following advice I found here.
I did note that the Glyphs fraction tutorial doesn’t bother with tabularity. Maybe I should let that go. Doing so would allow me not only to kern the numr/dnom figs against each other and the fraction bar, but also use proportional figs as the basis for numr/dnoms instead of .tf’s.

It never occurred to me that they might be tabular. But I can see the it could be useful.

You can add correction metrics keys to fix the width after you kerned them. So if the glyph is 20 units to small, add =+10 on both sides. And that could be automatically set by a script.

So. Decomposing is almost always not what you want.

That’s probably a better way to go, thanks.

Looking better. After turning off the auto alignment, I found this script worked for padding the glyphs to a tabular width:


figureWidth = 550
targetWidth = figureWidth * 1.5

for layer in myLayers:
	unitsToAdd = targetWidth - layer.width
	halfToAdd = round(unitsToAdd / 2)
	currentLeftKey = layer.parent.leftMetricsKey
	currentRightKey = layer.parent.rightMetricsKey
	layer.leftMetricsKey = "==" + currentLeftKey + "+" + str(halfToAdd)
	layer.rightMetricsKey = "==" + currentRightKey + "+" + str(unitsToAdd - halfToAdd)

But returning to my initial issue, I do find that disabling auto-alignment on the prebuilt fractions results in the same problem even if I’m not decomposing them. That is, /onethird gets a RSB of =one.numr (instead of =three.dnom) upon disabling alignment.

You can leave the auto-aligment on and still add metrics keys in the format I showed earlier.

Ah, okay, so I can dump the references to currentLeftKey and currentRightKey in the script then, as well as the syncs.

layer.leftMetricsKey = "==+" + str(halfToAdd)
layer.rightMetricsKey = "==+" + str(unitsToAdd - halfToAdd)

in the script now works. Thanks.

If you need to run the script later, you might need to check the existing metrics keys and add them to the equation.

1 Like