[CFF2ToCFF] Map charset to CIDs

This seems to fix the case of ttx not handling the results.
I *think* this fixes the rest of the issues I've been seeing
with this conversion.
This commit is contained in:
Behdad Esfahbod 2024-05-27 16:22:19 -06:00
parent c384709c0a
commit 4ad6b0db13

View File

@ -100,6 +100,21 @@ def _convertCFF2ToCFF(cff, otFont):
if width != private.defaultWidthX:
cs.program.insert(0, width - private.nominalWidthX)
mapping = {
name: ("cid" + str(n) if n else ".notdef")
for n, name in enumerate(topDict.charset)
}
topDict.charset = [
"cid" + str(n) if n else ".notdef" for n in range(len(topDict.charset))
]
charStrings.charStrings = {
mapping[name]: v for name, v in charStrings.charStrings.items()
}
# I'm not sure why the following is *not* necessary. And it breaks
# the output if I add it.
# topDict.ROS = ("Adobe", "Identity", 0)
def convertCFF2ToCFF(font, *, updatePostTable=True):
cff = font["CFF2"].cff