[cffLib] Fix bugs in converting CFF to CFF2 when the font has an FDArray.

The FontDict as well as the PrivateDict needs to have fields removed when these are deprecated in CFF2.
This commit is contained in:
ReadRoberts 2018-03-06 17:34:33 -08:00 committed by Cosimo Lupo
parent 21bbb15cd0
commit 942a7610fd
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482

View File

@ -256,7 +256,7 @@ class CFFFontSet(object):
charStrings.charStringsIndex.fdArray = fdArray
else:
charStrings.fdArray = fdArray
fontDict = FontDict()
fontDict = FontDict(isCFF2=True)
fdArray.append(fontDict)
fontDict.Private = privateDict
privateOpOrder = buildOrder(privateDictOperators2)
@ -271,8 +271,17 @@ class CFFFontSet(object):
# print "Removing privateDict attr", key
else:
# clean up the PrivateDicts in the fdArray
fdArray = topDict.FDArray
privateOpOrder = buildOrder(privateDictOperators2)
for fontDict in fdArray:
fontDict.order = fontDict.orderCFF2
fontDict._isCFF2 = True
for key in fontDict.rawDict.keys():
if key not in fontDict.order:
del fontDict.rawDict[key]
if hasattr(fontDict, key):
exec("del fontDict.%s" % (key))
privateDict = fontDict.Private
for entry in privateDictOperators:
key = entry[1]