diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-09-28 18:03:17 -0700 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-09-28 18:03:17 -0700 |
commit | fdb4746fee87a222b9b2f52f179174f3ccfd97b1 (patch) | |
tree | d4679afeaa898ba308ca52aade934361827f2a0b /scripts/common_tests.py | |
parent | 7c75cdb635d6f4b2e0a8d29fc9e5888645690bcb (diff) |
Add option to check heavier fonts as marked bold.
Not sure if there's any rule for whether fonts heavier than Bold (e.g.
Black) should be marked bold in the macStyle and subfamily name, so
this adds an option to test either way.
Diffstat (limited to 'scripts/common_tests.py')
-rw-r--r-- | scripts/common_tests.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/common_tests.py b/scripts/common_tests.py index ca37557..952e794 100644 --- a/scripts/common_tests.py +++ b/scripts/common_tests.py @@ -88,6 +88,8 @@ class TestItalicAngle(FontTest): class TestMetaInfo(FontTest): """Test various meta information.""" + mark_heavier_as_bold = False + def setUp(self): _, self.fonts = self.loaded_fonts @@ -98,7 +100,8 @@ class TestMetaInfo(FontTest): """ for font in self.fonts: font_name = font_data.font_name(font) - bold = ('Bold' in font_name) or ('Black' in font_name) + bold = ('Bold' in font_name) or ( + self.mark_heavier_as_bold and 'Black' in font_name) italic = 'Italic' in font_name expected_mac_style = (italic << 1) | bold self.assertEqual(font['head'].macStyle, expected_mac_style) @@ -144,6 +147,8 @@ class TestMetaInfo(FontTest): class TestNames(FontTest): """Tests various strings in the name table.""" + mark_heavier_as_bold = False + def setUp(self): font_files, self.fonts = self.loaded_fonts self.font_files = [path.basename(f) for f in font_files] @@ -222,7 +227,10 @@ class TestNames(FontTest): self.assertIn(subfam, ['Regular', 'Bold', 'Italic', 'Bold Italic']) # check that subfamily weight/slope are consistent with filename - self.assertEqual(weight == 'Bold', subfam.startswith('Bold')) + bold = (weight == 'Bold') or ( + self.mark_heavier_as_bold and + noto_fonts.WEIGHTS[weight] > noto_fonts.WEIGHTS['Bold']) + self.assertEqual(bold, subfam.startswith('Bold')) self.assertEqual(slope == 'Italic', subfam.endswith('Italic')) # check typographic name, if present |