def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True): reader = UFOReader(self.ufoPath) results = {} if doInfo: infoMatches = True info = self.font.info for attr, expectedValue in expectedFontInfo1To2Conversion.items(): writtenValue = getattr(info, attr) if expectedValue != writtenValue: infoMatches = False break results["info"]= infoMatches if doKerning: kerning = self.font.kerning.asDict() expectedKerning = reader.readKerning() results["kerning"] = expectedKerning == kerning if doGroups: groups = dict(self.font.groups) expectedGroups = reader.readGroups() results["groups"] = expectedGroups == groups if doFeatures: features = self.font.features.text expectedFeatures = expectedFormatVersion1Features # FontLab likes to add lines to the features, so skip blank lines. features = [line for line in features.splitlines() if line] expectedFeatures = [line for line in expectedFeatures.splitlines() if line] results["features"] = expectedFeatures == features if doLib: lib = dict(self.font.lib) expectedLib = reader.readLib() for key in removeFromFormatVersion1Lib: if key in expectedLib: del expectedLib[key] results["lib"] = expectedLib == lib return results
def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True): reader = UFOReader(self.ufoPath) results = {} if doInfo: infoMatches = True info = self.font.info for attr, expectedValue in fontInfoVersion2.items(): # cheat by skipping attrs that aren't supported if info._ufoToFLAttrMapping[attr]["nakedAttribute"] is None: continue writtenValue = getattr(info, attr) if expectedValue != writtenValue: infoMatches = False break results["info"]= infoMatches if doKerning: kerning = self.font.kerning.asDict() expectedKerning = reader.readKerning() results["kerning"] = expectedKerning == kerning if doGroups: groups = dict(self.font.groups) expectedGroups = reader.readGroups() results["groups"] = expectedGroups == groups if doFeatures: features = self.font.features.text expectedFeatures = reader.readFeatures() results["features"] = expectedFeatures == features if doLib: lib = dict(self.font.lib) expectedLib = reader.readLib() results["lib"] = expectedLib == lib return results
def extractFontFromUFO(pathOrFile, destination, doGlyphs=True, doInfo=True, doKerning=True, doGroups=True, doFeatures=True, doLib=True, customFunctions=[]): source = UFOReader(pathOrFile) if doInfo: source.readInfo(destination.info) if doKerning: kerning = source.readKerning() destination.kerning.update(kerning) if doGroups: groups = source.readGroups() destination.groups.update(groups) if doFeatures: features = source.readFeatures() destination.features.text = features if doLib: lib = source.readLib() destination.lib.update(lib) if doGlyphs: glyphSet = source.getGlyphSet() for glyphName in glyphSet.keys(): destination.newGlyph(glyphName) glyph = destination[glyphName] pointPen = glyph.getPointPen() glyphSet.readGlyph(glyphName=glyphName, glyphObject=glyph, pointPen=pointPen) for function in customFunctions: function(source, destination)
def compareToUFO(self): readerExpected = UFOReader(ufoPath1) readerWritten = UFOReader(self.dstDir) results = {} # info matches = True expectedPath = os.path.join(ufoPath1, "fontinfo.plist") writtenPath = os.path.join(self.dstDir, "fontinfo.plist") if not os.path.exists(writtenPath): matches = False else: expected = readPlist(expectedPath) written = readPlist(writtenPath) for attr, expectedValue in expected.items(): if expectedValue != written.get(attr): matches = False break results["info"] = matches # kerning matches = True expectedPath = os.path.join(ufoPath1, "kerning.plist") writtenPath = os.path.join(self.dstDir, "kerning.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["kerning"] = matches # groups matches = True expectedPath = os.path.join(ufoPath1, "groups.plist") writtenPath = os.path.join(self.dstDir, "groups.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["groups"] = matches # features matches = True expectedPath = os.path.join(ufoPath1, "features.fea") writtenPath = os.path.join(self.dstDir, "features.fea") if os.path.exists(writtenPath): matches = False results["features"] = matches # lib matches = True expectedPath = os.path.join(ufoPath1, "lib.plist") writtenPath = os.path.join(self.dstDir, "lib.plist") if not os.path.exists(writtenPath): matches = False else: writtenLib = readPlist(writtenPath) matches = readPlist(expectedPath) == writtenLib results["lib"] = matches return results
def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True): reader = UFOReader(self.ufoPath) results = {} if doInfo: infoMatches = True info = self.font.info for attr, expectedValue in expectedFontInfo1To2Conversion.items(): writtenValue = getattr(info, attr) if expectedValue != writtenValue: infoMatches = False break results["info"] = infoMatches if doKerning: kerning = self.font.kerning.asDict() expectedKerning = reader.readKerning() results["kerning"] = expectedKerning == kerning if doGroups: groups = dict(self.font.groups) expectedGroups = reader.readGroups() results["groups"] = expectedGroups == groups if doFeatures: features = self.font.features.text expectedFeatures = expectedFormatVersion1Features # FontLab likes to add lines to the features, so skip blank lines. features = [line for line in features.splitlines() if line] expectedFeatures = [ line for line in expectedFeatures.splitlines() if line ] results["features"] = expectedFeatures == features if doLib: lib = dict(self.font.lib) expectedLib = reader.readLib() for key in removeFromFormatVersion1Lib: if key in expectedLib: del expectedLib[key] results["lib"] = expectedLib == lib return results
def isUFO(pathOrFile): if not isinstance(pathOrFile, basestring): return False if os.path.splitext(pathOrFile)[-1].lower() != ".ufo": return False if not os.path.isdir(pathOrFile): return False try: reader = UFOReader(pathOrFile) except: return False return True
def compareToUFO(self, doInfo=True): reader = UFOReader(ufoPath2) results = {} # info infoMatches = True info = self.font.info for attr, expectedValue in fontInfoVersion2.items(): writtenValue = getattr(info, attr) if expectedValue != writtenValue: infoMatches = False break results["info"]= infoMatches # kerning kerning = self.font.kerning.asDict() expectedKerning = reader.readKerning() results["kerning"] = expectedKerning == kerning # groups groups = dict(self.font.groups) expectedGroups = reader.readGroups() results["groups"] = expectedGroups == groups # features features = self.font.features.text expectedFeatures = reader.readFeatures() results["features"] = expectedFeatures == features # lib lib = dict(self.font.lib) expectedLib = reader.readLib() results["lib"] = expectedLib == lib return results
def _loadData(self, path): from robofab.ufoLib import UFOReader reader = UFOReader(path) fontLib = reader.readLib() # info reader.readInfo(self.info) # kerning self.kerning.update(reader.readKerning()) self.kerning.setChanged(False) # groups self.groups.update(reader.readGroups()) # features if reader.formatVersion == 1: # migrate features from the lib features = [] classes = fontLib.get("org.robofab.opentype.classes") if classes is not None: del fontLib["org.robofab.opentype.classes"] features.append(classes) splitFeatures = fontLib.get("org.robofab.opentype.features") if splitFeatures is not None: order = fontLib.get("org.robofab.opentype.featureorder") if order is None: order = splitFeatures.keys() order.sort() else: del fontLib["org.robofab.opentype.featureorder"] del fontLib["org.robofab.opentype.features"] for tag in order: oneFeature = splitFeatures.get(tag) if oneFeature is not None: features.append(oneFeature) features = "\n".join(features) else: features = reader.readFeatures() self.features.text = features # hint data self.psHints = PostScriptFontHintValues(self) if postScriptHintDataLibKey in fontLib: del fontLib[postScriptHintDataLibKey] # lib self.lib.update(fontLib) # glyphs self._glyphSet = reader.getGlyphSet() self._hasNotChanged(doGlyphs=False)
def combineKerning(path1, path2, destPath, WORRY=False): """ This is a rather nasty tool, but it does the job. Give it two UFOs that you want to combine the kerning from. It'll go through, and combine the kerning of two UFOs. If WORRY is set to True, it will enforce a rule that one can't add together kerning that has groups which contain different members. It finishes by writing out a 'dummy' UFO, one that contains no glyphs, but only the groups and kerning info for the combined kerning. One must go in a open the UFO package to grab the kerning and put in into a UFO with the glyphs combined. This way, at least, the source UFOs are not touched, incase one needs to beat a retreat to the source UFOs. """ ufo1 = UFOReader(path1) groups1 = ufo1.readGroups() kerning1 = ufo1.readKerning() ufo2 = UFOReader(path2) groups2 = ufo2.readGroups() kerning2 = ufo2.readKerning() combinedKerning = dict(kerning1) for pair, value in kerning2.items(): if pair in combinedKerning: assert value == combinedKerning[pair] combinedKerning[pair] = value combinedGroups = {} for groups in (groups1, groups2): for name, group in groups.items(): if not name.startswith("@MMK_"): continue if name in combinedGroups and WORRY: assert group == combinedGroups[name] combinedGroups[name] = group else: combinedGroups[name] = group ufo = UFOWriter(destPath) ufo.writeKerning(combinedKerning) ufo.writeGroups(combinedGroups)
def compareToUFO(self, doInfo=True): reader = UFOReader(ufoPath1) results = {} # info infoMatches = True info = self.font.info for attr, expectedValue in expectedFontInfo1To2Conversion.items(): writtenValue = getattr(info, attr) if expectedValue != writtenValue: infoMatches = False break results["info"]= infoMatches # kerning kerning = self.font.kerning.asDict() expectedKerning = reader.readKerning() results["kerning"] = expectedKerning == kerning # groups groups = dict(self.font.groups) expectedGroups = reader.readGroups() results["groups"] = expectedGroups == groups # features features = self.font.features.text f = open(os.path.join(ufoPath2, "features.fea"), "r") expectedFeatures = f.read() f.close() match = True features = [line for line in features.splitlines() if line] expectedFeatures = [line for line in expectedFeatures.splitlines() if line] if expectedFeatures != features or reader.readFeatures() != "": match = False results["features"] = match # lib lib = dict(self.font.lib) expectedLib = reader.readLib() for key in removeFromFormatVersion1Lib: if key in expectedLib: del expectedLib[key] results["lib"] = expectedLib == lib return results
def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True): reader = UFOReader(self.ufoPath) results = {} if doInfo: infoMatches = True info = self.font.info for attr, expectedValue in fontInfoVersion2.items(): # cheat by skipping attrs that aren't supported if info._ufoToFLAttrMapping[attr]["nakedAttribute"] is None: continue writtenValue = getattr(info, attr) if expectedValue != writtenValue: infoMatches = False break results["info"] = infoMatches if doKerning: kerning = self.font.kerning.asDict() expectedKerning = reader.readKerning() results["kerning"] = expectedKerning == kerning if doGroups: groups = dict(self.font.groups) expectedGroups = reader.readGroups() results["groups"] = expectedGroups == groups if doFeatures: features = self.font.features.text expectedFeatures = reader.readFeatures() results["features"] = expectedFeatures == features if doLib: lib = dict(self.font.lib) expectedLib = reader.readLib() results["lib"] = expectedLib == lib return results
def compareToUFO(self): readerExpected = UFOReader(ufoPath2) readerWritten = UFOReader(self.dstDir) results = {} # info matches = True expectedPath = os.path.join(ufoPath2, "fontinfo.plist") writtenPath = os.path.join(self.dstDir, "fontinfo.plist") if not os.path.exists(writtenPath): matches = False else: expected = readPlist(expectedPath) written = readPlist(writtenPath) for attr, expectedValue in expected.items(): if expectedValue != written[attr]: matches = False break results["info"] = matches # kerning matches = True expectedPath = os.path.join(ufoPath2, "kerning.plist") writtenPath = os.path.join(self.dstDir, "kerning.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["kerning"] = matches # groups matches = True expectedPath = os.path.join(ufoPath2, "groups.plist") writtenPath = os.path.join(self.dstDir, "groups.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["groups"] = matches # features matches = True expectedPath = os.path.join(ufoPath2, "features.fea") writtenPath = os.path.join(self.dstDir, "features.fea") if not os.path.exists(writtenPath): matches = False else: f = open(expectedPath, "r") expectedText = f.read() f.close() f = open(writtenPath, "r") writtenText = f.read() f.close() # FontLab likes to add lines to the features, so skip blank lines. expectedText = [line for line in expectedText.splitlines() if line] writtenText = [line for line in writtenText.splitlines() if line] matches = "\n".join(expectedText) == "\n".join(writtenText) results["features"] = matches # lib matches = True expectedPath = os.path.join(ufoPath2, "lib.plist") writtenPath = os.path.join(self.dstDir, "lib.plist") if not os.path.exists(writtenPath): matches = False else: writtenLib = readPlist(writtenPath) matches = readPlist(expectedPath) == writtenLib results["lib"] = matches return results
def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True): readerExpected = UFOReader(ufoPath1) readerWritten = UFOReader(self.dstDir) results = {} if doInfo: matches = True expectedPath = os.path.join(ufoPath1, "fontinfo.plist") writtenPath = os.path.join(self.dstDir, "fontinfo.plist") if not os.path.exists(writtenPath): matches = False else: expected = readPlist(expectedPath) written = readPlist(writtenPath) for attr, expectedValue in expected.items(): if expectedValue != written[attr]: matches = False break results["info"] = matches if doKerning: matches = True expectedPath = os.path.join(ufoPath1, "kerning.plist") writtenPath = os.path.join(self.dstDir, "kerning.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["kerning"] = matches if doGroups: matches = True expectedPath = os.path.join(ufoPath1, "groups.plist") writtenPath = os.path.join(self.dstDir, "groups.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["groups"] = matches if doFeatures: matches = True featuresPath = os.path.join(self.dstDir, "features.fea") libPath = os.path.join(self.dstDir, "lib.plist") if os.path.exists(featuresPath): matches = False else: fontLib = readPlist(libPath) writtenText = [fontLib.get("org.robofab.opentype.classes", "")] features = fontLib.get("org.robofab.opentype.features", {}) featureOrder = fontLib.get("org.robofab.opentype.featureorder", []) for featureName in featureOrder: writtenText.append(features.get(featureName, "")) writtenText = "\n".join(writtenText) # FontLab likes to add lines to the features, so skip blank lines. expectedText = [ line for line in expectedFormatVersion1Features.splitlines() if line ] writtenText = [ line for line in writtenText.splitlines() if line ] matches = "\n".join(expectedText) == "\n".join(writtenText) results["features"] = matches if doLib: matches = True expectedPath = os.path.join(ufoPath1, "lib.plist") writtenPath = os.path.join(self.dstDir, "lib.plist") if not os.path.exists(writtenPath): matches = False else: # the test file doesn't have the glyph order # so purge it from the written writtenLib = readPlist(writtenPath) del writtenLib["org.robofab.glyphOrder"] matches = readPlist(expectedPath) == writtenLib results["lib"] = matches return results
def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True): readerExpected = UFOReader(ufoPath2) readerWritten = UFOReader(self.dstDir) results = {} if doInfo: matches = True expectedPath = os.path.join(ufoPath2, "fontinfo.plist") writtenPath = os.path.join(self.dstDir, "fontinfo.plist") if not os.path.exists(writtenPath): matches = False else: dummyFont = NewFont() _ufoToFLAttrMapping = dict(dummyFont.info._ufoToFLAttrMapping) dummyFont.close() expected = readPlist(expectedPath) written = readPlist(writtenPath) for attr, expectedValue in expected.items(): # cheat by skipping attrs that aren't supported if _ufoToFLAttrMapping[attr]["nakedAttribute"] is None: continue if expectedValue != written[attr]: matches = False break results["info"] = matches if doKerning: matches = True expectedPath = os.path.join(ufoPath2, "kerning.plist") writtenPath = os.path.join(self.dstDir, "kerning.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["kerning"] = matches if doGroups: matches = True expectedPath = os.path.join(ufoPath2, "groups.plist") writtenPath = os.path.join(self.dstDir, "groups.plist") if not os.path.exists(writtenPath): matches = False else: matches = readPlist(expectedPath) == readPlist(writtenPath) results["groups"] = matches if doFeatures: matches = True expectedPath = os.path.join(ufoPath2, "features.fea") writtenPath = os.path.join(self.dstDir, "features.fea") if not os.path.exists(writtenPath): matches = False else: f = open(expectedPath, "r") expectedText = f.read() f.close() f = open(writtenPath, "r") writtenText = f.read() f.close() # FontLab likes to add lines to the features, so skip blank lines. expectedText = [ line for line in expectedText.splitlines() if line ] writtenText = [ line for line in writtenText.splitlines() if line ] matches = "\n".join(expectedText) == "\n".join(writtenText) results["features"] = matches if doLib: matches = True expectedPath = os.path.join(ufoPath2, "lib.plist") writtenPath = os.path.join(self.dstDir, "lib.plist") if not os.path.exists(writtenPath): matches = False else: # the test file doesn't have the glyph order # so purge it from the written writtenLib = readPlist(writtenPath) del writtenLib["org.robofab.glyphOrder"] matches = readPlist(expectedPath) == writtenLib results["lib"] = matches return results
def importKerningMMK (font, UFOfilepath): report = 'Import Kerning Report ' + asctime() + '\nUFO file: ' + UFOfilepath kernClasses = {} kern_L_R_table = {} kernTable = {} feaClasses = {} dicGroups = {} UFO = UFOReader(UFOfilepath) kernGroups = UFO.readGroups() kernTable = UFO.readKerning() # progress = ProgressBar('Converting group names', ticks = len(kernGroups.items())) for groupname, content in kernGroups.items(): # progress.tick() if len(content) != 0: if content[0] == '': content.pop(0) if groupname.startswith('@'): # @MMK_ = MM kern class classname = '_' + groupname[7:] baseGlyph = content[0] content[0] = baseGlyph + '\'' classcontent = content dicGroups[groupname] = baseGlyph if kernClasses.has_key(classname): if kernClasses[classname] == classcontent: kern_L_R_table[classname] = (True, True) else: classname = generateClassName(kernClasses, classname) if groupname[5] == 'L': # @MMK_L_namegroup kern_L_R_table[classname] = (True, False) elif groupname[5] == 'R': # @MMK_R_namegroup kern_L_R_table[classname] = (False, True) else: print "WARNING! Something wrong whith LEFT/RIGHT identification...", groupname else: if groupname[5] == 'L': # @MMK_L_namegroup kern_L_R_table[classname] = (True, False) elif groupname[5] == 'R': # @MMK_R_namegroup kern_L_R_table[classname] = (False, True) else: print "WARNING! Something wrong whith LEFT/RIGHT identification...", groupname kernClasses[classname] = classcontent else: # fea class feaClasses[groupname] = content#' '.join(content) else: print 'WARNING! Group with NULL content: %s Ignored.' % groupname report = report + '\n\nGroup with NULL content: %s Ignored.' % groupname # progress.close() # progress = ProgressBar('Merging kerning and fea-classes',ticks = len(kernClasses.items()) + len(feaClasses.items())) classes = {} for classname, content in kernClasses.items(): # progress.tick() classes[classname] = content#.split(' ') for classname, content in feaClasses.items(): # progress.tick() classes[classname] = content#.split(' ') # progress.close() report = report + diffGroups(font.groups, classes, kern_L_R_table) font.groups.clear() font.groups = classes font.update() # progress = ProgressBar('Left/Right identification', ticks = len(font.naked().classes)) for index, kernClass in enumerate(font.naked().classes): # progress.tick() if kernClass.startswith('_'): nameClass = kernClass.split(':')[0] leftBool, rightBool = kern_L_R_table[nameClass] font.naked().SetClassFlags(index, leftBool, rightBool) font.update() print '\nConverting Groups from MetricsMachine to Fontlab Classes: DONE\n' # progress.close() # progress = ProgressBar('Left pairs converting', ticks = len(kernTable.items())) new_kern1 = {} for (left, right), value in kernTable.items(): # progress.tick() if dicGroups.has_key(left): baseGlyph = dicGroups[left] new_kern1[(baseGlyph, right)] = value else: if left.startswith('@'): print "WARNING! Something wrong with pair:", left, right, value, 'Ignored.' else: new_kern1[(left, right)] = value # progress.close() # progress = ProgressBar('Right pairs converting', ticks = len(new_kern1.items())) new_kern2 = {} for (left, right), value in new_kern1.items(): # progress.tick() if dicGroups.has_key(right): baseGlyph = dicGroups[right] new_kern2[(left, baseGlyph)] = value else: if right.startswith('@'): print "WARNING! Something wrong with pair:", left, right, value, 'Ignored.' else: new_kern2[(left, right)] = value # progress.close() report = report + diffKerning(font.kerning, new_kern2) font.kerning.clear() font.kerning.update(new_kern2) font.update() reportfile = open(UFOfilepath.replace('.ufo', '.log'), 'w') reportfile.write(report) reportfile.close() print '\nConverting Kerning from MetricsMachine to Fontlab: DONE\n'
def importKerningMMK(font, UFOfilepath): report = 'Import Kerning Report ' + asctime( ) + '\nUFO file: ' + UFOfilepath kernClasses = {} kern_L_R_table = {} kernTable = {} feaClasses = {} dicGroups = {} UFO = UFOReader(UFOfilepath) kernGroups = UFO.readGroups() kernTable = UFO.readKerning() # progress = ProgressBar('Converting group names', ticks = len(kernGroups.items())) for groupname, content in kernGroups.items(): # progress.tick() if len(content) != 0: if content[0] == '': content.pop(0) if groupname.startswith('@'): # @MMK_ = MM kern class classname = '_' + groupname[7:] baseGlyph = content[0] content[0] = baseGlyph + '\'' classcontent = content dicGroups[groupname] = baseGlyph if kernClasses.has_key(classname): if kernClasses[classname] == classcontent: kern_L_R_table[classname] = (True, True) else: classname = generateClassName(kernClasses, classname) if groupname[5] == 'L': # @MMK_L_namegroup kern_L_R_table[classname] = (True, False) elif groupname[5] == 'R': # @MMK_R_namegroup kern_L_R_table[classname] = (False, True) else: print "WARNING! Something wrong whith LEFT/RIGHT identification...", groupname else: if groupname[5] == 'L': # @MMK_L_namegroup kern_L_R_table[classname] = (True, False) elif groupname[5] == 'R': # @MMK_R_namegroup kern_L_R_table[classname] = (False, True) else: print "WARNING! Something wrong whith LEFT/RIGHT identification...", groupname kernClasses[classname] = classcontent else: # fea class feaClasses[groupname] = content #' '.join(content) else: print 'WARNING! Group with NULL content: %s Ignored.' % groupname report = report + '\n\nGroup with NULL content: %s Ignored.' % groupname # progress.close() # progress = ProgressBar('Merging kerning and fea-classes',ticks = len(kernClasses.items()) + len(feaClasses.items())) classes = {} for classname, content in kernClasses.items(): # progress.tick() classes[classname] = content #.split(' ') for classname, content in feaClasses.items(): # progress.tick() classes[classname] = content #.split(' ') # progress.close() report = report + diffGroups(font.groups, classes, kern_L_R_table) font.groups.clear() font.groups = classes font.update() # progress = ProgressBar('Left/Right identification', ticks = len(font.naked().classes)) for index, kernClass in enumerate(font.naked().classes): # progress.tick() if kernClass.startswith('_'): nameClass = kernClass.split(':')[0] leftBool, rightBool = kern_L_R_table[nameClass] font.naked().SetClassFlags(index, leftBool, rightBool) font.update() print '\nConverting Groups from MetricsMachine to Fontlab Classes: DONE\n' # progress.close() # progress = ProgressBar('Left pairs converting', ticks = len(kernTable.items())) new_kern1 = {} for (left, right), value in kernTable.items(): # progress.tick() if dicGroups.has_key(left): baseGlyph = dicGroups[left] new_kern1[(baseGlyph, right)] = value else: if left.startswith('@'): print "WARNING! Something wrong with pair:", left, right, value, 'Ignored.' else: new_kern1[(left, right)] = value # progress.close() # progress = ProgressBar('Right pairs converting', ticks = len(new_kern1.items())) new_kern2 = {} for (left, right), value in new_kern1.items(): # progress.tick() if dicGroups.has_key(right): baseGlyph = dicGroups[right] new_kern2[(left, baseGlyph)] = value else: if right.startswith('@'): print "WARNING! Something wrong with pair:", left, right, value, 'Ignored.' else: new_kern2[(left, right)] = value # progress.close() report = report + diffKerning(font.kerning, new_kern2) font.kerning.clear() font.kerning.update(new_kern2) font.update() reportfile = open(UFOfilepath.replace('.ufo', '.log'), 'w') reportfile.write(report) reportfile.close() print '\nConverting Kerning from MetricsMachine to Fontlab: DONE\n'