Skip to content

[cffLib] Question on moving Private from topDict to FontDict #2720

Discussion options

You must be logged in to vote
import copy
from fontTools import ttLib
from fontTools.cffLib import (
    FDArrayIndex,
    FontDict,
    FDSelect,
)

font = ttLib.TTFont("fonts/in.otf")
glyphOrder = font.getGlyphOrder()

cff = font["CFF "].cff.values()[0]
fontName = font["CFF "].cff.keys()[0]

cff.ROS = ("Adobe", "Identity", 0)

# delete encoding when converting to CID-keyed
del cff.rawDict["Encoding"]
mapping = {
    name: ("cid" + str(n) if n else ".notdef") for n, name in enumerate(cff.charset)
}
charstrings = cff.CharStrings
charstrings.charStrings = {
    mapping[name]: v for name, v in charstrings.charStrings.items()
}
cff.charset = ["cid" + str(n) if n else ".notdef" for n in range(len(cff.charset))]


# sample…

Replies: 5 comments 19 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@NightFurySL2001
Comment options

@justvanrossum
Comment options

@justvanrossum
Comment options

@justvanrossum
Comment options

@NightFurySL2001
Comment options

Comment options

You must be logged in to vote
10 replies
@justvanrossum
Comment options

@justvanrossum
Comment options

@NightFurySL2001
Comment options

@justvanrossum
Comment options

@NightFurySL2001
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by NightFurySL2001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2719 on August 01, 2022 12:19.