1#!/usr/bin/env python
2
3import argparse
4
5from fontTools import ttLib
6
7
8def 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
15def 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, recalcTimestamp=False)
23    update_font_revision(font, args.revision)
24    font.save(args.output)
25
26if __name__ == "__main__":
27    main()
28