diff options
author | Roozbeh Pournader <roozbeh@google.com> | 2015-01-13 09:28:45 -0800 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-16 12:16:25 -0700 |
commit | 29257870e8eb50be42c0e36f70c88817c0a9ce50 (patch) | |
tree | bced17bcc48da24ec62ebef66de230f0c2c32d86 /scripts | |
parent | 36623f13d922461c897fe0ae1ff550a073385329 (diff) |
Add tests for the bad hinting of lowercase 'o'.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/common_tests.py | 17 | ||||
-rwxr-xr-x | scripts/run_web_tests.py | 12 |
2 files changed, 28 insertions, 1 deletions
diff --git a/scripts/common_tests.py b/scripts/common_tests.py index 14d761b..e766487 100644 --- a/scripts/common_tests.py +++ b/scripts/common_tests.py @@ -1,16 +1,33 @@ """Common tests for different targets.""" import glob +import sys import unittest from fontTools import ttLib from nototools import coverage from nototools import font_data +sys.path.append('./third_party/freetype-py') +import freetype + import layout import roboto_data +def get_rendered_char_height(font_filename, font_size, char, target='mono'): + if target == 'mono': + render_params = freetype.FT_LOAD_TARGET_MONO + elif target == 'lcd': + render_params = freetype.FT_LOAD_TARGET_LCD + render_params |= freetype.FT_LOAD_RENDER + + face = freetype.Face(font_filename) + face.set_char_size(font_size*64) + face.load_char(char, render_params) + return face.glyph.bitmap.rows + + def load_fonts(patterns, expected_count=None): """Load all fonts specified in the patterns. diff --git a/scripts/run_web_tests.py b/scripts/run_web_tests.py index 6b6adf9..fbeee0a 100755 --- a/scripts/run_web_tests.py +++ b/scripts/run_web_tests.py @@ -72,7 +72,7 @@ class TestHints(unittest.TestCase): """Tests hints.""" def setUp(self): - _, self.fonts = FONTS + self.fontfiles, self.fonts = FONTS def test_existance_of_hints(self): """Tests all glyphs and makes sure non-composite ones have hints.""" @@ -89,6 +89,16 @@ class TestHints(unittest.TestCase): 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) + if __name__ == '__main__': unittest.main() |