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())))
示例#2
0
 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
示例#3
0
 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
示例#4
0
    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
示例#5
0
    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
示例#6
0
    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
示例#7
0
    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
示例#8
0
    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
示例#9
0
    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
示例#10
0
    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)
示例#11
0
    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)