diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-11 11:48:44 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-12 09:58:01 +0300 |
commit | a26a1f012a93e209458200c2ba8ae484a45a6c54 (patch) | |
tree | 593bfd3677bce7f893c30c81dcc4fc36f1360782 /contrib | |
parent | 07f57e35443ab7f09471caf2dbf1afbcced4d9f7 (diff) | |
download | ydb-a26a1f012a93e209458200c2ba8ae484a45a6c54.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib')
15 files changed, 108 insertions, 35 deletions
diff --git a/contrib/python/fonttools/.dist-info/METADATA b/contrib/python/fonttools/.dist-info/METADATA index 6a00aa9e47..fa68def0d1 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.52.1 +Version: 4.52.4 Summary: Tools to manipulate font files Home-page: http://github.com/fonttools/fonttools Author: Just van Rossum @@ -375,6 +375,27 @@ Have fun! Changelog ~~~~~~~~~ +4.52.4 (released 2024-05-27) +---------------------------- + +- [varLib.cff] Restore and deprecate convertCFFtoCFF2 that was removed in 4.52.0 + release as it is used by downstream projects (#3535). + +4.52.3 (released 2024-05-27) +---------------------------- + +- Fixed a small syntax error in the reStructuredText-formatted NEWS.rst file + which caused the upload to PyPI to fail for 4.52.2. No other code changes. + +4.52.2 (released 2024-05-27) +---------------------------- + +- [varLib.interpolatable] Ensure that scipy/numpy output is JSON-serializable + (#3522, #3526). +- [housekeeping] Regenerate table lists, to fix pyinstaller packaging of the new + ``VARC`` table (#3531, #3529). +- [cffLib] Make CFFToCFF2 and CFF2ToCFF more robust (#3521, #3525). + 4.52.1 (released 2024-05-24) ---------------------------- diff --git a/contrib/python/fonttools/fontTools/__init__.py b/contrib/python/fonttools/fontTools/__init__.py index 56dd7303e0..68138485de 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.52.1" +version = __version__ = "4.52.4" __all__ = ["version", "log", "configLogger"] diff --git a/contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py b/contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py index 5dc48a7fcb..689412ce2b 100644 --- a/contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py +++ b/contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py @@ -2,7 +2,13 @@ from fontTools.ttLib import TTFont, newTable from fontTools.misc.cliTools import makeOutputFileName -from fontTools.cffLib import TopDictIndex, buildOrder, topDictOperators +from fontTools.cffLib import ( + TopDictIndex, + buildOrder, + buildDefaults, + topDictOperators, + privateDictOperators, +) from .width import optimizeWidths from collections import defaultdict import logging @@ -36,16 +42,32 @@ def _convertCFF2ToCFF(cff, otFont): if hasattr(topDict, "VarStore"): raise ValueError("Variable CFF2 font cannot be converted to CFF format.") - if hasattr(topDict, "Private"): - privateDict = topDict.Private - else: - privateDict = None opOrder = buildOrder(topDictOperators) topDict.order = opOrder + for key in topDict.rawDict.keys(): + if key not in opOrder: + del topDict.rawDict[key] + if hasattr(topDict, key): + delattr(topDict, key) fdArray = topDict.FDArray charStrings = topDict.CharStrings + defaults = buildDefaults(privateDictOperators) + order = buildOrder(privateDictOperators) + for fd in fdArray: + fd.setCFF2(False) + privateDict = fd.Private + privateDict.order = order + for key in order: + if key not in privateDict.rawDict and key in defaults: + privateDict.rawDict[key] = defaults[key] + for key in privateDict.rawDict.keys(): + if key not in order: + del privateDict.rawDict[key] + if hasattr(privateDict, key): + delattr(privateDict, key) + for cs in charStrings.values(): cs.decompile() cs.program.append("endchar") diff --git a/contrib/python/fonttools/fontTools/cffLib/CFFToCFF2.py b/contrib/python/fonttools/fontTools/cffLib/CFFToCFF2.py index 78347c6667..37463a5b9b 100644 --- a/contrib/python/fonttools/fontTools/cffLib/CFFToCFF2.py +++ b/contrib/python/fonttools/fontTools/cffLib/CFFToCFF2.py @@ -43,7 +43,15 @@ def _convertCFFToCFF2(cff, otFont): fdArray = topDict.FDArray if hasattr(topDict, "FDArray") else None charStrings = topDict.CharStrings globalSubrs = cff.GlobalSubrs - localSubrs = [getattr(fd.Private, "Subrs", []) for fd in fdArray] if fdArray else [] + localSubrs = ( + [getattr(fd.Private, "Subrs", []) for fd in fdArray] + if fdArray + else ( + [topDict.Private.Subrs] + if hasattr(topDict, "Private") and hasattr(topDict.Private, "Subrs") + else [] + ) + ) for glyphName in charStrings.keys(): cs, fdIndex = charStrings.getItemAndSelector(glyphName) @@ -70,13 +78,21 @@ def _convertCFFToCFF2(cff, otFont): for glyphName in charStrings.keys(): cs, fdIndex = charStrings.getItemAndSelector(glyphName) program = cs.program - if fdIndex == None: - fdIndex = 0 + + thisLocalSubrs = ( + localSubrs[fdIndex] + if fdIndex + else ( + getattr(topDict.Private, "Subrs", []) + if hasattr(topDict, "Private") + else [] + ) + ) # Intentionally use custom type for nominalWidthX, such that any # CharString that has an explicit width encoded will throw back to us. extractor = T2WidthExtractor( - localSubrs[fdIndex] if localSubrs else [], + thisLocalSubrs, globalSubrs, nominalWidthXError, 0, @@ -94,7 +110,7 @@ def _convertCFFToCFF2(cff, otFont): op = program.pop(0) bias = extractor.localBias if op == "callsubr" else extractor.globalBias subrNumber += bias - subrSet = localSubrs[fdIndex] if op == "callsubr" else globalSubrs + subrSet = thisLocalSubrs if op == "callsubr" else globalSubrs subrProgram = subrSet[subrNumber].program program[:0] = subrProgram # Now pop the actual width diff --git a/contrib/python/fonttools/fontTools/cffLib/__init__.py b/contrib/python/fonttools/fontTools/cffLib/__init__.py index 9cfdebaa11..c192ec77af 100644 --- a/contrib/python/fonttools/fontTools/cffLib/__init__.py +++ b/contrib/python/fonttools/fontTools/cffLib/__init__.py @@ -1470,7 +1470,7 @@ class CharsetConverter(SimpleConverter): else: # offset == 0 -> no charset data. if isCID or "CharStrings" not in parent.rawDict: # We get here only when processing fontDicts from the FDArray of - # CFF-CID fonts. Only the real topDict references the chrset. + # CFF-CID fonts. Only the real topDict references the charset. assert value == 0 charset = None elif value == 0: diff --git a/contrib/python/fonttools/fontTools/cffLib/transforms.py b/contrib/python/fonttools/fontTools/cffLib/transforms.py index 0772d85e21..91f6999fe6 100644 --- a/contrib/python/fonttools/fontTools/cffLib/transforms.py +++ b/contrib/python/fonttools/fontTools/cffLib/transforms.py @@ -342,7 +342,7 @@ def _cs_drop_hints(charstring): del charstring._hints -def remove_hints(cff): +def remove_hints(cff, *, removeUnusedSubrs: bool = True): for fontname in cff.keys(): font = cff[fontname] cs = font.CharStrings @@ -404,7 +404,8 @@ def remove_hints(cff): ]: if hasattr(priv, k): setattr(priv, k, None) - remove_unused_subroutines(cff) + if removeUnusedSubrs: + remove_unused_subroutines(cff) def _pd_delete_empty_subrs(private_dict): diff --git a/contrib/python/fonttools/fontTools/misc/symfont.py b/contrib/python/fonttools/fontTools/misc/symfont.py index fb9e20a46e..3a8819c774 100644 --- a/contrib/python/fonttools/fontTools/misc/symfont.py +++ b/contrib/python/fonttools/fontTools/misc/symfont.py @@ -76,16 +76,16 @@ class GreenPen(BasePen): self.value = 0 def _moveTo(self, p0): - self.__startPoint = p0 + self._startPoint = p0 def _closePath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: - self._lineTo(self.__startPoint) + if p0 != self._startPoint: + self._lineTo(self._startPoint) def _endPath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: + if p0 != self._startPoint: # Green theorem is not defined on open contours. raise NotImplementedError @@ -145,19 +145,18 @@ class %s(BasePen): print( """ def _moveTo(self, p0): - self.__startPoint = p0 + self._startPoint = p0 def _closePath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: - self._lineTo(self.__startPoint) + if p0 != self._startPoint: + self._lineTo(self._startPoint) def _endPath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: - # Green theorem is not defined on open contours. + if p0 != self._startPoint: raise OpenContourError( - "Green theorem is not defined on open contours." + "Glyph statistics is not defined on open contours." ) """, end="", diff --git a/contrib/python/fonttools/fontTools/pens/momentsPen.py b/contrib/python/fonttools/fontTools/pens/momentsPen.py index 4c7ddfe321..2afb8fdbd1 100644 --- a/contrib/python/fonttools/fontTools/pens/momentsPen.py +++ b/contrib/python/fonttools/fontTools/pens/momentsPen.py @@ -15,6 +15,7 @@ __all__ = ["MomentsPen"] class MomentsPen(BasePen): + def __init__(self, glyphset=None): BasePen.__init__(self, glyphset) @@ -26,17 +27,17 @@ class MomentsPen(BasePen): self.momentYY = 0 def _moveTo(self, p0): - self.__startPoint = p0 + self._startPoint = p0 def _closePath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: - self._lineTo(self.__startPoint) + if p0 != self._startPoint: + self._lineTo(self._startPoint) def _endPath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: - raise OpenContourError("Glyph statistics not defined on open contours.") + if p0 != self._startPoint: + raise OpenContourError("Glyph statistics is not defined on open contours.") @cython.locals(r0=cython.double) @cython.locals(r1=cython.double) diff --git a/contrib/python/fonttools/fontTools/pens/statisticsPen.py b/contrib/python/fonttools/fontTools/pens/statisticsPen.py index 699b14ca79..b91d93b6eb 100644 --- a/contrib/python/fonttools/fontTools/pens/statisticsPen.py +++ b/contrib/python/fonttools/fontTools/pens/statisticsPen.py @@ -123,7 +123,7 @@ class StatisticsControlPen(StatisticsBase, BasePen): def _endPath(self): p0 = self._getCurrentPoint() - if p0 != self.__startPoint: + if p0 != self._startPoint: raise OpenContourError("Glyph statistics not defined on open contours.") def _update(self): diff --git a/contrib/python/fonttools/fontTools/ttLib/tables/__init__.py b/contrib/python/fonttools/fontTools/ttLib/tables/__init__.py index f4cba26bf6..e622f1d134 100644 --- a/contrib/python/fonttools/fontTools/ttLib/tables/__init__.py +++ b/contrib/python/fonttools/fontTools/ttLib/tables/__init__.py @@ -3,7 +3,7 @@ def _moduleFinderHint(): """Dummy function to let modulefinder know what tables may be dynamically imported. Generated by MetaTools/buildTableList.py. - >>> _moduleFinderHint() + >>> _moduleFinderHint() """ from . import B_A_S_E_ from . import C_B_D_T_ @@ -50,6 +50,7 @@ def _moduleFinderHint(): from . import T_S_I__3 from . import T_S_I__5 from . import T_T_F_A_ + from . import V_A_R_C_ from . import V_D_M_X_ from . import V_O_R_G_ from . import V_V_A_R_ diff --git a/contrib/python/fonttools/fontTools/varLib/cff.py b/contrib/python/fonttools/fontTools/varLib/cff.py index 393c793e36..59ac5c6f7a 100644 --- a/contrib/python/fonttools/fontTools/varLib/cff.py +++ b/contrib/python/fonttools/fontTools/varLib/cff.py @@ -16,6 +16,7 @@ from fontTools.cffLib.specializer import specializeCommands, commandsToProgram from fontTools.ttLib import newTable from fontTools import varLib from fontTools.varLib.models import allEqual +from fontTools.misc.loggingTools import deprecateFunction from fontTools.misc.roundTools import roundFunc from fontTools.misc.psCharStrings import T2CharString, T2OutlineExtractor from fontTools.pens.t2CharStringPen import T2CharStringPen @@ -49,6 +50,13 @@ def addCFFVarStore(varFont, varModel, varDataList, masterSupports): fontDict.Private.vstore = topDict.VarStore +@deprecateFunction("Use fontTools.cffLib.CFFToCFF2.convertCFFToCFF2 instead.") +def convertCFFtoCFF2(varFont): + from fontTools.cffLib.CFFToCFF2 import convertCFFToCFF2 + + return convertCFFToCFF2(varFont) + + def conv_to_int(num): if isinstance(num, float) and num.is_integer(): return int(num) diff --git a/contrib/python/fonttools/fontTools/varLib/instancer/__init__.py b/contrib/python/fonttools/fontTools/varLib/instancer/__init__.py index f8c43187c7..0c5dd40ce1 100644 --- a/contrib/python/fonttools/fontTools/varLib/instancer/__init__.py +++ b/contrib/python/fonttools/fontTools/varLib/instancer/__init__.py @@ -1559,7 +1559,6 @@ def instantiateVariableFont( Args: varfont: a TTFont instance, which must contain at least an 'fvar' table. - Note that variable fonts with 'CFF2' table are not supported yet. axisLimits: a dict keyed by axis tags (str) containing the coordinates (float) along one or more axes where the desired instance will be located. If the value is `None`, the default coordinate as per 'fvar' table for diff --git a/contrib/python/fonttools/fontTools/varLib/interpolatableHelpers.py b/contrib/python/fonttools/fontTools/varLib/interpolatableHelpers.py index 2a3540fff2..f71b32afd1 100644 --- a/contrib/python/fonttools/fontTools/varLib/interpolatableHelpers.py +++ b/contrib/python/fonttools/fontTools/varLib/interpolatableHelpers.py @@ -143,6 +143,9 @@ def min_cost_perfect_bipartite_matching_scipy(G): n = len(G) rows, cols = linear_sum_assignment(G) assert (rows == list(range(n))).all() + # Convert numpy array and integer to Python types, + # to ensure that this is JSON-serializable. + cols = list(int(e) for e in cols) return list(cols), matching_cost(G, cols) diff --git a/contrib/python/fonttools/fontTools/varLib/interpolatableTestStartingPoint.py b/contrib/python/fonttools/fontTools/varLib/interpolatableTestStartingPoint.py index e760006631..e91dacf288 100644 --- a/contrib/python/fonttools/fontTools/varLib/interpolatableTestStartingPoint.py +++ b/contrib/python/fonttools/fontTools/varLib/interpolatableTestStartingPoint.py @@ -49,7 +49,9 @@ def test_starting_point(glyph0, glyph1, ix, tolerance, matching): meanY = vector[2] stddevX = vector[3] * 0.5 stddevY = vector[4] * 0.5 - correlation = vector[5] / abs(vector[0]) + correlation = vector[5] + if correlation: + correlation /= abs(vector[0]) # https://cookierobotics.com/007/ a = stddevX * stddevX # VarianceX diff --git a/contrib/python/fonttools/ya.make b/contrib/python/fonttools/ya.make index 51c9d08b3b..dc7430ebfe 100644 --- a/contrib/python/fonttools/ya.make +++ b/contrib/python/fonttools/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(4.52.1) +VERSION(4.52.4) LICENSE(MIT) |