1import sys 2from fontTools.ttx import makeOutputFileName 3from fontTools.ttLib import TTFont 4 5 6def main(args=None): 7 if args is None: 8 args = sys.argv[1:] 9 10 if len(args) < 1: 11 print( 12 "usage: dump_woff_metadata.py " "INPUT.woff [OUTPUT.xml]", file=sys.stderr 13 ) 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