dev-versioner.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # ------------------------------------------------------------------------------
  4. # dev-versioner.py
  5. # Copyright 2016 Christopher Simpkins
  6. # MIT license
  7. # ------------------------------------------------------------------------------
  8. import sys
  9. from fontTools import ttLib
  10. VERSION_STRING="Version 2.020;DEV-012616;"
  11. SUCCESS_INDICATOR = 0
  12. def main(argv):
  13. for font_variant_path in argv:
  14. tt = ttLib.TTFont(font_variant_path)
  15. namerecord_list = tt['name'].__dict__['names']
  16. for record in namerecord_list:
  17. if record.__dict__['langID'] == 0:
  18. if record.__dict__['nameID'] == 5:
  19. record.__dict__['string'] = VERSION_STRING
  20. path_list = font_variant_path.split(".")
  21. outfile_path = path_list[0] + "-DEV." + path_list[1]
  22. tt.save(outfile_path)
  23. SUCCESS_INDICATOR = 1
  24. print("Updated '" + font_variant_path + "' version string to " + VERSION_STRING)
  25. if SUCCESS_INDICATOR == 0:
  26. print("Unable to complete the name table update for " + font_variant_path)
  27. if __name__ == '__main__':
  28. main(sys.argv[1:])