summaryrefslogtreecommitdiffstats
path: root/contrib/python/fonttools
diff options
context:
space:
mode:
authorAlexander Smirnov <[email protected]>2025-02-06 12:45:05 +0000
committerAlexander Smirnov <[email protected]>2025-02-06 12:45:05 +0000
commit877eef3e6cb697bdc2fa280c8a87a65a9ed98d51 (patch)
tree1e9a34db7a9b777ea1cbfcb071009da9da1232d7 /contrib/python/fonttools
parent60b0993921e4b80febdd8b09dee27c04484f18f3 (diff)
parent25f0f292fefc390b49ac937c2e2326fb576b62c2 (diff)
Merge pull request #14243 from ydb-platform/merge-libs-250206-0050
Diffstat (limited to 'contrib/python/fonttools')
-rw-r--r--contrib/python/fonttools/.dist-info/METADATA25
-rw-r--r--contrib/python/fonttools/fontTools/__init__.py2
-rw-r--r--contrib/python/fonttools/fontTools/feaLib/ast.py4
-rw-r--r--contrib/python/fonttools/fontTools/misc/bezierTools.py9
-rw-r--r--contrib/python/fonttools/fontTools/misc/transform.py28
-rw-r--r--contrib/python/fonttools/fontTools/pens/statisticsPen.py5
-rw-r--r--contrib/python/fonttools/fontTools/ttLib/tables/_n_a_m_e.py18
-rw-r--r--contrib/python/fonttools/ya.make2
8 files changed, 56 insertions, 37 deletions
diff --git a/contrib/python/fonttools/.dist-info/METADATA b/contrib/python/fonttools/.dist-info/METADATA
index ca6f7ccb089..931191c2892 100644
--- a/contrib/python/fonttools/.dist-info/METADATA
+++ b/contrib/python/fonttools/.dist-info/METADATA
@@ -1,6 +1,6 @@
-Metadata-Version: 2.1
+Metadata-Version: 2.2
Name: fonttools
-Version: 4.55.3
+Version: 4.55.4
Summary: Tools to manipulate font files
Home-page: http://github.com/fonttools/fonttools
Author: Just van Rossum
@@ -72,6 +72,18 @@ Requires-Dist: sympy; extra == "all"
Requires-Dist: xattr; sys_platform == "darwin" and extra == "all"
Requires-Dist: skia-pathops>=0.5.0; extra == "all"
Requires-Dist: uharfbuzz>=0.23.0; extra == "all"
+Dynamic: author
+Dynamic: author-email
+Dynamic: classifier
+Dynamic: description
+Dynamic: home-page
+Dynamic: license
+Dynamic: maintainer
+Dynamic: maintainer-email
+Dynamic: platform
+Dynamic: provides-extra
+Dynamic: requires-python
+Dynamic: summary
|CI Build Status| |Coverage Status| |PyPI| |Gitter Chat|
@@ -377,9 +389,15 @@ Have fun!
Changelog
~~~~~~~~~
-4.55.3 (released 2024-12-10)
+4.55.4 (released 2025-01-21)
----------------------------
+- [bezierTools] Fixed ``splitCubicAtT`` sometimes not returning identical start/end points as result of numerical precision (#3742, #3743).
+- [feaLib/ast] Fixed docstring of ``AlternateSubstStatement`` (#3735).
+- [transform] Typing fixes (#3734).
+
+4.55.3 (released 2024-12-10)
+----------------------------
- [Docs] fill out ttLib table section [#3716]
- [feaLib] More efficient inline format 4 lookups [#3726]
@@ -403,7 +421,6 @@ Changelog
4.55.0 (released 2024-11-14)
----------------------------
-
- [cffLib.specializer] Adjust stack use calculation (#3689)
- [varLib] Lets not add mac names if the rest of name doesn't have them (#3688)
- [ttLib.reorderGlyphs] Update CFF table charstrings and charset (#3682)
diff --git a/contrib/python/fonttools/fontTools/__init__.py b/contrib/python/fonttools/fontTools/__init__.py
index 0af1b7a5eca..d1af15d948f 100644
--- a/contrib/python/fonttools/fontTools/__init__.py
+++ b/contrib/python/fonttools/fontTools/__init__.py
@@ -3,6 +3,6 @@ from fontTools.misc.loggingTools import configLogger
log = logging.getLogger(__name__)
-version = __version__ = "4.55.3"
+version = __version__ = "4.55.4"
__all__ = ["version", "log", "configLogger"]
diff --git a/contrib/python/fonttools/fontTools/feaLib/ast.py b/contrib/python/fonttools/fontTools/feaLib/ast.py
index 17c6cc3fbe4..b9bab88ef23 100644
--- a/contrib/python/fonttools/fontTools/feaLib/ast.py
+++ b/contrib/python/fonttools/fontTools/feaLib/ast.py
@@ -595,8 +595,8 @@ class MarkClassDefinition(Statement):
class AlternateSubstStatement(Statement):
"""A ``sub ... from ...`` statement.
- ``prefix``, ``glyph``, ``suffix`` and ``replacement`` should be lists of
- `glyph-containing objects`_. ``glyph`` should be a `one element list`."""
+ ``glyph`` and ``replacement`` should be `glyph-containing objects`_.
+ ``prefix`` and ``suffix`` should be lists of `glyph-containing objects`_."""
def __init__(self, prefix, glyph, suffix, replacement, location=None):
Statement.__init__(self, location)
diff --git a/contrib/python/fonttools/fontTools/misc/bezierTools.py b/contrib/python/fonttools/fontTools/misc/bezierTools.py
index 1b37ade8d67..2021f244370 100644
--- a/contrib/python/fonttools/fontTools/misc/bezierTools.py
+++ b/contrib/python/fonttools/fontTools/misc/bezierTools.py
@@ -631,7 +631,14 @@ def splitCubicAtT(pt1, pt2, pt3, pt4, *ts):
((77.3438, 56.25), (85.9375, 43.75), (93.75, 25), (100, 0))
"""
a, b, c, d = calcCubicParameters(pt1, pt2, pt3, pt4)
- return _splitCubicAtT(a, b, c, d, *ts)
+ split = _splitCubicAtT(a, b, c, d, *ts)
+
+ # the split impl can introduce floating point errors; we know the first
+ # segment should always start at pt1 and the last segment should end at pt4,
+ # so we set those values directly before returning.
+ split[0] = (pt1, *split[0][1:])
+ split[-1] = (*split[-1][:-1], pt4)
+ return split
@cython.locals(
diff --git a/contrib/python/fonttools/fontTools/misc/transform.py b/contrib/python/fonttools/fontTools/misc/transform.py
index 2f4a216fa69..aeacc30fcb1 100644
--- a/contrib/python/fonttools/fontTools/misc/transform.py
+++ b/contrib/python/fonttools/fontTools/misc/transform.py
@@ -52,6 +52,8 @@ translate, rotation, scale, skew, and transformation-center components.
>>>
"""
+from __future__ import annotations
+
import math
from typing import NamedTuple
from dataclasses import dataclass
@@ -65,7 +67,7 @@ _ONE_EPSILON = 1 - _EPSILON
_MINUS_ONE_EPSILON = -1 + _EPSILON
-def _normSinCos(v):
+def _normSinCos(v: float) -> float:
if abs(v) < _EPSILON:
v = 0
elif v > _ONE_EPSILON:
@@ -214,7 +216,7 @@ class Transform(NamedTuple):
xx, xy, yx, yy = self[:4]
return [(xx * dx + yx * dy, xy * dx + yy * dy) for dx, dy in vectors]
- def translate(self, x=0, y=0):
+ def translate(self, x: float = 0, y: float = 0):
"""Return a new transformation, translated (offset) by x, y.
:Example:
@@ -225,7 +227,7 @@ class Transform(NamedTuple):
"""
return self.transform((1, 0, 0, 1, x, y))
- def scale(self, x=1, y=None):
+ def scale(self, x: float = 1, y: float | None = None):
"""Return a new transformation, scaled by x, y. The 'y' argument
may be None, which implies to use the x value for y as well.
@@ -241,7 +243,7 @@ class Transform(NamedTuple):
y = x
return self.transform((x, 0, 0, y, 0, 0))
- def rotate(self, angle):
+ def rotate(self, angle: float):
"""Return a new transformation, rotated by 'angle' (radians).
:Example:
@@ -251,13 +253,11 @@ class Transform(NamedTuple):
<Transform [0 1 -1 0 0 0]>
>>>
"""
- import math
-
c = _normSinCos(math.cos(angle))
s = _normSinCos(math.sin(angle))
return self.transform((c, s, -s, c, 0, 0))
- def skew(self, x=0, y=0):
+ def skew(self, x: float = 0, y: float = 0):
"""Return a new transformation, skewed by x and y.
:Example:
@@ -267,8 +267,6 @@ class Transform(NamedTuple):
<Transform [1 0 1 1 0 0]>
>>>
"""
- import math
-
return self.transform((1, math.tan(y), math.tan(x), 1, 0, 0))
def transform(self, other):
@@ -336,7 +334,7 @@ class Transform(NamedTuple):
dx, dy = -xx * dx - yx * dy, -xy * dx - yy * dy
return self.__class__(xx, xy, yx, yy, dx, dy)
- def toPS(self):
+ def toPS(self) -> str:
"""Return a PostScript representation
:Example:
@@ -352,7 +350,7 @@ class Transform(NamedTuple):
"""Decompose into a DecomposedTransform."""
return DecomposedTransform.fromTransform(self)
- def __bool__(self):
+ def __bool__(self) -> bool:
"""Returns True if transform is not identity, False otherwise.
:Example:
@@ -374,14 +372,14 @@ class Transform(NamedTuple):
"""
return self != Identity
- def __repr__(self):
+ def __repr__(self) -> str:
return "<%s [%g %g %g %g %g %g]>" % ((self.__class__.__name__,) + self)
Identity = Transform()
-def Offset(x=0, y=0):
+def Offset(x: float = 0, y: float = 0) -> Transform:
"""Return the identity transformation offset by x, y.
:Example:
@@ -392,7 +390,7 @@ def Offset(x=0, y=0):
return Transform(1, 0, 0, 1, x, y)
-def Scale(x, y=None):
+def Scale(x: float, y: float | None = None) -> Transform:
"""Return the identity transformation scaled by x, y. The 'y' argument
may be None, which implies to use the x value for y as well.
@@ -492,7 +490,7 @@ class DecomposedTransform:
0,
)
- def toTransform(self):
+ def toTransform(self) -> Transform:
"""Return the Transform() equivalent of this transformation.
:Example:
diff --git a/contrib/python/fonttools/fontTools/pens/statisticsPen.py b/contrib/python/fonttools/fontTools/pens/statisticsPen.py
index b91d93b6eb6..874a3c5b8d9 100644
--- a/contrib/python/fonttools/fontTools/pens/statisticsPen.py
+++ b/contrib/python/fonttools/fontTools/pens/statisticsPen.py
@@ -106,6 +106,7 @@ class StatisticsControlPen(StatisticsBase, BasePen):
def _moveTo(self, pt):
self._nodes.append(complex(*pt))
+ self._startPoint = pt
def _lineTo(self, pt):
self._nodes.append(complex(*pt))
@@ -119,12 +120,16 @@ class StatisticsControlPen(StatisticsBase, BasePen):
self._nodes.append(complex(*pt))
def _closePath(self):
+ p0 = self._getCurrentPoint()
+ if p0 != self._startPoint:
+ self._lineTo(self._startPoint)
self._update()
def _endPath(self):
p0 = self._getCurrentPoint()
if p0 != self._startPoint:
raise OpenContourError("Glyph statistics not defined on open contours.")
+ self._update()
def _update(self):
nodes = self._nodes
diff --git a/contrib/python/fonttools/fontTools/ttLib/tables/_n_a_m_e.py b/contrib/python/fonttools/fontTools/ttLib/tables/_n_a_m_e.py
index 3fd1cdb4834..31653f08eca 100644
--- a/contrib/python/fonttools/fontTools/ttLib/tables/_n_a_m_e.py
+++ b/contrib/python/fonttools/fontTools/ttLib/tables/_n_a_m_e.py
@@ -48,6 +48,10 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
dependencies = ["ltag"]
+ def __init__(self, tag=None):
+ super().__init__(tag)
+ self.names = []
+
def decompile(self, data, ttFont):
format, n, stringOffset = struct.unpack(b">HHH", data[:6])
expectedStringOffset = 6 + n * nameRecordSize
@@ -78,10 +82,6 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
self.names.append(name)
def compile(self, ttFont):
- if not hasattr(self, "names"):
- # only happens when there are NO name table entries read
- # from the TTX file
- self.names = []
names = self.names
names.sort() # sort according to the spec; see NameRecord.__lt__()
stringData = b""
@@ -108,8 +108,6 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
def fromXML(self, name, attrs, content, ttFont):
if name != "namerecord":
return # ignore unknown tags
- if not hasattr(self, "names"):
- self.names = []
name = NameRecord()
self.names.append(name)
name.fromXML(name, attrs, content, ttFont)
@@ -194,8 +192,6 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
identified by the (platformID, platEncID, langID) triplet. A warning is issued
to prevent unexpected results.
"""
- if not hasattr(self, "names"):
- self.names = []
if not isinstance(string, str):
if isinstance(string, bytes):
log.warning(
@@ -262,7 +258,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
The nameID is assigned in the range between 'minNameID' and 32767 (inclusive),
following the last nameID in the name table.
"""
- names = getattr(self, "names", [])
+ names = self.names
nameID = 1 + max([n.nameID for n in names] + [minNameID - 1])
if nameID > 32767:
raise ValueError("nameID must be less than 32768")
@@ -359,8 +355,6 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
If the 'nameID' argument is None, the created nameID will not
be less than the 'minNameID' argument.
"""
- if not hasattr(self, "names"):
- self.names = []
if nameID is None:
# Reuse nameID if possible
nameID = self.findMultilingualName(
@@ -404,8 +398,6 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
assert (
len(platforms) > 0
), "'platforms' must contain at least one (platformID, platEncID, langID) tuple"
- if not hasattr(self, "names"):
- self.names = []
if not isinstance(string, str):
raise TypeError(
"expected str, found %s: %r" % (type(string).__name__, string)
diff --git a/contrib/python/fonttools/ya.make b/contrib/python/fonttools/ya.make
index a5f677fa7df..461b5646645 100644
--- a/contrib/python/fonttools/ya.make
+++ b/contrib/python/fonttools/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(4.55.3)
+VERSION(4.55.4)
LICENSE(MIT)