From fdb4746fee87a222b9b2f52f179174f3ccfd97b1 Mon Sep 17 00:00:00 2001 From: James Godfrey-Kittle Date: Mon, 28 Sep 2015 18:03:17 -0700 Subject: 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. --- scripts/common_tests.py | 12 ++++++++++-- scripts/run_general_tests.py | 1 + scripts/run_web_tests.py | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'scripts') 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 diff --git a/scripts/run_general_tests.py b/scripts/run_general_tests.py index 297c37c..7ec8fcc 100755 --- a/scripts/run_general_tests.py +++ b/scripts/run_general_tests.py @@ -42,6 +42,7 @@ class TestItalicAngle(common_tests.TestItalicAngle): class TestMetaInfo(common_tests.TestMetaInfo): loaded_fonts = FONTS + mark_heavier_as_bold = True test_us_weight = None test_version_numbers = None diff --git a/scripts/run_web_tests.py b/scripts/run_web_tests.py index 21e5577..f201114 100755 --- a/scripts/run_web_tests.py +++ b/scripts/run_web_tests.py @@ -32,6 +32,7 @@ class TestItalicAngle(common_tests.TestItalicAngle): class TestMetaInfo(common_tests.TestMetaInfo): loaded_fonts = FONTS + mark_heavier_as_bold = True # Since different font files are hinted at different times, the actual # outlines differ slightly. So we are keeping the version numbers as a hint. test_version_numbers = None @@ -40,6 +41,7 @@ class TestMetaInfo(common_tests.TestMetaInfo): class TestNames(common_tests.TestNames): loaded_fonts = FONTS family_name = 'Roboto' + mark_heavier_as_bold = True def test_unique_identifier_and_full_name(self): """Tests the unique identifier and full name.""" -- cgit v1.2.3