run_web_tests.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/python
  2. #
  3. # Copyright 2015 Google Inc. All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. """Test assumptions that web fonts rely on."""
  17. import unittest
  18. from nototools.unittests import font_tests
  19. import run_general_tests
  20. FONTS = font_tests.load_fonts(
  21. ['out/web/*.ttf'],
  22. expected_count=18)
  23. class TestItalicAngle(run_general_tests.TestItalicAngle):
  24. loaded_fonts = FONTS
  25. class TestMetaInfo(font_tests.TestMetaInfo):
  26. loaded_fonts = FONTS
  27. mark_heavier_as_bold = False
  28. # Since different font files are hinted at different times, the actual
  29. # outlines differ slightly. So we are keeping the version numbers as a hint.
  30. test_version_numbers = None
  31. # fsType of 0 marks the font free for installation, embedding, etc.
  32. expected_os2_fsType = 0
  33. expected_os2_achVendID = 'GOOG'
  34. class TestNames(run_general_tests.TestNames):
  35. """Bugs:
  36. https://github.com/google/roboto/issues/37
  37. """
  38. loaded_fonts = FONTS
  39. def expected_unique_id(self, family, style):
  40. expected = family
  41. if style != 'Regular':
  42. expected += ' ' + style
  43. return expected
  44. class TestDigitWidths(font_tests.TestDigitWidths):
  45. loaded_fonts = FONTS
  46. # disable this test while *.frac and *superior glyphs are separate
  47. # the webfont glyph subset contains *.frac but not *superior
  48. test_superscript_digits = False
  49. class TestCharacterCoverage(font_tests.TestCharacterCoverage):
  50. loaded_fonts = FONTS
  51. include = frozenset([
  52. 0xEE01, 0xEE02, 0xF6C3]) # legacy PUA
  53. exclude = frozenset([
  54. 0x2072, 0x2073, 0x208F] + # unassigned characters
  55. range(0xE000, 0xF8FF + 1) + range(0xF0000, 0x10FFFF + 1) # other PUA
  56. ) - include # don't exclude legacy PUA
  57. class TestVerticalMetrics(font_tests.TestVerticalMetrics):
  58. loaded_fonts = FONTS
  59. # tests yMin and yMax to be equal to Roboto v1 values
  60. # android requires this, and web fonts expect this
  61. expected_head_yMin = -555
  62. expected_head_yMax = 2163
  63. # test ascent, descent, and lineGap to be equal to Roboto v1 values
  64. expected_hhea_descent = -500
  65. expected_hhea_ascent = 1900
  66. expected_hhea_lineGap = 0
  67. # test OS/2 vertical metrics to be equal to the old values
  68. expected_os2_sTypoDescender = -512
  69. expected_os2_sTypoAscender = 1536
  70. expected_os2_sTypoLineGap = 102
  71. expected_os2_usWinDescent = 512
  72. expected_os2_usWinAscent = 1946
  73. class TestLigatures(run_general_tests.TestLigatures):
  74. loaded_fonts = FONTS
  75. class TestGlyphBounds(run_general_tests.TestGlyphBounds):
  76. loaded_fonts = FONTS
  77. # a bug in which monotonic and polytonic glyphs extend too far left is
  78. # fixed in the unhinted output, but still present in the hinted binaries and
  79. # not fixed by the web target
  80. should_not_exceed = ()
  81. class TestHints(font_tests.TestHints):
  82. loaded_fonts = FONTS
  83. if __name__ == '__main__':
  84. unittest.main()