2015-07-31 20:03:13 +01:00
|
|
|
#!/usr/bin/env python
|
2015-08-20 11:13:17 +01:00
|
|
|
|
|
|
|
from __future__ import print_function, division, absolute_import
|
|
|
|
from fontTools.misc.py23 import *
|
2015-07-31 20:03:13 +01:00
|
|
|
from fontTools.ttLib import TTFont
|
|
|
|
from fontTools.ttx import makeOutputFileName
|
2019-06-11 12:44:15 +01:00
|
|
|
from fontTools.ttLib.woff2 import WOFF2FlavorData
|
2015-08-20 11:13:17 +01:00
|
|
|
import sys
|
2015-07-31 20:03:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main(args=None):
|
|
|
|
if args is None:
|
|
|
|
args = sys.argv[1:]
|
2019-06-11 12:44:15 +01:00
|
|
|
|
|
|
|
disableTransforms = False
|
|
|
|
if "--disable-transforms" in args:
|
|
|
|
disableTransforms = True
|
|
|
|
args.remove("--disable-transforms")
|
|
|
|
|
2015-07-31 20:03:13 +01:00
|
|
|
if len(args) < 1:
|
|
|
|
print("One argument, the input filename, must be provided.", file=sys.stderr)
|
2017-01-11 12:10:58 +00:00
|
|
|
return 1
|
2015-07-31 20:03:13 +01:00
|
|
|
|
|
|
|
filename = args[0]
|
|
|
|
outfilename = makeOutputFileName(filename, outputDir=None, extension='.woff2')
|
|
|
|
|
|
|
|
print("Processing %s => %s" % (filename, outfilename))
|
|
|
|
|
|
|
|
font = TTFont(filename, recalcBBoxes=False, recalcTimestamp=False)
|
|
|
|
font.flavor = "woff2"
|
2019-06-11 12:44:15 +01:00
|
|
|
|
|
|
|
if disableTransforms:
|
|
|
|
# an empty tuple signals that we don't want any table to be transformed
|
|
|
|
font.flavorData = WOFF2FlavorData(transformedTables=())
|
|
|
|
|
2015-07-31 20:03:13 +01:00
|
|
|
font.save(outfilename, reorderTables=False)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-01-11 12:10:58 +00:00
|
|
|
sys.exit(main())
|