varLib: use vmtx to compute phantom pts; fix sign of bottomSideY

when 'vmtx' is present in a font, use that to compute the third and fourth 'phantom points'.
When not present, we use the glyph bbox yMax and yMin coords.

NOTE that previously the bottomSideY was incorrectly set to -glyph.yMin (with a minus sign).
However, the minus is not needed when we use the bbox.
Positive vertical advance grows towards negative Y axis.
This commit is contained in:
Cosimo Lupo 2019-03-04 18:33:23 -08:00
parent 3de9e2978c
commit 52ec934a02

View File

@ -233,9 +233,13 @@ def _GetCoordinates(font, glyphName):
glyph.recalcBounds(glyf)
leftSideX = glyph.xMin - leftSideBearing
rightSideX = leftSideX + horizontalAdvanceWidth
# XXX these are incorrect. Load vmtx and fix.
if "vmtx" in font:
verticalAdvanceWidth, topSideBearing = font["vmtx"].metrics[glyphName]
topSideY = topSideBearing + glyph.yMax
bottomSideY = topSideY - verticalAdvanceWidth
else:
topSideY = glyph.yMax
bottomSideY = -glyph.yMin
bottomSideY = glyph.yMin
coord = coord.copy()
coord.extend([(leftSideX, 0),
(rightSideX, 0),