From 64a7750a219e522276a689c1771de1572bfc0372 Mon Sep 17 00:00:00 2001 From: James Godfrey-Kittle Date: Tue, 29 Sep 2015 18:05:15 -0700 Subject: Move TestHints to common_tests --- scripts/common_tests.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'scripts/common_tests.py') 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.""" -- cgit v1.2.3