def fixupGroups(fontPath, dstGlyphNames, srcToDstMap, dryRun, stats):
filename = os.path.join(fontPath, 'groups.plist')
groups = plistlib.readPlist(filename)
groups2 = {}
glyphToGroups = {}
for groupName, glyphNames in groups.iteritems():
glyphNames2 = []
for glyphName in glyphNames:
if glyphName in srcToDstMap:
gn2 = srcToDstMap[glyphName]
stats.renamedGlyphs[glyphName] = gn2
glyphName = gn2
if glyphName in dstGlyphNames:
glyphNames2.append(glyphName)
glyphToGroups[glyphName] = glyphToGroups.get(glyphName, []) + [groupName]
else:
stats.removedGlyphs.add(glyphName)
if len(glyphNames2) > 0:
groups2[groupName] = glyphNames2
else:
stats.removedGroups.add(groupName)
print('Writing', filename)
if not dryRun:
plistlib.writePlist(groups2, filename)
return groups2, glyphToGroups
评论列表
文章目录