Browse Source

Intermediate changes

robot-piglet 1 year ago
parent
commit
487e4bd3ed

+ 13 - 1
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)
 ----------------------------
 

+ 1 - 1
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"]

+ 46 - 8
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__":

+ 3 - 0
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)
 

+ 12 - 14
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
     )

+ 31 - 4
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.

+ 3 - 11
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)

+ 1 - 1
contrib/python/fonttools/ya.make

@@ -2,7 +2,7 @@
 
 PY3_LIBRARY()
 
-VERSION(4.47.0)
+VERSION(4.47.2)
 
 LICENSE(MIT)
 

+ 1 - 1
contrib/python/google-auth/py3/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: google-auth
-Version: 2.26.1
+Version: 2.26.2
 Summary: Google Authentication Library
 Home-page: https://github.com/googleapis/google-auth-library-python
 Author: Google Cloud Platform

+ 1 - 0
contrib/python/google-auth/py3/google/auth/external_account_authorized_user.py

@@ -342,6 +342,7 @@ class Credentials(
             revoke_url=info.get("revoke_url"),
             quota_project_id=info.get("quota_project_id"),
             scopes=info.get("scopes"),
+            universe_domain=info.get("universe_domain", _DEFAULT_UNIVERSE_DOMAIN),
             **kwargs
         )
 

Some files were not shown because too many files changed in this diff