diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-09-29 18:05:15 -0700 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-09-29 18:05:15 -0700 |
commit | 64a7750a219e522276a689c1771de1572bfc0372 (patch) | |
tree | d230bb0d28afd0dbf5f198a03246639031d87b5b | |
parent | 24632ad9ef96131a86b5a099f2eb59888df1cc5f (diff) |
Move TestHints to common_tests
-rw-r--r-- | scripts/common_tests.py | 32 | ||||
-rwxr-xr-x | scripts/run_web_tests.py | 32 |
2 files changed, 34 insertions, 30 deletions
diff --git a/scripts/common_tests.py b/scripts/common_tests.py index dc24f38..e92e1c8 100644 --- a/scripts/common_tests.py +++ b/scripts/common_tests.py @@ -421,6 +421,38 @@ class TestVerticalMetrics(FontTest): self.expected_os2_usWinAscent) +class TestHints(FontTest): + """Tests hints.""" + + def setUp(self): + self.fontfiles, self.fonts = self.loaded_fonts + + def test_existance_of_hints(self): + """Tests all glyphs and makes sure non-composite ones have hints.""" + missing_hints = [] + for font in self.fonts: + glyf_table = font['glyf'] + for glyph_name in font.getGlyphOrder(): + glyph = glyf_table[glyph_name] + if glyph.numberOfContours <= 0: # composite or empty glyph + continue + if len(glyph.program.bytecode) <= 0: + missing_hints.append( + (glyph_name, font_data.font_name(font))) + + self.assertTrue(missing_hints == []) + + def test_height_of_lowercase_o(self): + """Tests the height of the lowercase o in low resolutions.""" + for fontfile in self.fontfiles: + for size in range(8, 30): # Kind of arbitrary + o_height = get_rendered_char_height( + fontfile, size, 'o') + n_height = get_rendered_char_height( + fontfile, size, 'n') + self.assertEqual(o_height, n_height) + + class TestGlyphAreas(unittest.TestCase): """Tests that glyph areas between weights have the right ratios.""" diff --git a/scripts/run_web_tests.py b/scripts/run_web_tests.py index 1c88537..a6acc82 100755 --- a/scripts/run_web_tests.py +++ b/scripts/run_web_tests.py @@ -84,36 +84,8 @@ class TestLigatures(common_tests.TestLigatures): loaded_fonts = FONTS -class TestHints(unittest.TestCase): - """Tests hints.""" - - def setUp(self): - self.fontfiles, self.fonts = FONTS - - def test_existance_of_hints(self): - """Tests all glyphs and makes sure non-composite ones have hints.""" - missing_hints = [] - for font in self.fonts: - glyf_table = font['glyf'] - for glyph_name in font.getGlyphOrder(): - glyph = glyf_table[glyph_name] - if glyph.numberOfContours <= 0: # composite or empty glyph - continue - if len(glyph.program.bytecode) <= 0: - missing_hints.append( - (glyph_name, font_data.font_name(font))) - - self.assertTrue(missing_hints == []) - - def test_height_of_lowercase_o(self): - """Tests the height of the lowercase o in low resolutions.""" - for fontfile in self.fontfiles: - for size in range(8, 30): # Kind of arbitrary - o_height = common_tests.get_rendered_char_height( - fontfile, size, 'o') - n_height = common_tests.get_rendered_char_height( - fontfile, size, 'n') - self.assertEqual(o_height, n_height) +class TestHints(common_tests.TestHints): + loaded_fonts = FONTS if __name__ == '__main__': |