updated dev-versioner.py script to support uff16-big endian encoding of version name in name table ID 5, platform ID 3

pull/198/head
Chris Simpkins 2016-03-23 00:57:45 +07:00
parent 8b94a87b39
commit 138922c7fb
1 changed files with 18 additions and 9 deletions

@ -17,20 +17,29 @@ def main(argv):
for font_variant_path in argv: for font_variant_path in argv:
tt = ttLib.TTFont(font_variant_path) tt = ttLib.TTFont(font_variant_path)
namerecord_list = tt['name'].__dict__['names'] namerecord_list = tt['name'].__dict__['names']
path_list = font_variant_path.split(".")
outfile_path = path_list[0] + "-DEV." + path_list[1]
for record in namerecord_list: for record in namerecord_list:
if record.__dict__['langID'] == 0: if record.__dict__['langID'] == 0 and record.__dict__['nameID'] == 5:
if record.__dict__['nameID'] == 5: record.__dict__['string'] = VERSION_STRING
record.__dict__['string'] = VERSION_STRING
path_list = font_variant_path.split(".") tt.save(outfile_path)
outfile_path = path_list[0] + "-DEV." + path_list[1] SUCCESS_INDICATOR += 1
tt.save(outfile_path)
SUCCESS_INDICATOR = 1
print("Updated '" + font_variant_path + "' version string to " + VERSION_STRING) elif record.__dict__['langID'] == 1033 and record.__dict__['nameID'] == 5:
record.__dict__['string'] = VERSION_STRING.encode('utf_16_be') # UTF-16 big endian encoding for the Microsoft tables
tt.save(outfile_path)
SUCCESS_INDICATOR += 1
if SUCCESS_INDICATOR == 0: if SUCCESS_INDICATOR == 0:
print("Unable to complete the name table update for " + font_variant_path) print("[ERROR] Unable to complete the name table update for " + font_variant_path)
elif SUCCESS_INDICATOR == 1:
print("[ERROR] Incomplete name table update for " + font_variant_path)
SUCCESS_INDICATOR = 0 # reset success indicator
if __name__ == '__main__': if __name__ == '__main__':