예제 #1
0
 def apply_callback(self, sender):
     ufo_paths = walk(self._ufos_folder, 'ufo')
     if len(ufo_paths) > 0:
         print 'transforming all fonts in folder...\n'
         self.w.bar.start()
         for ufo_path in ufo_paths:
             font = RFont(ufo_path, showUI=False)
             print '\ttransforming %s...' % get_full_name(font)
             if self._round:
                 print '\t\trounding points...'
                 font.round()
             if self._decompose:
                 print '\t\tdecomposing...'
                 decompose(font)
             if self._overlaps:
                 print '\t\tremoving overlaps...'
                 font.removeOverlap()
             if self._order:
                 print '\t\tauto contour order...'
                 auto_contour_order(font)
             if self._direction:
                 print '\t\tauto contour direction...'
                 auto_contour_direction(font)
             if self._extremes:
                 print '\t\tadding extreme points...'
                 add_extremes(font)
             if self._save:
                 print '\t\tsaving font...'
                 font.save()
             print '\t...done.\n'
         self.w.bar.stop()
         print '...done.\n'
     # no font open
     else:
         print 'the selected directory contains no .ufo font.\n'
예제 #2
0
 def apply_callback(self, sender):
     ufo_paths = walk(self.ufos_folder, 'ufo')
     if len(ufo_paths) > 0:
         print 'transforming all fonts in folder...\n'
         self.w.bar.start()
         for ufo_path in ufo_paths:
             font = RFont(ufo_path, showUI=False)
             print '\ttransforming %s...' % get_full_name(font)
             if self.round:
                 print '\t\trounding points...'
                 font.round()
             if self.decompose:
                 print '\t\tdecomposing...'
                 decompose(font)
             if self.overlaps:
                 print '\t\tremoving overlaps...'
                 font.removeOverlap()
             if self.order:
                 print '\t\tauto contour order...'
                 auto_contour_order(font)
             if self.direction:
                 print '\t\tauto contour direction...'
                 auto_contour_direction(font)
             if self.extremes:
                 print '\t\tadding extreme points...'
                 add_extremes(font)
             if self.remove_features:
                 print '\t\tremoving all OpenType features...'
                 clear_features(font)
             if self.save:
                 print '\t\tsaving font...'
                 font.save()
             print '\t...done.\n'
         self.w.bar.stop()
         print '...done.\n'
     # no font in folder
     else:
         print no_font_in_folder
예제 #3
0
 def apply_callback(self, sender):
     ufo_paths = walk(self.ufos_folder, 'ufo')
     if len(ufo_paths) > 0:
         print('transforming all fonts in folder...\n')
         self.w.bar.start()
         for ufo_path in ufo_paths:
             font = RFont(ufo_path, showUI=False)
             print('\ttransforming %s...' % get_full_name(font))
             if self.round:
                 print('\t\trounding points...')
                 font.round()
             if self.decompose:
                 print('\t\tdecomposing...')
                 decompose(font)
             if self.overlaps:
                 print('\t\tremoving overlaps...')
                 font.removeOverlap()
             if self.order:
                 print('\t\tauto contour order...')
                 auto_contour_order(font)
             if self.direction:
                 print('\t\tauto contour direction...')
                 auto_contour_direction(font)
             if self.extremes:
                 print('\t\tadding extreme points...')
                 add_extremes(font)
             if self.remove_features:
                 print('\t\tremoving all OpenType features...')
                 clear_features(font)
             if self.save:
                 print('\t\tsaving font...')
                 font.save()
             print('\t...done.\n')
         self.w.bar.stop()
         print('...done.\n')
     # no font in folder
     else:
         print(no_font_in_folder)
예제 #4
0
    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 = RFont(path, document=False, showInterface=False)
            # check font info
            requiredFontInfo = dict(descender=-250, xHeight=500, ascender=750, capHeight=750, unitsPerEm=1000)
            for attr, value in requiredFontInfo.items():
                existingValue = getattr(font.info, attr)
                if existingValue is None:
                    setattr(font.info, attr, value)
            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 or "familyName-%s" % index
                familyName = familyName.replace(" ", "")
                styleName = font.info.styleName or "styleName-%s" % index
                styleName = 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()
            if not font.hasInterface():
                font.close()
        reportPath = os.path.join(destDir, "Batch Generate Report.txt")
        report.save(reportPath)
        return exportPaths