diff --git a/Doc/docs-requirements.txt b/Doc/docs-requirements.txt index 9e7fd9101..ad3ad76cc 100644 --- a/Doc/docs-requirements.txt +++ b/Doc/docs-requirements.txt @@ -1,4 +1,4 @@ sphinx==7.2.6 sphinx_rtd_theme==2.0.0 -reportlab==4.0.8 +reportlab==4.0.9 freetype-py==2.4.0 diff --git a/Lib/fontTools/afmLib.py b/Lib/fontTools/afmLib.py index e89646951..0aabf7f63 100644 --- a/Lib/fontTools/afmLib.py +++ b/Lib/fontTools/afmLib.py @@ -45,7 +45,6 @@ Here is an example of using `afmLib` to read, modify and write an AFM file: """ - import re # every single line starts with a "word" diff --git a/Lib/fontTools/cffLib/__init__.py b/Lib/fontTools/cffLib/__init__.py index 644508c15..0ad41c567 100644 --- a/Lib/fontTools/cffLib/__init__.py +++ b/Lib/fontTools/cffLib/__init__.py @@ -2880,7 +2880,6 @@ class PrivateDict(BaseDict): class IndexedStrings(object): - """SID -> string mapping.""" def __init__(self, file=None): diff --git a/Lib/fontTools/colorLib/builder.py b/Lib/fontTools/colorLib/builder.py index 442bc20e4..6e45e7a88 100644 --- a/Lib/fontTools/colorLib/builder.py +++ b/Lib/fontTools/colorLib/builder.py @@ -2,6 +2,7 @@ colorLib.builder: Build COLR/CPAL tables from scratch """ + import collections import copy import enum @@ -298,11 +299,15 @@ def buildPaletteLabels( labels: Iterable[_OptionalLocalizedString], nameTable: _n_a_m_e.table__n_a_m_e ) -> List[Optional[int]]: return [ - nameTable.addMultilingualName(l, mac=False) - if isinstance(l, dict) - else C_P_A_L_.table_C_P_A_L_.NO_NAME_ID - if l is None - else nameTable.addMultilingualName({"en": l}, mac=False) + ( + nameTable.addMultilingualName(l, mac=False) + if isinstance(l, dict) + else ( + C_P_A_L_.table_C_P_A_L_.NO_NAME_ID + if l is None + else nameTable.addMultilingualName({"en": l}, mac=False) + ) + ) for l in labels ] diff --git a/Lib/fontTools/config/__init__.py b/Lib/fontTools/config/__init__.py index c106fe51f..41ab8f758 100644 --- a/Lib/fontTools/config/__init__.py +++ b/Lib/fontTools/config/__init__.py @@ -6,6 +6,7 @@ etc. If this file gets too big, split it into smaller files per-module. An instance of the Config class can be attached to a TTFont object, so that the various modules can access their configuration options from it. """ + from textwrap import dedent from fontTools.misc.configTools import * diff --git a/Lib/fontTools/designspaceLib/__init__.py b/Lib/fontTools/designspaceLib/__init__.py index d6789f5f6..342f1decd 100644 --- a/Lib/fontTools/designspaceLib/__init__.py +++ b/Lib/fontTools/designspaceLib/__init__.py @@ -1434,9 +1434,9 @@ class BaseDocWriter(object): ): axesElement = ET.Element("axes") if self.documentObject.elidedFallbackName is not None: - axesElement.attrib[ - "elidedfallbackname" - ] = self.documentObject.elidedFallbackName + axesElement.attrib["elidedfallbackname"] = ( + self.documentObject.elidedFallbackName + ) self.root.append(axesElement) for axisObject in self.documentObject.axes: self._addAxis(axisObject) @@ -1776,17 +1776,17 @@ class BaseDocWriter(object): if instanceObject.filename is not None: instanceElement.attrib["filename"] = instanceObject.filename if instanceObject.postScriptFontName is not None: - instanceElement.attrib[ - "postscriptfontname" - ] = instanceObject.postScriptFontName + instanceElement.attrib["postscriptfontname"] = ( + instanceObject.postScriptFontName + ) if instanceObject.styleMapFamilyName is not None: - instanceElement.attrib[ - "stylemapfamilyname" - ] = instanceObject.styleMapFamilyName + instanceElement.attrib["stylemapfamilyname"] = ( + instanceObject.styleMapFamilyName + ) if instanceObject.styleMapStyleName is not None: - instanceElement.attrib[ - "stylemapstylename" - ] = instanceObject.styleMapStyleName + instanceElement.attrib["stylemapstylename"] = ( + instanceObject.styleMapStyleName + ) if self.effectiveFormatTuple < (5, 0): # Deprecated members as of version 5.0 if instanceObject.glyphs: diff --git a/Lib/fontTools/designspaceLib/statNames.py b/Lib/fontTools/designspaceLib/statNames.py index a164169da..1474e5fcf 100644 --- a/Lib/fontTools/designspaceLib/statNames.py +++ b/Lib/fontTools/designspaceLib/statNames.py @@ -8,6 +8,7 @@ instance: names = getStatNames(doc, instance.getFullUserLocation(doc)) print(names.styleNames) """ + from __future__ import annotations from dataclasses import dataclass diff --git a/Lib/fontTools/merge/layout.py b/Lib/fontTools/merge/layout.py index 6b85cd503..e1b504e61 100644 --- a/Lib/fontTools/merge/layout.py +++ b/Lib/fontTools/merge/layout.py @@ -169,20 +169,16 @@ otTables.BaseTagList.mergeMap = { "BaselineTag": sumLists, } -otTables.GDEF.mergeMap = ( - otTables.GSUB.mergeMap -) = ( - otTables.GPOS.mergeMap -) = otTables.BASE.mergeMap = otTables.JSTF.mergeMap = otTables.MATH.mergeMap = { +otTables.GDEF.mergeMap = otTables.GSUB.mergeMap = otTables.GPOS.mergeMap = ( + otTables.BASE.mergeMap +) = otTables.JSTF.mergeMap = otTables.MATH.mergeMap = { "*": mergeObjects, "Version": max, } -ttLib.getTableClass("GDEF").mergeMap = ttLib.getTableClass( - "GSUB" -).mergeMap = ttLib.getTableClass("GPOS").mergeMap = ttLib.getTableClass( - "BASE" -).mergeMap = ttLib.getTableClass( +ttLib.getTableClass("GDEF").mergeMap = ttLib.getTableClass("GSUB").mergeMap = ( + ttLib.getTableClass("GPOS").mergeMap +) = ttLib.getTableClass("BASE").mergeMap = ttLib.getTableClass( "JSTF" ).mergeMap = ttLib.getTableClass( "MATH" diff --git a/Lib/fontTools/misc/classifyTools.py b/Lib/fontTools/misc/classifyTools.py index 2235bbd7f..aed7ca68c 100644 --- a/Lib/fontTools/misc/classifyTools.py +++ b/Lib/fontTools/misc/classifyTools.py @@ -3,7 +3,6 @@ class Classifier(object): - """ Main Classifier object, used to classify things into similar sets. """ diff --git a/Lib/fontTools/misc/cliTools.py b/Lib/fontTools/misc/cliTools.py index 8322ea9eb..8a64235bf 100644 --- a/Lib/fontTools/misc/cliTools.py +++ b/Lib/fontTools/misc/cliTools.py @@ -1,4 +1,5 @@ """Collection of utilities for command-line interfaces and console scripts.""" + import os import re diff --git a/Lib/fontTools/misc/configTools.py b/Lib/fontTools/misc/configTools.py index 38bbada24..7eb1854fd 100644 --- a/Lib/fontTools/misc/configTools.py +++ b/Lib/fontTools/misc/configTools.py @@ -8,6 +8,7 @@ To create your own config system, you need to create an instance of ``options`` class variable set to your instance of Options. """ + from __future__ import annotations import logging diff --git a/Lib/fontTools/misc/dictTools.py b/Lib/fontTools/misc/dictTools.py index e3c0df735..cd3d394c2 100644 --- a/Lib/fontTools/misc/dictTools.py +++ b/Lib/fontTools/misc/dictTools.py @@ -1,6 +1,5 @@ """Misc dict tools.""" - __all__ = ["hashdict"] diff --git a/Lib/fontTools/misc/etree.py b/Lib/fontTools/misc/etree.py index 9d4a65c36..d0967b5f5 100644 --- a/Lib/fontTools/misc/etree.py +++ b/Lib/fontTools/misc/etree.py @@ -11,6 +11,7 @@ or subclasses built-in ElementTree classes to add features that are only availble in lxml, like OrderedDict for attributes, pretty_print and iterwalk. """ + from fontTools.misc.textTools import tostr diff --git a/Lib/fontTools/misc/filenames.py b/Lib/fontTools/misc/filenames.py index d279f89cc..ddedc5210 100644 --- a/Lib/fontTools/misc/filenames.py +++ b/Lib/fontTools/misc/filenames.py @@ -17,7 +17,6 @@ by Tal Leming and is copyright (c) 2005-2016, The RoboFab Developers: - Just van Rossum """ - illegalCharacters = r"\" * + / : < > ? [ \ ] | \0".split(" ") illegalCharacters += [chr(i) for i in range(1, 32)] illegalCharacters += [chr(0x7F)] diff --git a/Lib/fontTools/misc/textTools.py b/Lib/fontTools/misc/textTools.py index f7ca1acc9..f5484a83a 100644 --- a/Lib/fontTools/misc/textTools.py +++ b/Lib/fontTools/misc/textTools.py @@ -1,6 +1,5 @@ """fontTools.misc.textTools.py -- miscellaneous routines.""" - import ast import string diff --git a/Lib/fontTools/misc/transform.py b/Lib/fontTools/misc/transform.py index f85b54b73..0f9f3a5d8 100644 --- a/Lib/fontTools/misc/transform.py +++ b/Lib/fontTools/misc/transform.py @@ -76,7 +76,6 @@ def _normSinCos(v): class Transform(NamedTuple): - """2x2 transformation matrix plus offset, a.k.a. Affine transform. Transform instances are immutable: all transforming methods, eg. rotate(), return a new Transform instance. diff --git a/Lib/fontTools/misc/vector.py b/Lib/fontTools/misc/vector.py index 666ff15cf..02c62e651 100644 --- a/Lib/fontTools/misc/vector.py +++ b/Lib/fontTools/misc/vector.py @@ -8,7 +8,6 @@ __all__ = ["Vector"] class Vector(tuple): - """A math-like vector. Represents an n-dimensional numeric vector. ``Vector`` objects support diff --git a/Lib/fontTools/pens/basePen.py b/Lib/fontTools/pens/basePen.py index ac8abd40c..5d2cf5032 100644 --- a/Lib/fontTools/pens/basePen.py +++ b/Lib/fontTools/pens/basePen.py @@ -148,7 +148,6 @@ class AbstractPen: class NullPen(AbstractPen): - """A pen that does nothing.""" def moveTo(self, pt): @@ -187,7 +186,6 @@ class MissingComponentError(KeyError): class DecomposingPen(LoggingPen): - """Implements a 'addComponent' method that decomposes components (i.e. draws them onto self as simple contours). It can also be used as a mixin class (e.g. see ContourRecordingPen). @@ -229,7 +227,6 @@ class DecomposingPen(LoggingPen): class BasePen(DecomposingPen): - """Base class for drawing pens. You must override _moveTo, _lineTo and _curveToOne. You may additionally override _closePath, _endPath, addComponent, addVarComponent, and/or _qCurveToOne. You should not diff --git a/Lib/fontTools/pens/boundsPen.py b/Lib/fontTools/pens/boundsPen.py index d833cc89b..c92184413 100644 --- a/Lib/fontTools/pens/boundsPen.py +++ b/Lib/fontTools/pens/boundsPen.py @@ -7,7 +7,6 @@ __all__ = ["BoundsPen", "ControlBoundsPen"] class ControlBoundsPen(BasePen): - """Pen to calculate the "control bounds" of a shape. This is the bounding box of all control points, so may be larger than the actual bounding box if there are curves that don't have points @@ -67,7 +66,6 @@ class ControlBoundsPen(BasePen): class BoundsPen(ControlBoundsPen): - """Pen to calculate the bounds of a shape. It calculates the correct bounds even when the shape contains curves that don't have points on their extremes. This is somewhat slower to compute diff --git a/Lib/fontTools/pens/filterPen.py b/Lib/fontTools/pens/filterPen.py index 81423109a..6c8712c26 100644 --- a/Lib/fontTools/pens/filterPen.py +++ b/Lib/fontTools/pens/filterPen.py @@ -9,7 +9,6 @@ class _PassThruComponentsMixin(object): class FilterPen(_PassThruComponentsMixin, AbstractPen): - """Base class for pens that apply some transformation to the coordinates they receive and pass them to another pen. diff --git a/Lib/fontTools/pens/pointInsidePen.py b/Lib/fontTools/pens/pointInsidePen.py index 8a579ae4c..e1fbbbcb1 100644 --- a/Lib/fontTools/pens/pointInsidePen.py +++ b/Lib/fontTools/pens/pointInsidePen.py @@ -10,7 +10,6 @@ __all__ = ["PointInsidePen"] class PointInsidePen(BasePen): - """This pen implements "point inside" testing: to test whether a given point lies inside the shape (black) or outside (white). Instances of this class can be recycled, as long as the diff --git a/Lib/fontTools/pens/quartzPen.py b/Lib/fontTools/pens/quartzPen.py index 6e1228d6f..2b8a927dc 100644 --- a/Lib/fontTools/pens/quartzPen.py +++ b/Lib/fontTools/pens/quartzPen.py @@ -9,7 +9,6 @@ __all__ = ["QuartzPen"] class QuartzPen(BasePen): - """A pen that creates a CGPath Parameters diff --git a/Lib/fontTools/pens/recordingPen.py b/Lib/fontTools/pens/recordingPen.py index e24b65265..4f44a4d59 100644 --- a/Lib/fontTools/pens/recordingPen.py +++ b/Lib/fontTools/pens/recordingPen.py @@ -1,4 +1,5 @@ """Pen recording operations that can be accessed or replayed.""" + from fontTools.pens.basePen import AbstractPen, DecomposingPen from fontTools.pens.pointPen import AbstractPointPen diff --git a/Lib/fontTools/pens/reportLabPen.py b/Lib/fontTools/pens/reportLabPen.py index 2cb89c8bf..20c9065c7 100644 --- a/Lib/fontTools/pens/reportLabPen.py +++ b/Lib/fontTools/pens/reportLabPen.py @@ -6,7 +6,6 @@ __all__ = ["ReportLabPen"] class ReportLabPen(BasePen): - """A pen for drawing onto a ``reportlab.graphics.shapes.Path`` object.""" def __init__(self, glyphSet, path=None): diff --git a/Lib/fontTools/pens/statisticsPen.py b/Lib/fontTools/pens/statisticsPen.py index 403ef39f9..699b14ca7 100644 --- a/Lib/fontTools/pens/statisticsPen.py +++ b/Lib/fontTools/pens/statisticsPen.py @@ -1,5 +1,6 @@ """Pen calculating area, center of mass, variance and standard-deviation, covariance and correlation, and slant, of glyph shapes.""" + from math import sqrt, degrees, atan from fontTools.pens.basePen import BasePen, OpenContourError from fontTools.pens.momentsPen import MomentsPen @@ -52,7 +53,6 @@ class StatisticsBase: class StatisticsPen(StatisticsBase, MomentsPen): - """Pen calculating area, center of mass, variance and standard-deviation, covariance and correlation, and slant, of glyph shapes. @@ -91,7 +91,6 @@ class StatisticsPen(StatisticsBase, MomentsPen): class StatisticsControlPen(StatisticsBase, BasePen): - """Pen calculating area, center of mass, variance and standard-deviation, covariance and correlation, and slant, of glyph shapes, using the control polygon only. diff --git a/Lib/fontTools/pens/teePen.py b/Lib/fontTools/pens/teePen.py index 2828175a7..939f049b9 100644 --- a/Lib/fontTools/pens/teePen.py +++ b/Lib/fontTools/pens/teePen.py @@ -1,4 +1,5 @@ """Pen multiplexing drawing to one or more pens.""" + from fontTools.pens.basePen import AbstractPen diff --git a/Lib/fontTools/pens/transformPen.py b/Lib/fontTools/pens/transformPen.py index 2e572f612..ff98dbddb 100644 --- a/Lib/fontTools/pens/transformPen.py +++ b/Lib/fontTools/pens/transformPen.py @@ -5,7 +5,6 @@ __all__ = ["TransformPen", "TransformPointPen"] class TransformPen(FilterPen): - """Pen that transforms all coordinates using a Affine transformation, and passes them to another pen. """ diff --git a/Lib/fontTools/svgLib/path/arc.py b/Lib/fontTools/svgLib/path/arc.py index 3e0a211e0..4b2aa5c97 100644 --- a/Lib/fontTools/svgLib/path/arc.py +++ b/Lib/fontTools/svgLib/path/arc.py @@ -4,6 +4,7 @@ The code is mostly adapted from Blink's SVGPathNormalizer::DecomposeArcToCubic https://github.com/chromium/chromium/blob/93831f2/third_party/ blink/renderer/core/svg/svg_path_parser.cc#L169-L278 """ + from fontTools.misc.transform import Identity, Scale from math import atan2, ceil, cos, fabs, isfinite, pi, radians, sin, sqrt, tan diff --git a/Lib/fontTools/t1Lib/__init__.py b/Lib/fontTools/t1Lib/__init__.py index a64f78097..0475881e9 100644 --- a/Lib/fontTools/t1Lib/__init__.py +++ b/Lib/fontTools/t1Lib/__init__.py @@ -15,6 +15,7 @@ write(path, data, kind='OTHER', dohex=False) part should be written as hexadecimal or binary, but only if kind is 'OTHER'. """ + import fontTools from fontTools.misc import eexec from fontTools.misc.macCreatorType import getMacCreatorAndType @@ -49,7 +50,6 @@ class T1Error(Exception): class T1Font(object): - """Type 1 font class. Uses a minimal interpeter that supports just about enough PS to parse diff --git a/Lib/fontTools/ttLib/macUtils.py b/Lib/fontTools/ttLib/macUtils.py index 468a75ad6..0959a6fc2 100644 --- a/Lib/fontTools/ttLib/macUtils.py +++ b/Lib/fontTools/ttLib/macUtils.py @@ -1,4 +1,5 @@ """ttLib.macUtils.py -- Various Mac-specific stuff.""" + from io import BytesIO from fontTools.misc.macRes import ResourceReader, ResourceError @@ -35,7 +36,6 @@ def openTTFonts(path): class SFNTResourceReader(BytesIO): - """Simple read-only file wrapper for 'sfnt' resources.""" def __init__(self, path, res_name_or_index): diff --git a/Lib/fontTools/ttLib/removeOverlaps.py b/Lib/fontTools/ttLib/removeOverlaps.py index 624cd47b4..479532066 100644 --- a/Lib/fontTools/ttLib/removeOverlaps.py +++ b/Lib/fontTools/ttLib/removeOverlaps.py @@ -202,9 +202,11 @@ def removeOverlaps( glyphNames = sorted( glyphNames, key=lambda name: ( - glyfTable[name].getCompositeMaxpValues(glyfTable).maxComponentDepth - if glyfTable[name].isComposite() - else 0, + ( + glyfTable[name].getCompositeMaxpValues(glyfTable).maxComponentDepth + if glyfTable[name].isComposite() + else 0 + ), name, ), ) diff --git a/Lib/fontTools/ttLib/scaleUpem.py b/Lib/fontTools/ttLib/scaleUpem.py index 3f9b22af8..2909bfcb2 100644 --- a/Lib/fontTools/ttLib/scaleUpem.py +++ b/Lib/fontTools/ttLib/scaleUpem.py @@ -3,7 +3,6 @@ AAT and Graphite tables are not supported. CFF/CFF2 fonts are de-subroutinized.""" - from fontTools.ttLib.ttVisitor import TTVisitor import fontTools.ttLib as ttLib import fontTools.ttLib.tables.otBase as otBase diff --git a/Lib/fontTools/ttLib/tables/C_O_L_R_.py b/Lib/fontTools/ttLib/tables/C_O_L_R_.py index 2f03ec054..df857842c 100644 --- a/Lib/fontTools/ttLib/tables/C_O_L_R_.py +++ b/Lib/fontTools/ttLib/tables/C_O_L_R_.py @@ -7,7 +7,6 @@ from . import DefaultTable class table_C_O_L_R_(DefaultTable.DefaultTable): - """This table is structured so that you can treat it like a dictionary keyed by glyph name. ``ttFont['COLR'][]`` will return the color layers for any glyph. diff --git a/Lib/fontTools/ttLib/tables/O_S_2f_2.py b/Lib/fontTools/ttLib/tables/O_S_2f_2.py index edff91f58..0c739bcc4 100644 --- a/Lib/fontTools/ttLib/tables/O_S_2f_2.py +++ b/Lib/fontTools/ttLib/tables/O_S_2f_2.py @@ -113,7 +113,6 @@ OS2_format_5_addition = bigendian + OS2_format_5_addition class table_O_S_2f_2(DefaultTable.DefaultTable): - """the OS/2 table""" dependencies = ["head"] diff --git a/Lib/fontTools/ttLib/tables/T_S_I__0.py b/Lib/fontTools/ttLib/tables/T_S_I__0.py index f15fc67bc..77905822a 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__0.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__0.py @@ -5,6 +5,7 @@ TSI0 is the index table containing the lengths and offsets for the glyph programs and 'extra' programs ('fpgm', 'prep', and 'cvt') that are contained in the TSI1 table. """ + from . import DefaultTable import struct diff --git a/Lib/fontTools/ttLib/tables/T_S_I__1.py b/Lib/fontTools/ttLib/tables/T_S_I__1.py index 55aca3399..a9d04a09b 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__1.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__1.py @@ -4,6 +4,7 @@ tool to store its hinting source data. TSI1 contains the text of the glyph programs in the form of low-level assembly code, as well as the 'extra' programs 'fpgm', 'ppgm' (i.e. 'prep'), and 'cvt'. """ + from . import DefaultTable from fontTools.misc.loggingTools import LogMixin from fontTools.misc.textTools import strjoin, tobytes, tostr diff --git a/Lib/fontTools/ttLib/tables/T_S_I__2.py b/Lib/fontTools/ttLib/tables/T_S_I__2.py index 4278be155..163ef4522 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__2.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__2.py @@ -5,6 +5,7 @@ TSI2 is the index table containing the lengths and offsets for the glyph programs that are contained in the TSI3 table. It uses the same format as the TSI0 table. """ + from fontTools import ttLib superclass = ttLib.getTableClass("TSI0") diff --git a/Lib/fontTools/ttLib/tables/T_S_I__3.py b/Lib/fontTools/ttLib/tables/T_S_I__3.py index 785ca2315..604a7f0be 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__3.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__3.py @@ -3,6 +3,7 @@ tool to store its hinting source data. TSI3 contains the text of the glyph programs in the form of 'VTTTalk' code. """ + from fontTools import ttLib superclass = ttLib.getTableClass("TSI1") diff --git a/Lib/fontTools/ttLib/tables/T_S_I__5.py b/Lib/fontTools/ttLib/tables/T_S_I__5.py index 5edc86a9c..d86798695 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__5.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__5.py @@ -3,6 +3,7 @@ tool to store its hinting source data. TSI5 contains the VTT character groups. """ + from fontTools.misc.textTools import safeEval from . import DefaultTable import sys diff --git a/Lib/fontTools/ttLib/tables/TupleVariation.py b/Lib/fontTools/ttLib/tables/TupleVariation.py index 30d009906..027ac1534 100644 --- a/Lib/fontTools/ttLib/tables/TupleVariation.py +++ b/Lib/fontTools/ttLib/tables/TupleVariation.py @@ -517,22 +517,22 @@ class TupleVariation(object): return # no change coordWidth = self.getCoordWidth() self.coordinates = [ - None - if d is None - else d * scalar - if coordWidth == 1 - else (d[0] * scalar, d[1] * scalar) + ( + None + if d is None + else d * scalar if coordWidth == 1 else (d[0] * scalar, d[1] * scalar) + ) for d in self.coordinates ] def roundDeltas(self): coordWidth = self.getCoordWidth() self.coordinates = [ - None - if d is None - else otRound(d) - if coordWidth == 1 - else (otRound(d[0]), otRound(d[1])) + ( + None + if d is None + else otRound(d) if coordWidth == 1 else (otRound(d[0]), otRound(d[1])) + ) for d in self.coordinates ] diff --git a/Lib/fontTools/ttLib/tables/V_O_R_G_.py b/Lib/fontTools/ttLib/tables/V_O_R_G_.py index 4508c137d..b08737b22 100644 --- a/Lib/fontTools/ttLib/tables/V_O_R_G_.py +++ b/Lib/fontTools/ttLib/tables/V_O_R_G_.py @@ -4,7 +4,6 @@ import struct class table_V_O_R_G_(DefaultTable.DefaultTable): - """This table is structured so that you can treat it like a dictionary keyed by glyph name. ``ttFont['VORG'][]`` will return the vertical origin for any glyph. diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n.py b/Lib/fontTools/ttLib/tables/_k_e_r_n.py index 8f55a311c..270b3b7e4 100644 --- a/Lib/fontTools/ttLib/tables/_k_e_r_n.py +++ b/Lib/fontTools/ttLib/tables/_k_e_r_n.py @@ -147,9 +147,9 @@ class KernTable_format_0(object): except IndexError: # Slower, but will not throw an IndexError on an invalid # glyph id. - kernTable[ - (ttFont.getGlyphName(left), ttFont.getGlyphName(right)) - ] = value + kernTable[(ttFont.getGlyphName(left), ttFont.getGlyphName(right))] = ( + value + ) if len(data) > 6 * nPairs + 4: # Ignore up to 4 bytes excess log.warning( "excess data in 'kern' subtable: %d bytes", len(data) - 6 * nPairs diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index d565603b1..53abd13b4 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -79,7 +79,6 @@ class RepackerState(IntEnum): class BaseTTXConverter(DefaultTable): - """Generic base class for TTX table converters. It functions as an adapter between the TTX (ttLib actually) table model and the model we use for OpenType tables, which is necessarily subtly different. @@ -260,7 +259,6 @@ assert array.array("i").itemsize == 4, "Oops, file a bug against fonttools." class OTTableReader(object): - """Helper class to retrieve data from an OpenType table.""" __slots__ = ("data", "offset", "pos", "localState", "tableTag") @@ -392,7 +390,6 @@ class OffsetToWriter(object): class OTTableWriter(object): - """Helper class to gather and assemble data for OpenType tables.""" def __init__(self, localState=None, tableTag=None): @@ -882,7 +879,6 @@ def packUInt24(value): class BaseTable(object): - """Generic base class for all OpenType (sub)tables.""" def __getattr__(self, attr): @@ -1210,7 +1206,6 @@ class BaseTable(object): class FormatSwitchingBaseTable(BaseTable): - """Minor specialization of BaseTable, for tables that have multiple formats, eg. CoverageFormat1 vs. CoverageFormat2.""" @@ -1335,7 +1330,6 @@ valueRecordFormatDict = _buildDict() class ValueRecordFactory(object): - """Given a format code, this object convert ValueRecords.""" def __init__(self, valueFormat): diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py index 390f1660e..afe4e538f 100644 --- a/Lib/fontTools/ttLib/tables/otConverters.py +++ b/Lib/fontTools/ttLib/tables/otConverters.py @@ -146,7 +146,6 @@ class _LazyList(UserList): class BaseConverter(object): - """Base class for converter objects. Apart from the constructor, this is an abstract class.""" diff --git a/Lib/fontTools/ttLib/tables/otTraverse.py b/Lib/fontTools/ttLib/tables/otTraverse.py index bf22dcfdb..ac9421872 100644 --- a/Lib/fontTools/ttLib/tables/otTraverse.py +++ b/Lib/fontTools/ttLib/tables/otTraverse.py @@ -1,4 +1,5 @@ """Methods for traversing trees of otData-driven OpenType tables.""" + from collections import deque from typing import Callable, Deque, Iterable, List, Optional, Tuple from .otBase import BaseTable diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py index 84aa63f36..32a4ec8b2 100644 --- a/Lib/fontTools/ttLib/tables/ttProgram.py +++ b/Lib/fontTools/ttLib/tables/ttProgram.py @@ -1,4 +1,5 @@ """ttLib.tables.ttProgram.py -- Assembler/disassembler for TrueType bytecode programs.""" + from __future__ import annotations from fontTools.misc.textTools import num2binary, binary2num, readHex, strjoin diff --git a/Lib/fontTools/ttLib/ttCollection.py b/Lib/fontTools/ttLib/ttCollection.py index 70ed4b7a0..f01bc42be 100644 --- a/Lib/fontTools/ttLib/ttCollection.py +++ b/Lib/fontTools/ttLib/ttCollection.py @@ -8,7 +8,6 @@ log = logging.getLogger(__name__) class TTCollection(object): - """Object representing a TrueType Collection / OpenType Collection. The main API is self.fonts being a list of TTFont instances. diff --git a/Lib/fontTools/ttLib/ttFont.py b/Lib/fontTools/ttLib/ttFont.py index c8c74fecf..ad62a187d 100644 --- a/Lib/fontTools/ttLib/ttFont.py +++ b/Lib/fontTools/ttLib/ttFont.py @@ -15,7 +15,6 @@ log = logging.getLogger(__name__) class TTFont(object): - """Represents a TrueType font. The object manages file input and output, and offers a convenient way of @@ -843,7 +842,6 @@ class TTFont(object): class GlyphOrder(object): - """A pseudo table. The glyph order isn't in the font as a separate table, but it's nice to present it as such in the TTX format. """ diff --git a/Lib/fontTools/ttLib/ttGlyphSet.py b/Lib/fontTools/ttLib/ttGlyphSet.py index 5d188d6a1..b4beb3e76 100644 --- a/Lib/fontTools/ttLib/ttGlyphSet.py +++ b/Lib/fontTools/ttLib/ttGlyphSet.py @@ -17,7 +17,6 @@ from fontTools.pens.recordingPen import ( class _TTGlyphSet(Mapping): - """Generic dict-like GlyphSet class that pulls metrics from hmtx and glyph shape from TrueType or CFF. """ @@ -125,7 +124,6 @@ class _TTGlyphSetCFF(_TTGlyphSet): class _TTGlyph(ABC): - """Glyph object that supports the Pen protocol, meaning that it has .draw() and .drawPoints() methods that take a pen object as their only argument. Additionally there are 'width' and 'lsb' attributes, read from diff --git a/Lib/fontTools/ttx.py b/Lib/fontTools/ttx.py index d8c2a3a75..e7a068748 100644 --- a/Lib/fontTools/ttx.py +++ b/Lib/fontTools/ttx.py @@ -103,7 +103,6 @@ Compile options extension is available at https://pypi.python.org/pypi/zopfli """ - from fontTools.ttLib import TTFont, TTLibError from fontTools.misc.macCreatorType import getMacCreatorAndType from fontTools.unicode import setUnicodeData diff --git a/Lib/fontTools/ufoLib/__init__.py b/Lib/fontTools/ufoLib/__init__.py index 1a456a206..c2d2b0b26 100755 --- a/Lib/fontTools/ufoLib/__init__.py +++ b/Lib/fontTools/ufoLib/__init__.py @@ -197,7 +197,6 @@ class _UFOBaseIO: class UFOReader(_UFOBaseIO): - """ Read the various components of the .ufo. @@ -881,7 +880,6 @@ class UFOReader(_UFOBaseIO): class UFOWriter(UFOReader): - """ Write the various components of the .ufo. diff --git a/Lib/fontTools/ufoLib/converters.py b/Lib/fontTools/ufoLib/converters.py index daccf7827..88a26c616 100644 --- a/Lib/fontTools/ufoLib/converters.py +++ b/Lib/fontTools/ufoLib/converters.py @@ -2,7 +2,6 @@ Conversion functions. """ - # adapted from the UFO spec diff --git a/Lib/fontTools/ufoLib/etree.py b/Lib/fontTools/ufoLib/etree.py index 5054f8169..77e3c16e2 100644 --- a/Lib/fontTools/ufoLib/etree.py +++ b/Lib/fontTools/ufoLib/etree.py @@ -2,4 +2,5 @@ for the old ufoLib.etree module, which was moved to fontTools.misc.etree. Please use the latter instead. """ + from fontTools.misc.etree import * diff --git a/Lib/fontTools/ufoLib/glifLib.py b/Lib/fontTools/ufoLib/glifLib.py index 6dee9db30..62e87db0d 100755 --- a/Lib/fontTools/ufoLib/glifLib.py +++ b/Lib/fontTools/ufoLib/glifLib.py @@ -91,7 +91,6 @@ GLIFFormatVersion.__str__ = _VersionTupleEnumMixin.__str__ class Glyph: - """ Minimal glyph object. It has no glyph attributes until either the draw() or the drawPoints() method has been called. @@ -123,7 +122,6 @@ class Glyph: class GlyphSet(_UFOBaseIO): - """ GlyphSet manages a set of .glif files inside one directory. @@ -1228,9 +1226,9 @@ def _readGlyphFromTreeFormat2( unicodes = [] guidelines = [] anchors = [] - haveSeenAdvance = ( - haveSeenImage - ) = haveSeenOutline = haveSeenLib = haveSeenNote = False + haveSeenAdvance = haveSeenImage = haveSeenOutline = haveSeenLib = haveSeenNote = ( + False + ) identifiers = set() for element in tree: if element.tag == "outline": @@ -1883,7 +1881,6 @@ _transformationInfo = [ class GLIFPointPen(AbstractPointPen): - """ Helper class using the PointPen protocol to write the part of .glif files. diff --git a/Lib/fontTools/ufoLib/plistlib.py b/Lib/fontTools/ufoLib/plistlib.py index 1f52f20a2..38bb266b2 100644 --- a/Lib/fontTools/ufoLib/plistlib.py +++ b/Lib/fontTools/ufoLib/plistlib.py @@ -2,6 +2,7 @@ for the old ufoLib.plistlib module, which was moved to fontTools.misc.plistlib. Please use the latter instead. """ + from fontTools.misc.plistlib import dump, dumps, load, loads from fontTools.misc.textTools import tobytes diff --git a/Lib/fontTools/ufoLib/pointPen.py b/Lib/fontTools/ufoLib/pointPen.py index 3433fdbc9..baef9a583 100644 --- a/Lib/fontTools/ufoLib/pointPen.py +++ b/Lib/fontTools/ufoLib/pointPen.py @@ -2,4 +2,5 @@ for the old ufoLib.pointPen module, which was moved to fontTools.pens.pointPen. Please use the latter instead. """ + from fontTools.pens.pointPen import * diff --git a/Lib/fontTools/ufoLib/utils.py b/Lib/fontTools/ufoLib/utils.py index 85878b47a..45ec1c564 100644 --- a/Lib/fontTools/ufoLib/utils.py +++ b/Lib/fontTools/ufoLib/utils.py @@ -1,6 +1,7 @@ """The module contains miscellaneous helpers. It's not considered part of the public ufoLib API. """ + import warnings import functools diff --git a/Lib/fontTools/unicodedata/__init__.py b/Lib/fontTools/unicodedata/__init__.py index 808c9c722..06eb4619a 100644 --- a/Lib/fontTools/unicodedata/__init__.py +++ b/Lib/fontTools/unicodedata/__init__.py @@ -201,15 +201,13 @@ T = TypeVar("T") @overload -def script_horizontal_direction(script_code: str, default: T) -> HorizDirection | T: - ... +def script_horizontal_direction(script_code: str, default: T) -> HorizDirection | T: ... @overload def script_horizontal_direction( script_code: str, default: type[KeyError] = KeyError -) -> HorizDirection: - ... +) -> HorizDirection: ... def script_horizontal_direction( diff --git a/Lib/fontTools/varLib/__init__.py b/Lib/fontTools/varLib/__init__.py index b9af6dacb..1e0f2ec2f 100644 --- a/Lib/fontTools/varLib/__init__.py +++ b/Lib/fontTools/varLib/__init__.py @@ -18,6 +18,7 @@ Then you can make a variable-font this way: API *will* change in near future. """ + from typing import List from fontTools.misc.vector import Vector from fontTools.misc.roundTools import noRound, otRound @@ -569,9 +570,11 @@ def _get_advance_metrics( sparse_advance = 0xFFFF for glyph in glyphOrder: vhAdvances = [ - metrics[glyph][0] - if glyph in metrics and metrics[glyph][0] != sparse_advance - else None + ( + metrics[glyph][0] + if glyph in metrics and metrics[glyph][0] != sparse_advance + else None + ) for metrics in advMetricses ] vhAdvanceDeltasAndSupports[glyph] = masterModel.getDeltasAndSupports( diff --git a/Lib/fontTools/varLib/featureVars.py b/Lib/fontTools/varLib/featureVars.py index 828b84359..2e957f558 100644 --- a/Lib/fontTools/varLib/featureVars.py +++ b/Lib/fontTools/varLib/featureVars.py @@ -3,6 +3,7 @@ https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2#featurevariat NOTE: The API is experimental and subject to change. """ + from fontTools.misc.dictTools import hashdict from fontTools.misc.intTools import bit_count from fontTools.ttLib import newTable diff --git a/Lib/fontTools/varLib/instancer/__init__.py b/Lib/fontTools/varLib/instancer/__init__.py index df55f0414..89427dc53 100644 --- a/Lib/fontTools/varLib/instancer/__init__.py +++ b/Lib/fontTools/varLib/instancer/__init__.py @@ -82,6 +82,7 @@ are supported, but support for CFF2 variable fonts will be added soon. The discussion and implementation of these features are tracked at https://github.com/fonttools/fonttools/issues/1537 """ + from fontTools.misc.fixedTools import ( floatToFixedToFloat, strToFixedToFloat, @@ -643,9 +644,11 @@ def instantiateGvar(varfont, axisLimits, optimize=True): glyphnames = sorted( glyf.glyphOrder, key=lambda name: ( - glyf[name].getCompositeMaxpValues(glyf).maxComponentDepth - if glyf[name].isComposite() or glyf[name].isVarComposite() - else 0, + ( + glyf[name].getCompositeMaxpValues(glyf).maxComponentDepth + if glyf[name].isComposite() or glyf[name].isVarComposite() + else 0 + ), name, ), ) diff --git a/Lib/fontTools/varLib/interpolate_layout.py b/Lib/fontTools/varLib/interpolate_layout.py index aa3f49c6e..798b29590 100644 --- a/Lib/fontTools/varLib/interpolate_layout.py +++ b/Lib/fontTools/varLib/interpolate_layout.py @@ -1,6 +1,7 @@ """ Interpolate OpenType Layout tables (GDEF / GPOS / GSUB). """ + from fontTools.ttLib import TTFont from fontTools.varLib import models, VarLibError, load_designspace, load_masters from fontTools.varLib.merger import InstancerMerger diff --git a/Lib/fontTools/varLib/merger.py b/Lib/fontTools/varLib/merger.py index 96029166a..61122f4c6 100644 --- a/Lib/fontTools/varLib/merger.py +++ b/Lib/fontTools/varLib/merger.py @@ -1,6 +1,7 @@ """ Merge OpenType Layout tables (GDEF / GPOS / GSUB). """ + import os import copy import enum diff --git a/Lib/fontTools/varLib/mutator.py b/Lib/fontTools/varLib/mutator.py index d1d123ab6..c7c37dabc 100644 --- a/Lib/fontTools/varLib/mutator.py +++ b/Lib/fontTools/varLib/mutator.py @@ -3,6 +3,7 @@ Instantiate a variation font. Run, eg: $ fonttools varLib.mutator ./NotoSansArabic-VF.ttf wght=140 wdth=85 """ + from fontTools.misc.fixedTools import floatToFixedToFloat, floatToFixed from fontTools.misc.roundTools import otRound from fontTools.pens.boundsPen import BoundsPen @@ -198,9 +199,11 @@ def instantiateVariableFont(varfont, location, inplace=False, overlap=True): glyphnames = sorted( gvar.variations.keys(), key=lambda name: ( - glyf[name].getCompositeMaxpValues(glyf).maxComponentDepth - if glyf[name].isComposite() or glyf[name].isVarComposite() - else 0, + ( + glyf[name].getCompositeMaxpValues(glyf).maxComponentDepth + if glyf[name].isComposite() or glyf[name].isVarComposite() + else 0 + ), name, ), ) @@ -304,9 +307,9 @@ def instantiateVariableFont(varfont, location, inplace=False, overlap=True): if applies: assert record.FeatureTableSubstitution.Version == 0x00010000 for rec in record.FeatureTableSubstitution.SubstitutionRecord: - table.FeatureList.FeatureRecord[ - rec.FeatureIndex - ].Feature = rec.Feature + table.FeatureList.FeatureRecord[rec.FeatureIndex].Feature = ( + rec.Feature + ) break del table.FeatureVariations diff --git a/dev-requirements.txt b/dev-requirements.txt index 400f8e06b..f104af9a2 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,4 +5,4 @@ sphinx>=1.5.5 mypy>=0.782 # Pin black as each version could change formatting, breaking CI randomly. -black==23.12.0 +black==24.1.1 diff --git a/requirements.txt b/requirements.txt index 2a56ea8f9..b2e5f2da9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,17 +4,17 @@ brotli==1.1.0; platform_python_implementation != "PyPy" brotlicffi==1.1.0.0; platform_python_implementation == "PyPy" unicodedata2==15.1.0; python_version <= '3.11' scipy==1.10.0; platform_python_implementation != "PyPy" and python_version <= '3.8' # pyup: ignore -scipy==1.11.4; platform_python_implementation != "PyPy" and python_version >= '3.9' +scipy==1.12.0; platform_python_implementation != "PyPy" and python_version >= '3.9' munkres==1.1.4; platform_python_implementation == "PyPy" zopfli==0.2.3 fs==2.4.16 skia-pathops==0.8.0.post1; platform_python_implementation != "PyPy" # this is only required to run Tests/cu2qu/{ufo,cli}_test.py ufoLib2==0.16.0 -ufo2ft==2.33.4 +ufo2ft==3.0.0 pyobjc==10.1; sys_platform == "darwin" freetype-py==2.4.0 -uharfbuzz==0.37.3 -glyphsLib==6.6.0 # this is only required to run Tests/varLib/interpolatable_test.py +uharfbuzz==0.39.0 +glyphsLib==6.6.3 # this is only required to run Tests/varLib/interpolatable_test.py lxml==5.1.0 sympy==1.12 diff --git a/setup.py b/setup.py index 2d83ad3a2..7702871f9 100755 --- a/setup.py +++ b/setup.py @@ -46,9 +46,7 @@ env_with_cython = os.environ.get("FONTTOOLS_WITH_CYTHON") with_cython = ( True if env_with_cython in {"1", "true", "yes"} - else False - if env_with_cython in {"0", "false", "no"} - else None + else False if env_with_cython in {"0", "false", "no"} else None ) # --with-cython/--without-cython options override environment variables opt_with_cython = {"--with-cython"}.intersection(sys.argv)