Closed madig closed 3 years ago
Glyphs is generating a NSBezierPath from the layer and then back-slants it on the half x-height. Then measures the bounding box of that NSBezierpath.
"Generates a NSBezierPath" as in it applies a negative angle skew transformation with origin = xheight / 2 to the layer contents? And how does it take an italic side-bearing like 11
and transform it into -62
? Back-slant, apply side-bearing, forward-slant, use new side-bearing?
It doesn't deal with the none slanted sidebearing at all. All operations work on the UI value.
Ok thanks. Figured it out. Code follows once I am ready for a PR.
I'm looking at breaking up the code and making a neat copy of the core algorithm, to make it work on UFOs and provide a better base for editor-specific scripts. I'm running into trouble with italic fonts; the final side-bearings produced by the algorithm seem to be made specifically for Glyphs.app's automatic value conversion when dealing with italic fonts.
From what I can glean, Glyphs.app (and optionally FontLab 7) measures italic side-bearings from
y = xHeight / 2
with a measurement line following the italic angle instead ofy = 0
and a straight-up line like in non-italic fonts.The
-11
and10
values are what come out of HT Letterspacer. There is no such standardized italic side-bearings measuring in the UFO world, so I need to de-italicize these values to arrive at:I think there are two options here:
So far, I have failed at both. The former because I can't find a calculation that spits out what Glyphs.app does and the latter because taking out all the
(slant|deSlant)
calls from the code doesn't actually do much because the side-bearing computation seems to be independent of the angle anyway?!Halp!