Browse Source

Update glyph bounds tests

Based on an added test in nototools.
James Godfrey-Kittle 8 years ago
parent
commit
2b87a51297
2 changed files with 20 additions and 38 deletions
  1. 3 3
      requirements.txt
  2. 17 35
      scripts/run_general_tests.py

+ 3 - 3
requirements.txt

@@ -1,14 +1,14 @@
 booleanOperations==0.5.2
 Cython==0.24.1
-FontTools==3.1.2
 freetype-py==1.0.2
 numpy==1.11.2rc1
 scipy==0.18.1
 
+git+https://github.com/fonttools/fonttools.git@0682e77370d877f8af37aae553c6d200f2078921
 git+https://github.com/googlei18n/compreffor.git@7d7ada07b24840d960c42c02c52a04de5b54ffe3
 git+https://github.com/googlei18n/cu2qu.git@d46be588f1510194cfd1bfef51ce25447d2cced6
-git+https://github.com/googlei18n/nototools@65d818d035b4ee34ce1016d91bf0e9657f3a13a1
-git+https://github.com/googlei18n/ufo2ft.git@9867ec8312f40c16058667c1a3f8708c986e4a83
+git+https://github.com/googlei18n/nototools@8db437b21de59b2d7aba30429c60a78f3e853caa
+git+https://github.com/googlei18n/ufo2ft.git@6184b1493bc4afc6969bd2516d02f3f616cb5484
 git+https://github.com/robofab-developers/robofab.git@62229c4ea33c324e698766d3700ca9a47efcdeb6
 git+https://github.com/typesupply/feaTools.git@8fc73f8ad5523cb6d9e0c8ac966eeb5dab5f7f49
 git+https://github.com/unified-font-object/ufoLib.git@ce2923fec01de83ca05cc6388a191afedfbd8f12

+ 17 - 35
scripts/run_general_tests.py

@@ -34,41 +34,6 @@ UFO_MASTERS = font_tests.load_fonts(
     font_class=OpenFont)
 
 
-class TestRobotoRegressions(font_tests.FontTest):
-    loaded_fonts = FONTS
-
-    def setUp(self):
-        self.font_files, self.fonts = self.loaded_fonts
-
-    def test_chi_descends(self):
-        """Test that the chi glyph descends below the baseline.
-        Bug: https://github.com/google/roboto/issues/18
-        """
-
-        for font in self.fonts:
-            glyph_set = font.getGlyphSet()
-            glyph = glyph_set['chi']._glyph
-            self.assertTrue(
-                glyph.yMin < 0, 'Lowercase chi does not descend below y=0, is '
-                'it an alias of x?')
-
-    def test_upsilontonos_narrow(self):
-        """Test that the tonos in Upsilontonos is not too far left.
-        Bug: https://github.com/google/roboto/issues/154
-        """
-
-        for filename, font in zip(self.font_files, self.fonts):
-            glyph_set = font.getGlyphSet()
-            glyph = glyph_set['Upsilontonos']._glyph
-
-            # accept within an x bound based on weight, where xMin=-150 is about
-            # what is expected for regular, -110 for light, -190 for medium
-            bound = -(150 + (font['OS/2'].usWeightClass - 400) * 0.4)
-            self.assertTrue(
-                glyph.xMin > bound, 'Upsilontonos extends far to the left and may '
-                'be susceptible to aggressive clipping. %s %d' % (filename, glyph.xMin))
-
-
 class TestItalicAngle(font_tests.TestItalicAngle):
     loaded_fonts = FONTS
     expected_italic_angle = -12.0
@@ -158,6 +123,23 @@ class TestVerticalMetrics(font_tests.TestVerticalMetrics):
     expected_head_yMax = 2163
 
 
+class TestGlyphBounds(font_tests.TestGlyphBounds):
+    loaded_fonts = FONTS
+
+    should_exceed = (
+        (('chi',), (None, 0, None, None), 0, 'is it an alias of x?'),
+    )
+
+    should_not_exceed = (
+        (('Epsilontonos', 'Etatonos', 'Iotatonos', 'Upsilontonos'),
+            (-150, None, None, None), 0.4,
+            'may be susceptible to aggressive clipping'),
+        (('uni1F1B', 'uni1F2B', 'uni1F3B', 'uni1F5B', 'uni1F9B'),
+            (-550, None, None, None), 0.1,
+            'may be susceptible to aggressive clipping'),
+    )
+
+
 class TestGlyphAreas(font_tests.TestGlyphAreas):
     master_weights_to_test = ['Thin', 'Bold']
     instance_weights_to_test = ['Thin', 'Regular', 'Bold']