touchup_for_web.py 793 B

123456789101112131415161718192021222324252627282930313233
  1. from fontTools.ttLib import TTFont
  2. from scripts import *
  3. import sys
  4. import os
  5. def main(font_path):
  6. font = TTFont(font_path)
  7. filename = os.path.basename(font_path)
  8. # Set usWeightClass to 250 for Thin fonts
  9. if "Thin" in filename and "fvar" not in font:
  10. font['OS/2'].usWeightClass = 250
  11. # Update vertical metrics to match v2.138 webfonts
  12. update_attribs(
  13. font,
  14. **{"ascent": 1900,
  15. "descent": -500,
  16. "sTypoAscender": 1536,
  17. "sTypoDescender": -512,
  18. "sTypoLineGap": 102,
  19. "usWinAscent": 1946,
  20. "usWinDescent": 512,}
  21. )
  22. update_psname_and_fullname(font)
  23. update_gasp(font, {8:8, 65535: 15})
  24. disable_oblique_bits(font)
  25. update_font_version(font)
  26. font.save(font_path)
  27. main(sys.argv[1])