run_web_tests.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 TestRobotoRegressions(run_general_tests.TestRobotoRegressions):
  24. loaded_fonts = FONTS
  25. # this bug is present in the hinted binaries and not fixed by the web target
  26. test_upsilontonos_narrow = False
  27. class TestItalicAngle(run_general_tests.TestItalicAngle):
  28. loaded_fonts = FONTS
  29. class TestMetaInfo(font_tests.TestMetaInfo):
  30. loaded_fonts = FONTS
  31. mark_heavier_as_bold = True
  32. # Since different font files are hinted at different times, the actual
  33. # outlines differ slightly. So we are keeping the version numbers as a hint.
  34. test_version_numbers = None
  35. # fsType of 0 marks the font free for installation, embedding, etc.
  36. expected_os2_fsType = 0
  37. expected_os2_achVendID = 'GOOG'
  38. class TestNames(run_general_tests.TestNames):
  39. """Bugs:
  40. https://github.com/google/roboto/issues/37
  41. """
  42. loaded_fonts = FONTS
  43. def expected_unique_id(self, family, style):
  44. expected = family
  45. if style != 'Regular':
  46. expected += ' ' + style
  47. return expected
  48. class TestDigitWidths(font_tests.TestDigitWidths):
  49. loaded_fonts = FONTS
  50. # disable this test while *.frac and *superior glyphs are separate
  51. # the webfont glyph subset contains *.frac but not *superior
  52. test_superscript_digits = False
  53. class TestCharacterCoverage(font_tests.TestCharacterCoverage):
  54. loaded_fonts = FONTS
  55. include = frozenset([
  56. 0xEE01, 0xEE02, 0xF6C3]) # legacy PUA
  57. exclude = frozenset([
  58. 0x2072, 0x2073, 0x208F] + # unassigned characters
  59. range(0xE000, 0xF8FF + 1) + range(0xF0000, 0x10FFFF + 1) # other PUA
  60. ) - include # don't exclude legacy PUA
  61. class TestVerticalMetrics(font_tests.TestVerticalMetrics):
  62. loaded_fonts = FONTS
  63. # tests yMin and yMax to be equal to Roboto v1 values
  64. # android requires this, and web fonts expect this
  65. expected_head_yMin = -555
  66. expected_head_yMax = 2163
  67. # test ascent, descent, and lineGap to be equal to Roboto v1 values
  68. expected_hhea_descent = -500
  69. expected_hhea_ascent = 1900
  70. expected_hhea_lineGap = 0
  71. # test OS/2 vertical metrics to be equal to the old values
  72. expected_os2_sTypoDescender = -512
  73. expected_os2_sTypoAscender = 1536
  74. expected_os2_sTypoLineGap = 102
  75. expected_os2_usWinDescent = 512
  76. expected_os2_usWinAscent = 1946
  77. class TestLigatures(run_general_tests.TestLigatures):
  78. loaded_fonts = FONTS
  79. class TestFeatures(run_general_tests.TestFeatures):
  80. loaded_fonts = FONTS
  81. class TestHints(font_tests.TestHints):
  82. loaded_fonts = FONTS
  83. if __name__ == '__main__':
  84. unittest.main()