当前位置: 首页>>代码示例>>Python>>正文


Python metadata.Metadata类代码示例

本文整理汇总了Python中bakery_lint.metadata.Metadata的典型用法代码示例。如果您正苦于以下问题:Python Metadata类的具体用法?Python Metadata怎么用?Python Metadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Metadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_check_normal_style_matches_names

    def test_check_normal_style_matches_names(self):
        """ Check metadata.json font.style `italic` matches font internal """
        contents = self.read_metadata_contents()
        family = Metadata.get_family_metadata(contents)

        for font_metadata in family.fonts:
            if font_metadata.style != 'normal':
                continue

            font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)

            if bool(font.macStyle & 0b10):
                self.fail(('Metadata style has been set to normal'
                           ' but font second bit (italic) in macStyle has'
                           ' been set'))

            style = font.familyname.split('-')[-1]
            if style.endswith('Italic'):
                self.fail(('macStyle second bit is not set but postScriptName "%s"'
                           ' is ended with "Italic"') % font.familyname)

            style = font.fullname.split('-')[-1]
            if style.endswith('Italic'):
                self.fail(('macStyle second bit is not set but fullName "%s"'
                           ' is ended with "Italic"') % font.fullname)
开发者ID:adrientetar,项目名称:fontbakery,代码行数:25,代码来源:test_metadata.py

示例2: test_metadata_copyright_size

    def test_metadata_copyright_size(self):
        """ Copyright notice should be less than 500 chars """
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)

        for font_metadata in fm.fonts:
            self.assertLessEqual(len(font_metadata.copyright), 500)
开发者ID:adrientetar,项目名称:fontbakery,代码行数:7,代码来源:test_metadata.py

示例3: test_check_metadata_fields

    def test_check_metadata_fields(self):
        """ Check METADATA.json "fonts" property items have required field """
        contents = self.read_metadata_contents()
        family = Metadata.get_family_metadata(contents)

        keys = [("name", str), ("postScriptName", str),
                ("fullName", str), ("style", str),
                ("weight", int), ("filename", str),
                ("copyright", str)]

        missing = set([])
        unknown = set([])

        for j, itemtype in keys:

            for font_metadata in family.fonts:
                if j not in font_metadata:
                    missing.add(j)

                for k in font_metadata:
                    if k not in map(lambda x: x[0], keys):
                        unknown.add(k)

        if unknown:
            msg = 'METADATA.json "fonts" property has unknown items [%s]'
            self.fail(msg % ', '.join(unknown))

        if missing:
            msg = 'METADATA.json "fonts" property items missed [%s] items'
            self.fail(msg % ', '.join(missing))
开发者ID:adrientetar,项目名称:fontbakery,代码行数:30,代码来源:test_metadata.py

示例4: test_metrics_descents_equal_bbox

    def test_metrics_descents_equal_bbox(self):
        """ Check that descents values are same as min glyph point """
        contents = self.read_metadata_contents()
        family_metadata = Metadata.get_family_metadata(contents)

        fonts_descents_not_bbox = []
        ymin = 0

        _cache = {}
        for font_metadata in family_metadata.fonts:
            ttfont = Font.get_ttfont_from_metadata(self.path, font_metadata)

            ymin_, ymax_ = ttfont.get_bounding()
            ymin = min(ymin, ymin_)

            _cache[font_metadata.filename] = {
                'os2typo': abs(ttfont.descents.os2typo),
                'os2win': abs(ttfont.descents.os2win),
                'hhea': abs(ttfont.descents.hhea)
            }

        for filename, data in _cache.items():
            if [data['os2typo'], data['os2win'], data['hhea']] != [abs(ymin)] * 3:
                fonts_descents_not_bbox.append(filename)

        if fonts_descents_not_bbox:
            _ = '[%s] ascents differ to minimum value: %s'
            self.fail(_ % (', '.join(fonts_descents_not_bbox), ymin))
开发者ID:lowks,项目名称:fontbakery-cli,代码行数:28,代码来源:test_check_vertical_metrics.py

示例5: test_check_menu_contains_proper_glyphs

 def test_check_menu_contains_proper_glyphs(self):
     """ Check menu file contains proper glyphs """
     contents = self.read_metadata_contents()
     fm = Metadata.get_family_metadata(contents)
     for font_metadata in fm.fonts:
         tf = Font.get_ttfont_from_metadata(self.operator.path, font_metadata, is_menu=True)
         self.check_retrieve_glyphs(tf, font_metadata)
开发者ID:adrientetar,项目名称:fontbakery,代码行数:7,代码来源:test_metadata.py

示例6: generate

def generate(config, outfile='review.html'):
    directory = UpstreamDirectory(config['path'])
    fonts = [(path, FontFactory.openfont(op.join(config['path'], path)))
             for path in directory.BIN]

    metadata_file = open(op.join(config['path'], 'METADATA.json')).read()
    family_metadata = Metadata.get_family_metadata(metadata_file)
    faces = []
    for f in family_metadata.fonts:
        faces.append({'name': f.full_name,
                      'basename': f.post_script_name,
                      'path': f.filename,
                      'meta': f})

    destfile = open(op.join(config['path'], 'review.html'), 'w')
    app_version = report_utils.git_info(config)

    report_app = report_utils.ReportApp(config)
    fonts_orthography = get_orthography(fonts)

    report_app.review_page.dump_file(fonts_orthography, 'orthography.json')

    print(report_utils.render_template(
        outfile, fonts=faces, markdown=markdown, current_page=outfile,
        get_weight_name=get_weight_name,
        build_repo_url=report_utils.build_repo_url, app_version=app_version,
        get_orthography=get_orthography_old, fontaineFonts=fonts), file=destfile)
开发者ID:davelab6,项目名称:fontbakery-cli,代码行数:27,代码来源:review.py

示例7: test_check_canonical_filenames

 def test_check_canonical_filenames(self):
     """ Test If filename is canonical """
     contents = self.read_metadata_contents()
     family_metadata = Metadata.get_family_metadata(contents)
     for font_metadata in family_metadata.fonts:
         canonical_filename = self.create_canonical_filename(font_metadata)
         self.assertEqual(canonical_filename, font_metadata.filename)
开发者ID:anthrotype,项目名称:fontbakery,代码行数:7,代码来源:test_check_canonical_filenames.py

示例8: test_copyright_matches_pattern

    def test_copyright_matches_pattern(self):
        """ Copyright string matches to Copyright * 20\d\d * (*@*.*) """
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)

        for font_metadata in fm.fonts:
            self.assertRegexpMatches(font_metadata.copyright,
                                     r'Copyright\s+\(c\)\s+20\d{2}.*\(.*@.*.*\)')
开发者ID:lowks,项目名称:fontbakery-cli,代码行数:8,代码来源:test_metadata_font_copyright.py

示例9: test_check_familyname_matches_fontnames

 def test_check_familyname_matches_fontnames(self):
     """ Check font name is the same as family name """
     contents = self.read_metadata_contents()
     fm = Metadata.get_family_metadata(contents)
     for font_metadata in fm.fonts:
         _ = '%s: Family name "%s" does not match font name: "%s"'
         _ = _ % (font_metadata.filename, fm.name, font_metadata.name)
         self.assertEqual(font_metadata.name, fm.name, _)
开发者ID:adrientetar,项目名称:fontbakery,代码行数:8,代码来源:test_metadata.py

示例10: test_check_canonical_filenames

 def test_check_canonical_filenames(self):
     """ Test If filename is canonical """
     contents = self.read_metadata_contents()
     family_metadata = Metadata.get_family_metadata(contents)
     for font_metadata in family_metadata.fonts:
         canonical_filename = self.create_canonical_filename(font_metadata)
         if canonical_filename != font_metadata.filename:
             self.fail('{} != {}'.format(canonical_filename,
                                         font_metadata.filename))
开发者ID:adrientetar,项目名称:fontbakery,代码行数:9,代码来源:test_metadata.py

示例11: test_copyright_contains_correct_rfn

    def test_copyright_contains_correct_rfn(self):
        """ Copyright notice does not contain Reserved File Name """
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)

        for font_metadata in fm.fonts:
            if 'Reserved Font Name' in font_metadata.copyright:
                msg = '"%s" contains "Reserved File Name"'
                self.fail(msg % font_metadata.copyright)
开发者ID:adrientetar,项目名称:fontbakery,代码行数:9,代码来源:test_metadata.py

示例12: test_copyright_is_consistent_across_family

    def test_copyright_is_consistent_across_family(self):
        """ Copyright notice is the same in all fonts? """
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)

        copyright = ''
        for font_metadata in fm.fonts:
            if copyright and font_metadata.copyright != copyright:
                self.fail('Copyright is inconsistent across family')
            copyright = font_metadata.copyright
开发者ID:adrientetar,项目名称:fontbakery,代码行数:10,代码来源:test_metadata.py

示例13: test_postscriptname_contains_correct_weight

    def test_postscriptname_contains_correct_weight(self):
        """ Metadata weight matches postScriptName """
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)

        for font_metadata in fm.fonts:

            if 'Reserved Font Name' not in font_metadata.copyright:
                msg = '"%s" should have "Reserved File Name"'
                self.fail(msg % font_metadata.copyright)
开发者ID:lowks,项目名称:fontbakery-cli,代码行数:10,代码来源:test_metadata_font_copyright.py

示例14: test_postscriptname_contains_correct_weight

    def test_postscriptname_contains_correct_weight(self):
        """ Metadata weight matches postScriptName """
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)

        for font_metadata in fm.fonts:

            font = Font.get_ttfont_from_metadata(self.path, font_metadata)
            if font.OS2_usWeightClass != font_metadata.weight:
                msg = 'METADATA.JSON has weight %s but in TTF it is %s'
                self.fail(msg % (font_metadata.weight, font.OS2_usWeightClass))
开发者ID:lowks,项目名称:fontbakery-cli,代码行数:11,代码来源:test_check_canonical_weights.py

示例15: test_check_metadata_matches_nametable

    def test_check_metadata_matches_nametable(self):
        contents = self.read_metadata_contents()
        fm = Metadata.get_family_metadata(contents)
        for font_metadata in fm.fonts:
            ttfont = Font.get_ttfont_from_metadata(self.path, font_metadata)

            report = '%s: Family name was supposed to be "%s" but is "%s"'
            report = report % (font_metadata.name, fm.name,
                               ttfont.familyname)
            self.assertEqual(ttfont.familyname, fm.name, report)
            self.assertEqual(ttfont.fullname, font_metadata.full_name)
开发者ID:lowks,项目名称:fontbakery-cli,代码行数:11,代码来源:test_check_metadata_matches_nametable.py


注:本文中的bakery_lint.metadata.Metadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。