fonttools 4.55.4__cp312-cp312-macosx_10_13_x86_64.whl → 4.55.7__cp312-cp312-macosx_10_13_x86_64.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.4"
6
+ version = __version__ = "4.55.7"
7
7
 
8
8
  __all__ = ["version", "log", "configLogger"]
Binary file
@@ -1106,7 +1106,13 @@ class Builder(object):
1106
1106
  if (language == "dflt" or include_default) and lookups:
1107
1107
  self.features_[key] = lookups[:]
1108
1108
  else:
1109
- self.features_[key] = []
1109
+ # if we aren't including default we need to manually remove the
1110
+ # default lookups, which were added to all declared langsystems
1111
+ # as they were encountered (we don't remove all lookups because
1112
+ # we want to allow duplicate script/lang statements;
1113
+ # see https://github.com/fonttools/fonttools/issues/3748
1114
+ cur_lookups = self.features_.get(key, [])
1115
+ self.features_[key] = [x for x in cur_lookups if x not in lookups]
1110
1116
  self.language_systems = frozenset([(self.script_, language)])
1111
1117
 
1112
1118
  if required:
Binary file
@@ -1187,7 +1187,7 @@ class Glyph(object):
1187
1187
  ):
1188
1188
  return
1189
1189
  try:
1190
- coords, endPts, flags = self.getCoordinates(glyfTable)
1190
+ coords, endPts, flags = self.getCoordinates(glyfTable, round=otRound)
1191
1191
  self.xMin, self.yMin, self.xMax, self.yMax = coords.calcIntBounds()
1192
1192
  except NotImplementedError:
1193
1193
  pass
@@ -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):
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,
@@ -1267,13 +1265,27 @@ class Glyph(object):
1267
1265
  for compo in self.components:
1268
1266
  g = glyfTable[compo.glyphName]
1269
1267
  try:
1270
- coordinates, endPts, flags = g.getCoordinates(glyfTable)
1268
+ coordinates, endPts, flags = g.getCoordinates(
1269
+ glyfTable, round=round
1270
+ )
1271
1271
  except RecursionError:
1272
1272
  raise ttLib.TTLibError(
1273
1273
  "glyph '%s' contains a recursive component reference"
1274
1274
  % compo.glyphName
1275
1275
  )
1276
1276
  coordinates = GlyphCoordinates(coordinates)
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)
1277
1289
  if hasattr(compo, "firstPt"):
1278
1290
  # component uses two reference points: we apply the transform _before_
1279
1291
  # computing the offset between the points
@@ -1930,6 +1942,18 @@ class GlyphComponent(object):
1930
1942
  result = self.__eq__(other)
1931
1943
  return result if result is NotImplemented else not result
1932
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
+
1933
1957
 
1934
1958
  class GlyphCoordinates(object):
1935
1959
  """A list of glyph coordinates.
Binary file