_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:
parent
97e626b23e
commit
1ca554332c
@ -369,7 +369,9 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
|||||||
(0, bottomSideY),
|
(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.
|
"""Return glyph coordinates and controls as expected by "gvar" table.
|
||||||
|
|
||||||
The coordinates includes four "phantom points" for the glyph metrics,
|
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.
|
# Add phantom points for (left, right, top, bottom) positions.
|
||||||
phantomPoints = self._getPhantomPoints(glyphName, hMetrics, vMetrics)
|
phantomPoints = self._getPhantomPoints(glyphName, hMetrics, vMetrics)
|
||||||
coords.extend(phantomPoints)
|
coords.extend(phantomPoints)
|
||||||
|
if roundCoordinates:
|
||||||
|
coords.toInt()
|
||||||
return coords, controls
|
return coords, controls
|
||||||
|
|
||||||
def _setCoordinates(self, glyphName, coord, hMetrics, vMetrics=None):
|
def _setCoordinates(self, glyphName, coord, hMetrics, vMetrics=None):
|
||||||
|
@ -51,8 +51,15 @@ def fvarAxes():
|
|||||||
def _get_coordinates(varfont, glyphname):
|
def _get_coordinates(varfont, glyphname):
|
||||||
# converts GlyphCoordinates to a list of (x, y) tuples, so that pytest's
|
# converts GlyphCoordinates to a list of (x, y) tuples, so that pytest's
|
||||||
# assert will give us a nicer diff
|
# assert will give us a nicer diff
|
||||||
with pytest.deprecated_call():
|
return list(
|
||||||
return list(varfont["glyf"].getCoordinatesAndControls(glyphname, varfont)[0])
|
varfont["glyf"]._getCoordinatesAndControls(
|
||||||
|
glyphname,
|
||||||
|
varfont["hmtx"].metrics,
|
||||||
|
varfont["vmtx"].metrics,
|
||||||
|
# the tests expect float coordinates
|
||||||
|
roundCoordinates=False,
|
||||||
|
)[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class InstantiateGvarTest(object):
|
class InstantiateGvarTest(object):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user