aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/fonttools
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-01-26 13:18:00 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-01-26 14:37:14 +0300
commit7e48de06a66dff1e3f73e186f64b6d155dffa086 (patch)
treeedd6494ecf7cfca5285dbf4e5c386a20ab58e970 /contrib/python/fonttools
parent9b8da54607431b12327615568180adf77cca95c8 (diff)
downloadydb-7e48de06a66dff1e3f73e186f64b6d155dffa086.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/fonttools')
-rw-r--r--contrib/python/fonttools/.dist-info/METADATA14
-rw-r--r--contrib/python/fonttools/fontTools/__init__.py2
-rw-r--r--contrib/python/fonttools/fontTools/merge/__init__.py54
-rw-r--r--contrib/python/fonttools/fontTools/merge/options.py3
-rw-r--r--contrib/python/fonttools/fontTools/otlLib/builder.py26
-rw-r--r--contrib/python/fonttools/fontTools/varLib/featureVars.py35
-rw-r--r--contrib/python/fonttools/fontTools/varLib/interpolatable.py14
-rw-r--r--contrib/python/fonttools/ya.make2
8 files changed, 110 insertions, 40 deletions
diff --git a/contrib/python/fonttools/.dist-info/METADATA b/contrib/python/fonttools/.dist-info/METADATA
index f156c42697..f9e01c388f 100644
--- a/contrib/python/fonttools/.dist-info/METADATA
+++ b/contrib/python/fonttools/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: fonttools
-Version: 4.47.0
+Version: 4.47.2
Summary: Tools to manipulate font files
Home-page: http://github.com/fonttools/fonttools
Author: Just van Rossum
@@ -375,6 +375,18 @@ Have fun!
Changelog
~~~~~~~~~
+4.47.2 (released 2024-01-11)
+----------------------------
+
+Minor release to fix uploading wheels to PyPI.
+
+4.47.1 (released 2024-01-11)
+----------------------------
+
+- [merge] Improve help message and add standard command line options (#3408)
+- [otlLib] Pass ``ttFont`` to ``name.addName`` in ``buildStatTable`` (#3406)
+- [featureVars] Re-use ``FeatureVariationRecord``'s when possible (#3413)
+
4.47.0 (released 2023-12-18)
----------------------------
diff --git a/contrib/python/fonttools/fontTools/__init__.py b/contrib/python/fonttools/fontTools/__init__.py
index 6c00e567a4..7410d3c7fe 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.47.0"
+version = __version__ = "4.47.2"
__all__ = ["version", "log", "configLogger"]
diff --git a/contrib/python/fonttools/fontTools/merge/__init__.py b/contrib/python/fonttools/fontTools/merge/__init__.py
index 8d8a5213e8..7653e4a079 100644
--- a/contrib/python/fonttools/fontTools/merge/__init__.py
+++ b/contrib/python/fonttools/fontTools/merge/__init__.py
@@ -139,6 +139,7 @@ class Merger(object):
*(vars(table).keys() for table in tables if table is not NotImplemented),
)
for key in allKeys:
+ log.info(" %s", key)
try:
mergeLogic = logic[key]
except KeyError:
@@ -181,17 +182,50 @@ def main(args=None):
args = sys.argv[1:]
options = Options()
- args = options.parse_opts(args, ignore_unknown=["output-file"])
- outfile = "merged.ttf"
+ args = options.parse_opts(args)
fontfiles = []
+ if options.input_file:
+ with open(options.input_file) as inputfile:
+ fontfiles = [
+ line.strip()
+ for line in inputfile.readlines()
+ if not line.lstrip().startswith("#")
+ ]
for g in args:
- if g.startswith("--output-file="):
- outfile = g[14:]
- continue
fontfiles.append(g)
- if len(args) < 1:
- print("usage: pyftmerge font...", file=sys.stderr)
+ if len(fontfiles) < 1:
+ print(
+ "usage: pyftmerge [font1 ... fontN] [--input-file=filelist.txt] [--output-file=merged.ttf] [--import-file=tables.ttx]",
+ file=sys.stderr,
+ )
+ print(
+ " [--drop-tables=tags] [--verbose] [--timing]",
+ file=sys.stderr,
+ )
+ print("", file=sys.stderr)
+ print(" font1 ... fontN Files to merge.", file=sys.stderr)
+ print(
+ " --input-file=<filename> Read files to merge from a text file, each path new line. # Comment lines allowed.",
+ file=sys.stderr,
+ )
+ print(
+ " --output-file=<filename> Specify output file name (default: merged.ttf).",
+ file=sys.stderr,
+ )
+ print(
+ " --import-file=<filename> TTX file to import after merging. This can be used to set metadata.",
+ file=sys.stderr,
+ )
+ print(
+ " --drop-tables=<table tags> Comma separated list of table tags to skip, case sensitive.",
+ file=sys.stderr,
+ )
+ print(
+ " --verbose Output progress information.",
+ file=sys.stderr,
+ )
+ print(" --timing Output progress timing.", file=sys.stderr)
return 1
configLogger(level=logging.INFO if options.verbose else logging.WARNING)
@@ -202,8 +236,12 @@ def main(args=None):
merger = Merger(options=options)
font = merger.merge(fontfiles)
+
+ if options.import_file:
+ font.importXML(options.import_file)
+
with timer("compile and save font"):
- font.save(outfile)
+ font.save(options.output_file)
if __name__ == "__main__":
diff --git a/contrib/python/fonttools/fontTools/merge/options.py b/contrib/python/fonttools/fontTools/merge/options.py
index f134009368..8bc8947138 100644
--- a/contrib/python/fonttools/fontTools/merge/options.py
+++ b/contrib/python/fonttools/fontTools/merge/options.py
@@ -11,6 +11,9 @@ class Options(object):
self.verbose = False
self.timing = False
self.drop_tables = []
+ self.input_file = None
+ self.output_file = "merged.ttf"
+ self.import_file = None
self.set(**kwargs)
diff --git a/contrib/python/fonttools/fontTools/otlLib/builder.py b/contrib/python/fonttools/fontTools/otlLib/builder.py
index 3508a7e28d..4b457f4d9f 100644
--- a/contrib/python/fonttools/fontTools/otlLib/builder.py
+++ b/contrib/python/fonttools/fontTools/otlLib/builder.py
@@ -2781,14 +2781,13 @@ def buildStatTable(
"""
ttFont["STAT"] = ttLib.newTable("STAT")
statTable = ttFont["STAT"].table = ot.STAT()
- nameTable = ttFont["name"]
statTable.ElidedFallbackNameID = _addName(
- nameTable, elidedFallbackName, windows=windowsNames, mac=macNames
+ ttFont, elidedFallbackName, windows=windowsNames, mac=macNames
)
# 'locations' contains data for AxisValue Format 4
axisRecords, axisValues = _buildAxisRecords(
- axes, nameTable, windowsNames=windowsNames, macNames=macNames
+ axes, ttFont, windowsNames=windowsNames, macNames=macNames
)
if not locations:
statTable.Version = 0x00010001
@@ -2797,10 +2796,10 @@ def buildStatTable(
# requires a higher table version
statTable.Version = 0x00010002
multiAxisValues = _buildAxisValuesFormat4(
- locations, axes, nameTable, windowsNames=windowsNames, macNames=macNames
+ locations, axes, ttFont, windowsNames=windowsNames, macNames=macNames
)
axisValues = multiAxisValues + axisValues
- nameTable.names.sort()
+ ttFont["name"].names.sort()
# Store AxisRecords
axisRecordArray = ot.AxisRecordArray()
@@ -2820,14 +2819,14 @@ def buildStatTable(
statTable.AxisValueCount = len(axisValues)
-def _buildAxisRecords(axes, nameTable, windowsNames=True, macNames=True):
+def _buildAxisRecords(axes, ttFont, windowsNames=True, macNames=True):
axisRecords = []
axisValues = []
for axisRecordIndex, axisDict in enumerate(axes):
axis = ot.AxisRecord()
axis.AxisTag = axisDict["tag"]
axis.AxisNameID = _addName(
- nameTable, axisDict["name"], 256, windows=windowsNames, mac=macNames
+ ttFont, axisDict["name"], 256, windows=windowsNames, mac=macNames
)
axis.AxisOrdering = axisDict.get("ordering", axisRecordIndex)
axisRecords.append(axis)
@@ -2837,7 +2836,7 @@ def _buildAxisRecords(axes, nameTable, windowsNames=True, macNames=True):
axisValRec.AxisIndex = axisRecordIndex
axisValRec.Flags = axisVal.get("flags", 0)
axisValRec.ValueNameID = _addName(
- nameTable, axisVal["name"], windows=windowsNames, mac=macNames
+ ttFont, axisVal["name"], windows=windowsNames, mac=macNames
)
if "value" in axisVal:
@@ -2863,9 +2862,7 @@ def _buildAxisRecords(axes, nameTable, windowsNames=True, macNames=True):
return axisRecords, axisValues
-def _buildAxisValuesFormat4(
- locations, axes, nameTable, windowsNames=True, macNames=True
-):
+def _buildAxisValuesFormat4(locations, axes, ttFont, windowsNames=True, macNames=True):
axisTagToIndex = {}
for axisRecordIndex, axisDict in enumerate(axes):
axisTagToIndex[axisDict["tag"]] = axisRecordIndex
@@ -2875,7 +2872,7 @@ def _buildAxisValuesFormat4(
axisValRec = ot.AxisValue()
axisValRec.Format = 4
axisValRec.ValueNameID = _addName(
- nameTable, axisLocationDict["name"], windows=windowsNames, mac=macNames
+ ttFont, axisLocationDict["name"], windows=windowsNames, mac=macNames
)
axisValRec.Flags = axisLocationDict.get("flags", 0)
axisValueRecords = []
@@ -2891,7 +2888,8 @@ def _buildAxisValuesFormat4(
return axisValues
-def _addName(nameTable, value, minNameID=0, windows=True, mac=True):
+def _addName(ttFont, value, minNameID=0, windows=True, mac=True):
+ nameTable = ttFont["name"]
if isinstance(value, int):
# Already a nameID
return value
@@ -2916,5 +2914,5 @@ def _addName(nameTable, value, minNameID=0, windows=True, mac=True):
else:
raise TypeError("value must be int, str, dict or list")
return nameTable.addMultilingualName(
- names, windows=windows, mac=mac, minNameID=minNameID
+ names, ttFont=ttFont, windows=windows, mac=mac, minNameID=minNameID
)
diff --git a/contrib/python/fonttools/fontTools/varLib/featureVars.py b/contrib/python/fonttools/fontTools/varLib/featureVars.py
index a6beb5c7d2..828b843594 100644
--- a/contrib/python/fonttools/fontTools/varLib/featureVars.py
+++ b/contrib/python/fonttools/fontTools/varLib/featureVars.py
@@ -414,6 +414,10 @@ def addFeatureVariationsRaw(font, table, conditionalSubstitutions, featureTag="r
axis.axisTag: axisIndex for axisIndex, axis in enumerate(font["fvar"].axes)
}
+ hasFeatureVariations = (
+ hasattr(table, "FeatureVariations") and table.FeatureVariations is not None
+ )
+
featureVariationRecords = []
for conditionSet, lookupIndices in conditionalSubstitutions:
conditionTable = []
@@ -440,11 +444,19 @@ def addFeatureVariationsRaw(font, table, conditionalSubstitutions, featureTag="r
varFeatureIndex, combinedLookupIndices
)
)
- featureVariationRecords.append(
- buildFeatureVariationRecord(conditionTable, records)
- )
+ if hasFeatureVariations and (
+ fvr := findFeatureVariationRecord(table.FeatureVariations, conditionTable)
+ ):
+ fvr.FeatureTableSubstitution.SubstitutionRecord.extend(records)
+ fvr.FeatureTableSubstitution.SubstitutionCount = len(
+ fvr.FeatureTableSubstitution.SubstitutionRecord
+ )
+ else:
+ featureVariationRecords.append(
+ buildFeatureVariationRecord(conditionTable, records)
+ )
- if hasattr(table, "FeatureVariations") and table.FeatureVariations is not None:
+ if hasFeatureVariations:
if table.FeatureVariations.Version != 0x00010000:
raise VarLibError(
"Unsupported FeatureVariations table version: "
@@ -614,6 +626,21 @@ def buildConditionTable(axisIndex, filterRangeMinValue, filterRangeMaxValue):
return ct
+def findFeatureVariationRecord(featureVariations, conditionTable):
+ """Find a FeatureVariationRecord that has the same conditionTable."""
+ if featureVariations.Version != 0x00010000:
+ raise VarLibError(
+ "Unsupported FeatureVariations table version: "
+ f"0x{featureVariations.Version:08x} (expected 0x00010000)."
+ )
+
+ for fvr in featureVariations.FeatureVariationRecord:
+ if conditionTable == fvr.ConditionSet.ConditionTable:
+ return fvr
+
+ return None
+
+
def sortFeatureList(table):
"""Sort the feature list by feature tag, and remap the feature indices
elsewhere. This is needed after the feature list has been modified.
diff --git a/contrib/python/fonttools/fontTools/varLib/interpolatable.py b/contrib/python/fonttools/fontTools/varLib/interpolatable.py
index 0a9bbebc41..5fc12e04c9 100644
--- a/contrib/python/fonttools/fontTools/varLib/interpolatable.py
+++ b/contrib/python/fonttools/fontTools/varLib/interpolatable.py
@@ -376,9 +376,6 @@ def test_gen(
size1 = m1Vec[0] * m1Vec[0]
midSize = midVector[0] * midVector[0]
- power = 1
- t = tolerance**power
-
for overweight, problem_type in enumerate(
(
InterpolatableProblem.UNDERWEIGHT,
@@ -386,8 +383,7 @@ def test_gen(
)
):
if overweight:
- expectedSize = sqrt(size0 * size1)
- expectedSize = (size0 + size1) - expectedSize
+ expectedSize = max(size0, size1)
continue
else:
expectedSize = sqrt(size0 * size1)
@@ -406,13 +402,9 @@ def test_gen(
) or (overweight and 1e-5 + expectedSize / tolerance < midSize):
try:
if overweight:
- this_tolerance = (expectedSize / midSize) ** (
- 1 / power
- )
+ this_tolerance = expectedSize / midSize
else:
- this_tolerance = (midSize / expectedSize) ** (
- 1 / power
- )
+ this_tolerance = midSize / expectedSize
except ZeroDivisionError:
this_tolerance = 0
log.debug("tolerance %g", this_tolerance)
diff --git a/contrib/python/fonttools/ya.make b/contrib/python/fonttools/ya.make
index 6e76c94da1..4d380b556c 100644
--- a/contrib/python/fonttools/ya.make
+++ b/contrib/python/fonttools/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(4.47.0)
+VERSION(4.47.2)
LICENSE(MIT)