summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-09-28 18:03:17 -0700
committerJames Godfrey-Kittle <jamesgk@google.com>2015-09-28 18:03:17 -0700
commitfdb4746fee87a222b9b2f52f179174f3ccfd97b1 (patch)
treed4679afeaa898ba308ca52aade934361827f2a0b /scripts
parent7c75cdb635d6f4b2e0a8d29fc9e5888645690bcb (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')
-rw-r--r--scripts/common_tests.py12
-rwxr-xr-xscripts/run_general_tests.py1
-rwxr-xr-xscripts/run_web_tests.py2
3 files changed, 13 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
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."""