fonttools 4.55.5__py3-none-any.whl → 4.55.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fonttools might be problematic. Click here for more details.

fontTools/__init__.py CHANGED
@@ -3,6 +3,6 @@ from fontTools.misc.loggingTools import configLogger
3
3
 
4
4
  log = logging.getLogger(__name__)
5
5
 
6
- version = __version__ = "4.55.5"
6
+ version = __version__ = "4.55.7"
7
7
 
8
8
  __all__ = ["version", "log", "configLogger"]
@@ -1206,9 +1206,7 @@ class Glyph(object):
1206
1206
  Return True if bounds were calculated, False otherwise.
1207
1207
  """
1208
1208
  for compo in self.components:
1209
- if hasattr(compo, "firstPt") or hasattr(compo, "transform"):
1210
- return False
1211
- if not float(compo.x).is_integer() or not float(compo.y).is_integer():
1209
+ if not compo._hasOnlyIntegerTranslate():
1212
1210
  return False
1213
1211
 
1214
1212
  # All components are untransformed and have an integer x/y translate
@@ -1241,7 +1239,7 @@ class Glyph(object):
1241
1239
  else:
1242
1240
  return self.numberOfContours == -1
1243
1241
 
1244
- def getCoordinates(self, glyfTable, round=noRound):
1242
+ def getCoordinates(self, glyfTable, *, round=noRound):
1245
1243
  """Return the coordinates, end points and flags
1246
1244
 
1247
1245
  This method returns three values: A :py:class:`GlyphCoordinates` object,
@@ -1276,7 +1274,18 @@ class Glyph(object):
1276
1274
  % compo.glyphName
1277
1275
  )
1278
1276
  coordinates = GlyphCoordinates(coordinates)
1279
- coordinates.toInt(round=round)
1277
+ # if asked to round e.g. while computing bboxes, it's important we
1278
+ # do it immediately before a component transform is applied to a
1279
+ # simple glyph's coordinates in case these might still contain floats;
1280
+ # however, if the referenced component glyph is another composite, we
1281
+ # must not round here but only at the end, after all the nested
1282
+ # transforms have been applied, or else rounding errors will compound.
1283
+ if (
1284
+ round is not noRound
1285
+ and g.numberOfContours > 0
1286
+ and not compo._hasOnlyIntegerTranslate()
1287
+ ):
1288
+ coordinates.toInt(round=round)
1280
1289
  if hasattr(compo, "firstPt"):
1281
1290
  # component uses two reference points: we apply the transform _before_
1282
1291
  # computing the offset between the points
@@ -1933,6 +1942,18 @@ class GlyphComponent(object):
1933
1942
  result = self.__eq__(other)
1934
1943
  return result if result is NotImplemented else not result
1935
1944
 
1945
+ def _hasOnlyIntegerTranslate(self):
1946
+ """Return True if it's a 'simple' component.
1947
+
1948
+ That is, it has no anchor points and no transform other than integer translate.
1949
+ """
1950
+ return (
1951
+ not hasattr(self, "firstPt")
1952
+ and not hasattr(self, "transform")
1953
+ and float(self.x).is_integer()
1954
+ and float(self.y).is_integer()
1955
+ )
1956
+
1936
1957
 
1937
1958
  class GlyphCoordinates(object):
1938
1959
  """A list of glyph coordinates.