def convertToOTF(ttfPath, dest, report): temp = tempfile.mkstemp(suffix=".otf")[1] font = OpenFont(ttfPath, showUI=False) font.kerning.clear() for attr in font.info.asDict().keys(): if attr not in defaultFontInfoAttributes: setattr(font.info, attr, None) result = font.generate(path=temp, format="otf", decompose=False, checkOutlines=False, autohint=False, releaseMode=True, glyphOrder=font.glyphOrder) font.close() report.write(result) sourceFont = TTFont(temp) sourceFontWithTables = TTFont(ttfPath) for table in [ "loca", "OS/2", "cmap", "name", "GSUB", "GPOS", "GDEF", "kern" ]: if table in sourceFontWithTables: sourceFont[table] = sourceFontWithTables[table] sourceFont.save(dest) result = OTFAutohint(dest) report.writeItems(result) os.remove(temp)
def button_apply_callback(self, sender): if self.otfs_folder is not None: _otfs_paths = walk(self.otfs_folder, 'otf') if len(_otfs_paths) > 0: # set ufos folder if self.ufos_folder is None: self.ufos_folder = self.otfs_folder # print settings boolstring = ["False", "True"] print 'batch generating ufos for all otfs in folder...\n' print '\totfs folder: %s' % self.otfs_folder print '\tufos folder: %s' % self.ufos_folder print # batch convert self.w.bar.start() for otf_path in _otfs_paths: print '\tcreating ufo from %s...' % os.path.split(otf_path)[1] otf = OpenFont(otf_path, showUI=True) # does not work without UI ufo_file = os.path.splitext(os.path.split(otf_path)[1])[0] + '.ufo' ufo_path = os.path.join(self.ufos_folder, ufo_file) otf.save(ufo_path) # close otf.close() print '\t\tufo path: %s' % ufo_path print '\t\tconversion sucessful? %s\n' % os.path.exists(ufo_path) # done self.w.bar.stop() print print '...done.\n' # no font in folder else: print no_font_in_folder
def importFontInfoFromUFOtoCurrentFont(): aFontPath = getFile(messageText='Please, choose a UFO file', fileTypes=['ufo'])[0] if aFontPath.endswith('.ufo'): if version[0] == '2': sourceFont = OpenFont(aFontPath, showInterface=False) else: sourceFont = OpenFont(aFontPath, showUI=False) sourceFontInfos = sourceFont.info.asDict() for eachAttribute, eachValue in sourceFontInfos.items(): setattr(CurrentFont().info, eachAttribute, eachValue)
def run(self, destDir, progress): paths = self.controller.get(["ufo"]) report = Report() tempDir = tempfile.mkdtemp() tempExportPaths = self._generateCallback(tempDir, progress, report) progress.update("Merging Tables...") report.writeTitle("Merged Fonts:") report.newLine() tableNames = [ item["tableName"] for item in self.tableList if item["add"] ] for fontIndex, path in enumerate(paths): font = OpenFont(path, showUI=False) binarySourcepath = font.lib.get( "com.typemytype.robofont.binarySource") tempExportPath = tempExportPaths[fontIndex] if binarySourcepath: binaryIsOpenType = os.path.splitext( binarySourcepath)[1].lower() in [".ttf", ".otf"] tempIsOpenType = os.path.splitext( tempExportPath)[1].lower() in [".ttf", ".otf"] if binaryIsOpenType and tempIsOpenType: binarySource = TTFont(binarySourcepath) tempFont = TTFont(tempExportPath) fileName = os.path.basename(tempExportPath) if not self.controller.keepFileNames(): fileName = "%s-%s" % (font.info.familyName, font.info.styleName) path = os.path.join(destDir, fileName) report.writeTitle(os.path.basename(path), "'") report.write("source: %s" % path) report.write("binary source: %s" % binarySource) report.newLine() report.indent() for table in tableNames: if table in binarySource: report.write("merge %s table" % table) tempFont[table] = binarySource[table] report.dedent() report.newLine() tempFont.save(path) tempFont.close() binarySource.close() font.close() reportPath = os.path.join(destDir, "Binary Merge Report.txt") report.save(reportPath) if os.path.exists(tempDir): shutil.rmtree(tempDir)
def generateOTF(ufoPath, dest, report): font = OpenFont(ufoPath, showUI=False) result = font.generate(path=dest, format="otf", decompose=False, checkOutlines=True, autohint=False, releaseMode=True, glyphOrder=font.glyphOrder) font.close() report.write(result) result = OTFAutohint(dest) report.writeItems(result)
def reportButtonCallback(self, sender): popUpIndex = self.w.fontsPopUp.get() if popUpIndex == 0: # all fonts fontsToProcess = self.allFonts else: fontsToProcess = [self.allFonts[popUpIndex]] PDF_folder = getFolder('Choose where to save the reports')[0] templateFont = OpenFont(TEMPLATE_FONT_PATH, showUI=False) justNow = datetime.now() self._drawReport( referenceFont=templateFont, someFonts=fontsToProcess, glyphNames=templateFont.glyphOrder, reportPath=os.path.join( PDF_folder, '{:0>4d}{:0>2d}{:0>2d}_templateCompliant.pdf'.format( justNow.year, justNow.month, justNow.day)), caption='Template Compliant') allGlyphNames = set() for eachFont in fontsToProcess: allGlyphNames = allGlyphNames | set(eachFont.glyphOrder) leftovers = allGlyphNames - set(templateFont.glyphOrder) self._drawReport(referenceFont=templateFont, someFonts=fontsToProcess, glyphNames=leftovers, reportPath=os.path.join( PDF_folder, '{:0>4d}{:0>2d}{:0>2d}_extraTemplate.pdf'.format( justNow.year, justNow.month, justNow.day)), caption='Extra Template')
def otf2ttf(otf_path, ttf_path): ''' Generate a .ttf font from an .otf source font. Requires RoboFont. ''' otf_font = OpenFont(otf_path, showInterface=False) ### is this curve conversion really necessary? ### some scripts do just `font.generate('myfont.ttf', 'ttf')` coreFont = otf_font.naked() for glyph in coreFont: curveConverter.bezier2quadratic(glyph) coreFont.segmentType = glyph.segmentType ### end conversion otf_font.generate(ttf_path, 'ttf') return os.path.exists(ttf_path)
def otf2ttf(otf_path, ttf_path): ''' Generate a .ttf font from an .otf source font. Requires RoboFont. ''' otf_font = OpenFont(otf_path, showUI=False) ### is this curve conversion really necessary? ### some scripts do just `font.generate('myfont.ttf', 'ttf')` coreFont = otf_font.naked() for glyph in coreFont: curveConverter.bezier2quadratic(glyph) coreFont.segmentType = glyph.segmentType ### end conversion otf_font.generate(ttf_path, 'ttf') return os.path.exists(ttf_path)
def addCallback(self, sender=None): """ Open a font without UI and add it to the font list. """ f = OpenFont(None, showInterface=False) if f is None: return self.fonts.append(f) self.w.fontList.set(self._getFontItems())
def button_apply_callback(self, sender): if self.otfs_folder is not None: _otfs_paths = walk(self.otfs_folder, 'otf') if len(_otfs_paths) > 0: # set ufos folder if self.ufos_folder is None: self.ufos_folder = self.otfs_folder # print settings boolstring = ["False", "True"] print('batch generating ufos for all otfs in folder...\n') print('\totfs folder: %s' % self.otfs_folder) print('\tufos folder: %s' % self.ufos_folder) print() # batch convert self.w.bar.start() for otf_path in _otfs_paths: print('\tcreating ufo from %s...' % os.path.split(otf_path)[1]) otf = OpenFont(otf_path, showUI=True) # does not work without UI ufo_file = os.path.splitext(os.path.split(otf_path)[1])[0] + '.ufo' ufo_path = os.path.join(self.ufos_folder, ufo_file) otf.save(ufo_path) # close otf.close() print('\t\tufo path: %s' % ufo_path) print('\t\tconversion sucessful? %s\n' % os.path.exists(ufo_path)) # done self.w.bar.stop() print() print('...done.\n') # no font in folder else: print(no_font_in_folder)
def button_apply_callback(self, sender): _otfs_folder = self.w.otfs_folder_value.get() _ufos_folder = self.w.ufos_folder_value.get() if _otfs_folder != None: _otfs_paths = walk(_otfs_folder, 'otf') if len(_otfs_paths) > 0: # set ufos folder if _ufos_folder == None: _ufos_folder = _otfs_folder # print settings boolstring = ("False", "True") print 'batch generating .ufos for all .otfs in folder...\n' print '\totfs folder: %s' % _otfs_folder print '\tufos folder: %s' % _ufos_folder print # batch convert self.w.bar.start() for otf_path in _otfs_paths: print '\tsaving .ufo for %s...' % os.path.split(otf_path)[1] otf = OpenFont(otf_path, showUI=True) ufo_file = os.path.splitext(os.path.split(otf_path)[1])[0] + '.ufo' ufo_path = os.path.join(_ufos_folder, ufo_file) otf.save(ufo_path) # close otf.close() print '\t\tufo path: %s' % ufo_path print '\t\tconversion sucessful? %s\n' % os.path.exists(ufo_path) # done self.w.bar.stop() print print '...done.\n'
def extract_encoding(ufo_path, enc_path=None): ''' Extract encoding data from an ufo's glyphOrder attribute. ''' # get glyph names from ufo try: ufo = OpenFont(ufo_path, showUI=False) except: ufo = OpenFont(ufo_path) enc = '' for glyph_name in ufo.glyphOrder: enc += '%s\n' % glyph_name ufo.close() # save to .enc file if enc_path is not None: enc_file = open(enc_path, 'w') enc_file.write(enc) enc_file.close() # done return enc
def openFont(nameOrPath, showUI=False): """ Open a font defined by the name of path. If the font is already open in RoboFont, then answer. """ if isRoboFont(): from mojo.roboFont import AllFonts, OpenFont for f in AllFonts(): if nameOrPath == f.info.familyName or f.path.endswith(nameOrPath): return f assert os.path.exists(nameOrPath) return OpenFont(nameOrPath, showUI=showUI) # Else not in RoboFont, use plain fontParts instead from fontParts.fontshell.font import RFont #print('RFONT', nameOrPath) return RFont(nameOrPath, showInterface=showUI)
def convertToTTF(otfPath, dest, report): temp = tempfile.mkstemp(suffix=".ttf")[1] tempDest = tempfile.mkstemp(suffix=".ttf")[1] font = OpenFont(otfPath, showUI=False) font.lib[shouldAddPointsInSplineConversionLibKey] = 1 font.kerning.clear() for attr in font.info.asDict().keys(): if attr not in defaultFontInfoAttributes: setattr(font.info, attr, None) result = font.generate(path=temp, format="ttf", decompose=False, checkOutlines=False, autohint=False, releaseMode=True, glyphOrder=font.glyphOrder) font.close() report.write(result) sourceFont = TTFont(temp) sourceFontWithTables = TTFont(otfPath) for table in [ "loca", "OS/2", "cmap", "name", "GSUB", "GPOS", "GDEF", "kern" ]: if table in sourceFontWithTables: sourceFont[table] = sourceFontWithTables[table] fixMetrics(sourceFont) sourceFont.save(tempDest) sourceFont.close() del sourceFont sourceFontWithTables.close() del sourceFontWithTables autohintOptions = getExtensionDefault(settingsIdentifier, defaultOptions) result = TTFAutohint(tempDest, dest, autohintOptions) report.writeItems(result) os.remove(temp) os.remove(tempDest)
def generateTTF(ufoPath, dest, report): tempDest = tempfile.mkstemp(suffix=".ttf")[1] font = OpenFont(ufoPath, showUI=False) font.lib[shouldAddPointsInSplineConversionLibKey] = 1 result = font.generate(path=tempDest, format="ttf", decompose=False, checkOutlines=True, autohint=False, releaseMode=True, glyphOrder=font.glyphOrder) font.close() report.write(result) autohintOptions = getExtensionDefault(settingsIdentifier, defaultOptions) result = TTFAutohint(tempDest, dest, autohintOptions) report.writeItems(result) os.remove(tempDest)
MARGIN_LFT = 15 MARGIN_RGT = 15 MARGIN_TOP = 15 MARGIN_COL = 10 MARGIN_ROW = 15 MARGIN_BTM = 10 MARGIN_HALFROW = 7 RIGHT_COLUMN = 180 RED = (1, 0, 0) BLACK = (0, 0, 0) RESOURCES_FOLDER = os.path.join(os.path.dirname(__file__), '..', 'resources') if version[0] == '2': NOT_DEF_GLYPH = OpenFont(os.path.join(RESOURCES_FOLDER, 'notdef.ufo'), showInterface=False)['.notdef'] else: NOT_DEF_GLYPH = OpenFont(os.path.join(RESOURCES_FOLDER, 'notdef.ufo'), showUI=False)['.notdef'] # the control factory class MultiFontMetricsWindow(BaseWindowController): # attrs textModeOptions = ['Loaded Strings', 'Typewriter'] textMode = textModeOptions[0] selectedGlyph = None subscribedGlyph = None
def alignCallback(self, sender): """ Change the alignment status """ postEvent(f"{DEFAULTKEY}.alignmentDidChange") def contextEditCallback(self, sender): postEvent(f"{DEFAULTKEY}.contextDidChange", position=sender.title) if __name__ == "__main__": if DEBUG_MODE: testFontsFolder = Path.home() / "Desktop/mutatorSans" for eachFontPath in [ ff for ff in testFontsFolder.iterdir() if ff.suffix == ".ufo" ]: OpenFont(eachFontPath, showInterface=True) try: OpenWindow(OverlayUFOs) except Exception as error: for eachFont in AllFonts(): eachFont.close() raise error else: OpenWindow(OverlayUFOs)
def importButtonCallback(self, sender): if not len(self.selectedMasters): return if self.verbose: print('importing glyphs from selected sources...\n') # mode 0 : fonts → fonts if self.importMode == 0: for master in self.selectedMasters: ufoPath = self._sources[master['name']] srcFont = OpenFont(ufoPath, showInterface=False) tmpFont = NewFont(familyName=srcFont.info.familyName, styleName=srcFont.info.styleName, showInterface=False) glyphsFolder = os.path.join(ufoPath, 'glyphs') ufoName = splitall(glyphsFolder)[-2] if self.verbose: print(f'\t{ufoName}:') for glyphName in self.glyphNames: if glyphName not in srcFont: if self.verbose: print(f'\t\t{glyphName} not in font.') continue srcGlyph = srcFont[glyphName] if srcGlyph.components: for component in srcGlyph.components: if not component.baseGlyph in tmpFont: if self.verbose: print(f'\t\timporting {component.baseGlyph} ({glyphName})...') tmpFont[component.baseGlyph] = srcFont[component.baseGlyph] tmpFont[component.baseGlyph].lib[self.glyphSetPathKey] = glyphsFolder if self.verbose: print(f'\t\timporting {glyphName}...') tmpFont[glyphName] = srcGlyph tmpFont[glyphName].lib[self.glyphSetPathKey] = glyphsFolder tmpFont.openInterface() if self.verbose: print() # mode 1 : fonts → glyphs if self.importMode == 1: tmpFont = CurrentFont() if tmpFont is None: tmpFont = NewFont(familyName='tempEdit') for i, master in enumerate(self.selectedMasters): ufoPath = self._sources[master['name']] if not os.path.exists(ufoPath): if self.verbose: print(f'source file does not exist: {ufoPath}') continue srcFont = OpenFont(ufoPath, showInterface=False) glyphsFolder = os.path.join(ufoPath, 'glyphs') ufoName = splitall(glyphsFolder)[-2] glyphNameExtension = os.path.splitext(ufoName)[0] for glyphName in self.glyphNames: tmpGlyphName = f'{glyphName}.{glyphNameExtension}' if glyphName not in srcFont: if self.verbose: print(f'\t\tcreating {glyphName}...') tmpFont.newGlyph(tmpGlyphName) else: srcGlyph = srcFont[glyphName] for component in srcGlyph.components: if component.baseGlyph not in tmpFont: if component.baseGlyph not in srcFont: continue if self.verbose: print(f'\t\timporting {component.baseGlyph} ({glyphName})...') tmpBaseGlyph = f'{component.baseGlyph}.{glyphNameExtension}' tmpFont[tmpBaseGlyph] = srcFont[component.baseGlyph] tmpFont[tmpBaseGlyph].lib[self.glyphSetPathKey] = glyphsFolder if self.verbose: print(f'\t\timporting {glyphName}...') tmpFont.newGlyph(tmpGlyphName) tmpFont[tmpGlyphName].appendGlyph(srcGlyph) tmpFont[tmpGlyphName].width = srcGlyph.width tmpFont[tmpGlyphName].lib[self.glyphSetPathKey] = glyphsFolder if 'background' not in tmpFont.layerOrder: tmpFont.newLayer('background') if self.verbose: print() # mode 2 : fonts → layers else: tmpFont = CurrentFont() if tmpFont is None: tmpFont = NewFont(familyName='tempEdit') for i, master in enumerate(self.selectedMasters): ufoPath = self._sources[master['name']] if not os.path.exists(ufoPath): if self.verbose: print(f'source file does not exist: {ufoPath}') continue srcFont = OpenFont(ufoPath, showInterface=False) glyphsFolder = os.path.join(ufoPath, 'glyphs') ufoName = splitall(glyphsFolder)[-2] layerName = os.path.splitext(ufoName)[0] tmpLayer = tmpFont.newLayer(layerName) if self.verbose: print(f'\t{ufoName}:') if i == 0: tmpFont.defaultLayer = tmpLayer if 'foreground' in tmpFont.layerOrder: tmpFont.removeLayer('foreground') for glyphName in self.glyphNames: if glyphName not in srcFont: if self.verbose: print(f'\t\tcreating {glyphName}...') tmpLayer.newGlyph(glyphName) else: srcGlyph = srcFont[glyphName] for component in srcGlyph.components: if component.baseGlyph not in tmpLayer: if component.baseGlyph not in srcFont: continue if self.verbose: print(f'\t\timporting {component.baseGlyph} ({glyphName})...') tmpLayer[component.baseGlyph] = srcFont[component.baseGlyph] tmpLayer[component.baseGlyph].lib[self.glyphSetPathKey] = glyphsFolder if self.verbose: print(f'\t\timporting {glyphName}...') tmpLayer[glyphName] = srcGlyph tmpLayer[glyphName].width = srcGlyph.width tmpLayer[glyphName].lib[self.glyphSetPathKey] = glyphsFolder if self.verbose: print() if self.verbose: print('...done.\n')
def exportButtonCallback(self, sender): f = CurrentFont() if f is None: return if self.verbose: print('exporting selected glyphs back to their sources...\n') for glyphName in f.selectedGlyphNames: if self.importMode == 1: glyph = f[glyphName].getLayer('foreground') if self.glyphSetPathKey not in glyph.lib: continue glyphsFolder = glyph.lib[self.glyphSetPathKey] ufoName = splitall(glyphsFolder)[-2] glyphNameExtension = os.path.splitext(ufoName)[0] glyphNameParts = glyphName.split('.') if not (len(glyphNameParts) > 1 and glyphNameParts[-1] == os.path.splitext(ufoName)[0]): print(f'{glyphName} does not have the expected glyph name extension, skipping...') continue if self.verbose: print(f'\twriting {glyphName} to {ufoName}...') outputGlyphName = '.'.join(glyphNameParts[:-1]) glyphSet = GlyphSet(glyphsFolder, validateWrite=True) glyphSet.writeGlyph(outputGlyphName, glyph.naked(), glyph.drawPoints) glyphSet.writeContents() else: for layerName in f.layerOrder: glyph = f[glyphName].getLayer(layerName) if self.glyphSetPathKey not in glyph.lib: continue glyphsFolder = glyph.lib[self.glyphSetPathKey] # mode 0 if not '.ufoz' in glyphsFolder: glyphSet = GlyphSet(glyphsFolder, validateWrite=True) ufoName = splitall(glyphsFolder)[-2] if self.verbose: print(f'\twriting {glyphName} to {ufoName}...') glyphSet.writeGlyph(glyphName, glyph.naked(), glyph.drawPoints) glyphSet.writeContents() # mode 2 else: ufoPath = os.path.dirname(glyphsFolder) ufoName = splitall(ufoPath)[-1] dstFont = OpenFont(ufoPath, showInterface=False) if self.verbose: print(f'\twriting {glyphName} to {ufoName}...') dstFont.insertGlyph(glyph, name=glyph.name) dstFont.save() dstFont.close() if self.verbose: print() print('...done.\n')
def _convertPath(self, path, destDir, saveOTF=True, saveTTF=True, saveWOFF=True, saveWOFFFormat=WOFF_TTF_FORMAT, saveWOFF2=True, saveWOFF2Format=WOFF_TTF_FORMAT, saveEOT=True, saveSVG=False, suffix="", report=None, preserveTTFhints=False): fileName = os.path.basename(path) fileName, ext = os.path.splitext(fileName) ext = ext.lower() if ext in [".ttf", ".otf"]: font = CompositorFont(path) else: font = OpenFont(path, showUI=False) familyName = font.info.familyName styleName = font.info.styleName if not self.controller.keepFileNames(): fileName = "%s-%s" % (familyName, styleName) fileName += suffix fileName = fileName.replace(" ", "_") if self.controller.exportInFolders(): fontDir = os.path.join(destDir, familyName.replace(" ", ""), styleName.replace(" ", "")) else: fontDir = destDir otfPath = os.path.join(fontDir, fileName + ".otf") ttfPath = os.path.join(fontDir, fileName + ".ttf") woffPath = os.path.join(fontDir, fileName + ".woff") woff2Path = os.path.join(fontDir, fileName + ".woff2") eotPath = os.path.join(fontDir, fileName + ".eot") svgPath = os.path.join(fontDir, fileName + ".svg") # save otf if saveOTF: report.writeTitle("Build OTF", "'") report.indent() report.write("path: %s" % otfPath) buildTree(fontDir) temp = self._getTempOTF(path, report=report, preserveTTFhints=preserveTTFhints) shutil.copyfile(temp, otfPath) report.dedent() report.newLine() # save ttf if saveTTF: report.writeTitle("Build TTF", "'") report.indent() report.write("path: %s" % ttfPath) buildTree(fontDir) temp = self._getTempTTF(path, report=report, preserveTTFhints=preserveTTFhints) shutil.copyfile(temp, ttfPath) report.dedent() report.newLine() # convert to woff if saveWOFF: if saveWOFFFormat == WOFF_TTF_FORMAT: func = self._getTempTTF reportFormat = "TTF" elif saveWOFFFormat == WOFF_OTF_FORMAT: func = self._getTempOTF reportFormat = "OTF" report.writeTitle("Build WOFF (%s)" % reportFormat, "'") report.indent() report.write("path: %s" % woffPath) buildTree(fontDir) temp = func(path, report=report, preserveTTFhints=preserveTTFhints) convertToWoff(temp, woffPath) report.dedent() report.newLine() # convert to woff2 if saveWOFF2: if saveWOFFFormat == WOFF_TTF_FORMAT: func = self._getTempTTF reportFormat = "TTF" elif saveWOFFFormat == WOFF_OTF_FORMAT: func = self._getTempOTF reportFormat = "OTF" report.writeTitle("Build WOFF2 (%s)" % reportFormat, "'") report.indent() report.write("path: %s" % woff2Path) buildTree(fontDir) temp = func(path, report=report, preserveTTFhints=preserveTTFhints) convertToWoff2(temp, woff2Path) report.dedent() report.newLine() # convert to eot if saveEOT: report.writeTitle("Build EOT", "'") report.indent() report.write("path: %s" % eotPath) buildTree(fontDir) temp = self._getTempTTF(path, report=report, preserveTTFhints=preserveTTFhints) convertToEot(temp, eotPath) report.dedent() report.newLine() # convert to svg if saveSVG: report.writeTitle("Build SVG", "'") report.indent() report.write("path: %s" % svgPath) buildTree(fontDir) convertToSVG(path, svgPath) report.dedent() report.newLine() self._removeTempFiles() self._writeHTMLPreview(report.html, report.css, fileName, familyName, styleName, saveTTF, saveWOFF, saveWOFF2, saveEOT, saveSVG)
def run(self, destDir, progress, report=None): paths = self.controller.get() decompose = self.decompose.get() removeOverlap = self.remove_overlap.get() autohint = self.autohint.get() releaseMode = self.release_mode.get() suffix = self.generateSuffix.get() suffix = time.strftime(suffix) formats = [ i for i in doodleSupportedExportFileTypes if getattr(self, i).get() ] if report is None: report = Report() report.writeTitle("Batch Generated Fonts:") report.newLine() progress.update("Collecting Data...") fonts = [] for path in paths: font = OpenFont(path, showUI=False) fonts.append(font) if decompose: report.writeTitle("Decompose:") report.indent() progress.update("Decompose...") progress.setTickCount(len(fonts)) for font in fonts: report.write("%s %s" % (font.info.familyName, font.info.styleName)) progress.update() font.decompose() progress.setTickCount(None) report.dedent() report.newLine() decompose = False if removeOverlap: report.writeTitle("Remove Overlap:") progress.update("Remove Overlap...") report.indent() progress.setTickCount(len(fonts)) for font in fonts: report.write("%s %s" % (font.info.familyName, font.info.styleName)) progress.update() font.removeOverlap() progress.setTickCount(None) report.dedent() report.newLine() removeOverlap = False report.writeTitle("Generate:") exportPaths = [] for index, font in enumerate(fonts): report.writeTitle((os.path.basename(paths[index]))) report.newLine() report.write("source: %s" % paths[index]) report.newLine() for format in formats: report.writeTitle("Generate %s" % format, "'") report.indent() familyName = font.info.familyName.replace(" ", "") styleName = font.info.styleName.replace(" ", "") if not self.controller.keepFileNames(): fileName = "%s-%s%s.%s" % (familyName, styleName, suffix, format) else: fileName = os.path.basename(paths[index]) fileName, _ = os.path.splitext(fileName) fileName = "%s%s.%s" % (fileName, suffix, format) progress.update("Generating ... %s" % fileName) if self.controller.exportInFolders(): fontDir = os.path.join(destDir, format) else: fontDir = destDir buildTree(fontDir) path = os.path.join(fontDir, fileName) report.write("path: %s" % path) result = font.generate(path=path, format=format, decompose=decompose, checkOutlines=removeOverlap, autohint=autohint, releaseMode=releaseMode, progressBar=progress, glyphOrder=font.glyphOrder) report.indent() report.write(result) report.dedent() exportPaths.append(path) report.dedent() report.newLine() font.close() reportPath = os.path.join(destDir, "Batch Generate Report.txt") report.save(reportPath) return exportPaths