touchup_for_android.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import sys
  2. from fontTools.ttLib import TTFont
  3. from nototools import font_data
  4. from scripts import *
  5. def main(font_path):
  6. font = TTFont(font_path, recalcBBoxes=False)
  7. # turn off round-to-grid flags in certain problem components
  8. # https://github.com/google/roboto/issues/153
  9. glyph_set = font.getGlyphSet()
  10. ellipsis = glyph_set['ellipsis']._glyph
  11. for component in ellipsis.components:
  12. component.flags &= ~(1 << 2)
  13. # Add first 32 control chars to font.
  14. # Has been specifically requested by Android team. They are
  15. # seeing tofus in Android's layout libs. This should be fixed in
  16. # the libs but it is easier for us to tweak the fonts.
  17. for table in font["cmap"].tables:
  18. for uni in range(32):
  19. if uni in table.cmap:
  20. continue
  21. table.cmap[uni] = "uni0002"
  22. font_data.delete_from_cmap(font, [
  23. 0x20E3, # COMBINING ENCLOSING KEYCAP
  24. 0x2191, # UPWARDS ARROW
  25. 0x2193, # DOWNWARDS ARROW
  26. ])
  27. # Update vertical metrics to match v2.136
  28. update_attribs(
  29. font,
  30. **android_and_cros_vert_metrics
  31. )
  32. update_psname_and_fullname(font, include_year=True)
  33. update_font_version(font)
  34. font.save(font_path)
  35. main(sys.argv[1])