def setValidNames(font, isBold): name = font['name'].getName(1, 3, 1) familyname = name.string.decode(name.getEncoding()) rules = NameTableNamingRule({'isBold': isBold, 'isItalic': True, 'familyName': familyname, 'weight': font['OS/2'].usWeightClass}) names = [] passedNamesId = [] for rec in font['name'].names: string = rec.string.decode(rec.getEncoding()) if rec.nameID in [1, 2, 4, 6, 16, 17, 18]: string = rules.apply(rec.nameID) passedNamesId.append(rec.nameID) names.append({'nameID': rec.nameID, 'string': string}) difference = set([1, 2, 4, 6, 16, 17, 18]).difference(set(passedNamesId)) if difference: for nameID in difference: string = rules.apply(nameID) names.append({'nameID': nameID, 'string': string}) for field in names: setValidNameRecord(font, field['nameID'], field['string']) for name in font['name'].names: logger.debug(u'{}: {}'.format(name.nameID, name.string.decode(name.getEncoding())))
def func(*args, **kwargs): logger.debug('\n$ ' + shell_cmd_repr(value, args)) try: result = getattr(cls.__originmodule__, value)(*args, **kwargs) return result except Exception as e: logger.error('Error: %s' % e.message) raise e
def execute(self, pipedata, prefix=""): if op.exists(op.join(self.project_root, self.filename)): try: args = [op.join(self.project_root, self.filename), self.builddir] copy_single_file(op.join(self.project_root, self.filename), op.join(self.builddir, 'sources')) except: logger.debug('Unable to copy files') raise return pipedata
def execute(self, pipedata): task = self.bakery.logging_task('Copy sources') if self.bakery.forcerun: return pipedata source_dir = self.create_source_dir() if pipedata.get('compiler') == 'make': makefile = op.join(self.project_root, 'Makefile') shutil.copy(makefile, source_dir) self.copy_helper_files(pipedata) try: if pipedata.get('compiler') != 'make': process_files = list(pipedata.get('process_files', [])) paths_to_copy = list(pipedata.get('process_files', [])) for path in process_files: paths_to_copy += self.lookup_splitted_ttx(path) self.copy_to_builddir(paths_to_copy, source_dir) sources = [] for path in process_files: filename = op.basename(path) sources.append(op.join(source_dir, filename)) pipedata.update({'process_files': sources}) else: for root, dirs, files in os.walk(self.project_root): if root.startswith(self.builddir.rstrip('/')): continue # ignore git repo if op.basename(root) in ['.git']: continue d = op.join(source_dir, root.replace(self.project_root, '').strip('/')) if not op.exists(d): os.makedirs(d) for f in files: shutil.copy(op.join(root, f), op.join(d, f)) except Exception as ex: logger.debug('Unable process copy. Exception info: %s' % ex) raise return pipedata
def execute(self, pipedata, prefix=""): if op.exists(op.join(self.project_root, self.filename)): try: args = [ op.join(self.project_root, self.filename), self.builddir ] copy_single_file(op.join(self.project_root, self.filename), op.join(self.builddir, 'sources')) except: logger.debug('Unable to copy files') raise return pipedata
def apply(self, *args, **kwargs): override_origin = kwargs.pop('override_origin', None) if not self.fix(*args, **kwargs): return False if not self.save_after_fix: return True self.save() if override_origin and os.path.exists(self.fixfont_path): command = "$ mv {} {}".format(self.fixfont_path, self.fontpath) logger.debug(command) shutil.move(self.fixfont_path, self.fontpath) return True
def apply(self, override_origin=False): from bakery_cli.ttfont import Font ymin = 0 ymax = 0 for f in self.fonts: metrics = Font(f) font_ymin, font_ymax = metrics.get_bounding() ymin = min(font_ymin, ymin) ymax = max(font_ymax, ymax) for f in self.fonts: fixer = VmetFixer(self.testcase, f) fixer.apply(ymin, ymax, override_origin=override_origin) command = "$ {0} {1}".format(Vmet.SCRIPTPATH, ' '.join(self.fonts)) logger.debug(command) import StringIO for l in StringIO.StringIO(metricview(self.fonts)): logger.debug(l)