1from __future__ import print_function 2import sys 3from fontTools.ttx import makeOutputFileName 4from fontTools.ttLib import TTFont 5 6 7def main(args=None): 8 if args is None: 9 args = sys.argv[1:] 10 11 if len(args) < 1: 12 print("usage: dump_woff_metadata.py " 13 "INPUT.woff [OUTPUT.xml]", file=sys.stderr) 14 return 1 15 16 infile = args[0] 17 if len(args) > 1: 18 outfile = args[1] 19 else: 20 outfile = makeOutputFileName(infile, None, ".xml") 21 22 font = TTFont(infile) 23 24 if not font.flavorData or not font.flavorData.metaData: 25 print("No WOFF metadata") 26 return 1 27 28 with open(outfile, "wb") as f: 29 f.write(font.flavorData.metaData) 30 31 32if __name__ == "__main__": 33 sys.exit(main()) 34