_getCoordinatesAndControls: make sure coords are rounded toInt() as gvar expects

ufo2ft will no longer send varLib already-rounded master glyf tables (to give it an opportunity to compute implied oncurves on the pre-rounded coords) so when retrieving coordinates off the glyf table in order to compute gvar deltas we have to round
This commit is contained in:
Cosimo Lupo 2023-06-07 18:05:48 +01:00
parent 97e626b23e
commit 1ca554332c
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8
2 changed files with 14 additions and 3 deletions

View File

@ -369,7 +369,9 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
(0, bottomSideY),
]
def _getCoordinatesAndControls(self, glyphName, hMetrics, vMetrics=None):
def _getCoordinatesAndControls(
self, glyphName, hMetrics, vMetrics=None, roundCoordinates=True
):
"""Return glyph coordinates and controls as expected by "gvar" table.
The coordinates includes four "phantom points" for the glyph metrics,
@ -442,6 +444,8 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
# Add phantom points for (left, right, top, bottom) positions.
phantomPoints = self._getPhantomPoints(glyphName, hMetrics, vMetrics)
coords.extend(phantomPoints)
if roundCoordinates:
coords.toInt()
return coords, controls
def _setCoordinates(self, glyphName, coord, hMetrics, vMetrics=None):

View File

@ -51,8 +51,15 @@ def fvarAxes():
def _get_coordinates(varfont, glyphname):
# converts GlyphCoordinates to a list of (x, y) tuples, so that pytest's
# assert will give us a nicer diff
with pytest.deprecated_call():
return list(varfont["glyf"].getCoordinatesAndControls(glyphname, varfont)[0])
return list(
varfont["glyf"]._getCoordinatesAndControls(
glyphname,
varfont["hmtx"].metrics,
varfont["vmtx"].metrics,
# the tests expect float coordinates
roundCoordinates=False,
)[0]
)
class InstantiateGvarTest(object):