Kohsuke Yatoh | bc71822 | 2021-01-31 23:48:46 -0800 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import argparse |
| 4 | |
| 5 | from fontTools import ttLib |
| 6 | |
| 7 | |
| 8 | def update_font_revision(font, revisionSpec): |
| 9 | if revisionSpec.startswith('+'): |
| 10 | font['head'].fontRevision += float(revisionSpec[1:]) |
| 11 | else: |
| 12 | font['head'].fontRevision = float(revisionSpec) |
| 13 | |
| 14 | |
| 15 | def main(): |
| 16 | args_parser = argparse.ArgumentParser(description='Update font file metadata') |
| 17 | args_parser.add_argument('--input', help='Input otf/ttf font file.') |
| 18 | args_parser.add_argument('--output', help='Output file for updated font file.') |
| 19 | args_parser.add_argument('--revision', help='Updated font revision. Use + to update revision based on the current revision') |
| 20 | args = args_parser.parse_args() |
| 21 | |
| 22 | font = ttLib.TTFont(args.input) |
| 23 | update_font_revision(font, args.revision) |
| 24 | font.save(args.output) |
| 25 | |
| 26 | if __name__ == "__main__": |
| 27 | main() |