def convert_otf2ttf(self, builddir): _ = '$ font2ttf.py {0}.otf {0}.ttf\n' self.stdout_pipe.write(_.format(self.postscript_fontname)) from scripts.font2ttf import convert try: path = op.join(builddir, 'sources', self.postscript_fontname + '.otf') ttfpath = op.join(builddir, self.postscript_fontname + '.ttf') convert(path, ttfpath, log=self.stdout_pipe) except Exception, ex: self.stdout_pipe.write('Error: %s\n' % ex.message)
def execute_ufo_sfd(self, project_root, builddir, files): for f in files: filepath = op.join(builddir, f) _ = '$ font2ttf.py %s %s' self.stdout_pipe.write(_ % (filepath, filepath[:-4] + '.ttf')) ttfpath = filepath[:-4] + '.ttf' try: convert(op.join(self.builddir, filepath), op.join(self.builddir, ttfpath), log=self.stdout_pipe) except Exception, ex: self.stdout_pipe.write('# Error: %s\n' % ex.message)
def otf2ttf(self, filepath): _ = '$ font2ttf.py {0}.otf {0}.ttf\n' fontname = filepath[:-4] self.stdout_pipe.write(_.format(fontname)) path = '{}.otf'.format(fontname) if op.exists(op.join(self.builddir, path)): try: ttfpath = '{}.ttf'.format(fontname) convert(op.join(self.builddir, path), op.join(self.builddir, ttfpath), log=self.stdout_pipe) os.remove(op.join(self.builddir, path)) except Exception, ex: self.stdout_pipe.write('Error: %s\n' % ex.message) raise
def after_copy(self, builddir): from scripts.font2ttf import convert _ = '$ font2ttf.py %s %s %s' self.stdout_pipe.write(_ % (self.source_path, self.postscript_fontname + '.ttf', self.postscript_fontname + '.otf')) ufopath = op.join(builddir, 'sources', self.get_file_name()) ttfpath = op.join(builddir, self.postscript_fontname + '.ttf') otfpath = op.join(builddir, self.postscript_fontname + '.otf') try: convert(ufopath, ttfpath, otfpath, log=self.stdout_pipe) except Exception, ex: self.stdout_pipe.write('FAILED\nError: %s\n' % ex.message)