From 52ec934a021122bc6c6f8d244a46132d0199eff6 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 4 Mar 2019 18:33:23 -0800 Subject: [PATCH] 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. --- Lib/fontTools/varLib/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/varLib/__init__.py b/Lib/fontTools/varLib/__init__.py index 6e534ea0c..9fe2e531b 100644 --- a/Lib/fontTools/varLib/__init__.py +++ b/Lib/fontTools/varLib/__init__.py @@ -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. - topSideY = glyph.yMax - bottomSideY = -glyph.yMin + if "vmtx" in font: + verticalAdvanceWidth, topSideBearing = font["vmtx"].metrics[glyphName] + topSideY = topSideBearing + glyph.yMax + bottomSideY = topSideY - verticalAdvanceWidth + else: + topSideY = glyph.yMax + bottomSideY = glyph.yMin coord = coord.copy() coord.extend([(leftSideX, 0), (rightSideX, 0),