summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--scripts/run_android_tests.py49
2 files changed, 57 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 6e359d3..4062ad4 100644
--- a/Makefile
+++ b/Makefile
@@ -33,12 +33,17 @@ android:
touched=$$(mktemp); \
subsetted=$$(mktemp); \
final=out/android/$$(basename $$source); \
- python scripts/touchup_for_android.py $$source $$touched; \
- python $$HOME/noto/nototools/subset.py $$touched $$subsetted; \
- python scripts/force_yminmax.py $$subsetted $$final; \
+ python scripts/touchup_for_android.py $$source $$touched && \
+ python $$HOME/noto/nototools/subset.py $$touched $$subsetted && \
+ python scripts/force_yminmax.py $$subsetted $$final && \
rm $$touched $$subsetted; \
done
glass: out/android/Roboto-Thin.ttf
mkdir -p out/glass
python scripts/touchup_for_glass.py $< out/glass/Roboto-Thin.ttf
+
+test: test-android
+
+test-android:
+ python scripts/run_android_tests.py
diff --git a/scripts/run_android_tests.py b/scripts/run_android_tests.py
new file mode 100644
index 0000000..7880039
--- /dev/null
+++ b/scripts/run_android_tests.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+"""Test assumptions that Android relies on."""
+
+import glob
+import unittest
+
+from fontTools import ttLib
+
+
+def load_fonts():
+ """Load all fonts built for Android."""
+ all_fonts = glob.glob('out/android/*.ttf')
+ all_fonts = [ttLib.TTFont(font) for font in all_fonts]
+ return all_fonts
+
+
+class TestVerticalMetrics(unittest.TestCase):
+ """Test the vertical metrics of fonts."""
+
+ def setUp(self):
+ self.fonts = load_fonts()
+
+ def test_ymin_ymax(self):
+ """Tests yMin and yMax to be equal to what Android expects."""
+ for font in self.fonts:
+ head_table = font['head']
+ self.assertEqual(head_table.yMin, -555)
+ self.assertEqual(head_table.yMax, 2163)
+
+
+class TestDigitWidths(unittest.TestCase):
+ """Tests the width of digits."""
+
+ def setUp(self):
+ self.fonts = load_fonts()
+ self.digits = [
+ 'zero', 'one', 'two', 'three', 'four',
+ 'five', 'six', 'seven', 'eight', 'nine']
+
+ def test_digit_widths(self):
+ """Tests all decimal digits to make sure they have the same width."""
+ for font in self.fonts:
+ hmtx_table = font['hmtx']
+ widths = [hmtx_table[digit][0] for digit in self.digits]
+ self.assertEqual(len(set(widths)), 1)
+
+
+if __name__ == '__main__':
+ unittest.main()