def renameUFOLib(ufoPath, newNames, dryRun=False, print=print):
filename = os.path.join(ufoPath, 'lib.plist')
plist = plistlib.readPlist(filename)
glyphOrder = plist.get('public.glyphOrder')
if glyphOrder is not None:
plist['public.glyphOrder'] = renameStrings(glyphOrder, newNames)
roboSort = plist.get('com.typemytype.robofont.sort')
if roboSort is not None:
for entry in roboSort:
if isinstance(entry, dict) and entry.get('type') == 'glyphList':
asc = entry.get('ascending')
desc = entry.get('descending')
if asc is not None:
entry['ascending'] = renameStrings(asc, newNames)
if desc is not None:
entry['descending'] = renameStrings(desc, newNames)
print('Writing', filename)
if not dryRun:
plistlib.writePlist(plist, filename)
评论列表
文章目录