aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-06-11 11:48:44 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-06-12 09:58:01 +0300
commita26a1f012a93e209458200c2ba8ae484a45a6c54 (patch)
tree593bfd3677bce7f893c30c81dcc4fc36f1360782 /contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py
parent07f57e35443ab7f09471caf2dbf1afbcced4d9f7 (diff)
downloadydb-a26a1f012a93e209458200c2ba8ae484a45a6c54.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py')
-rw-r--r--contrib/python/fonttools/fontTools/cffLib/CFF2ToCFF.py32
1 files changed, 27 insertions, 5 deletions
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")