()
| 217 | |
| 218 | |
| 219 | def main(): |
| 220 | argparser = ArgumentParser(description='Restore lost kerning') |
| 221 | |
| 222 | argparser.add_argument( |
| 223 | '-dry', dest='dryRun', action='store_const', const=True, default=False, |
| 224 | help='Do not modify anything, but instead just print what would happen.') |
| 225 | |
| 226 | argparser.add_argument( |
| 227 | 'srcFont', metavar='<fontfile>', type=str, |
| 228 | help='TrueType, OpenType or UFO fonts to gather glyph info from') |
| 229 | |
| 230 | argparser.add_argument( |
| 231 | 'diffFile', metavar='<diffile>', type=str, help='Diff file') |
| 232 | |
| 233 | args = argparser.parse_args() |
| 234 | |
| 235 | dryRun = args.dryRun |
| 236 | |
| 237 | agl = parseAGL('src/glyphlist.txt') |
| 238 | diacriticComps = loadGlyphCompositions('src/diacritics.txt') |
| 239 | |
| 240 | altUc2names, altName2ucs = loadAltNamesDB(agl, args.srcFont) |
| 241 | localUc2Names, localName2ucs = loadLocalNamesDB(agl, diacriticComps) |
| 242 | |
| 243 | canonicalGlyphName = lambda name: _canonicalGlyphName( |
| 244 | name, localName2ucs, localUc2Names, altName2ucs) |
| 245 | |
| 246 | deletedNames = loadNamesFromDiff(args.diffFile) # 10e15297b.diff |
| 247 | deletedDiacriticNames = OrderedDict() |
| 248 | |
| 249 | for glyphName, comp in diacriticComps.iteritems(): |
| 250 | if glyphName in deletedNames: |
| 251 | deletedDiacriticNames[glyphName] = comp |
| 252 | |
| 253 | |
| 254 | for fontPath in srcFontPaths: |
| 255 | addedGroupNames = set() |
| 256 | |
| 257 | oldFilenamePrefix = 'regular' |
| 258 | if fontPath.find('Bold') != -1: |
| 259 | oldFilenamePrefix = 'bold' |
| 260 | oldGroups, oldNameToGroups = loadGroups( |
| 261 | oldFilenamePrefix + '-groups.plist') |
| 262 | oldKerning, oldLIndex, oldRIndex, oldRGroupIndex = loadKerning( |
| 263 | oldFilenamePrefix + '-kerning.plist') |
| 264 | # lIndex : { name => <ref to plist right-hand side dict> } |
| 265 | # rIndex : { name => [(left-hand-side-name, kernVal), ...] } |
| 266 | |
| 267 | currGroupFilename = os.path.join(fontPath, 'groups.plist') |
| 268 | currKerningFilename = os.path.join(fontPath, 'kerning.plist') |
| 269 | currGroups, currNameToGroups = loadGroups(currGroupFilename) |
| 270 | currKerning, currLIndex, currRIndex, currRGroupIndex = loadKerning(currKerningFilename) |
| 271 | |
| 272 | for glyphName, comp in deletedDiacriticNames.iteritems(): |
| 273 | oldGroupMemberships = oldNameToGroups.get(glyphName) |
| 274 | localGlyphName, localUc = canonicalGlyphName(glyphName) |
| 275 | |
| 276 | # if glyphName != 'dcaron': |
no test coverage detected
searching dependent graphs…