Snippets: remove woff2_{,de}compress.py; superseded by fonttools ttLib.woff2
diff --git a/Snippets/woff2_compress.py b/Snippets/woff2_compress.py
deleted file mode 100755
index 23f7e79..0000000
--- a/Snippets/woff2_compress.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function, division, absolute_import
-from fontTools.misc.py23 import *
-from fontTools import configLogger
-from fontTools.ttLib import TTFont
-from fontTools.ttx import makeOutputFileName
-from fontTools.ttLib.woff2 import WOFF2FlavorData
-import sys
-import logging
-import argparse
-
-
-def woff2_compress(input_file, output_file, transform_tables=None):
- logging.info("Processing %s => %s" % (input_file, output_file))
-
- font = TTFont(input_file, recalcBBoxes=False, recalcTimestamp=False)
- font.flavor = "woff2"
-
- if transform_tables is not None:
- font.flavorData = WOFF2FlavorData(transformedTables=transform_tables)
-
- font.save(output_file, reorderTables=False)
-
-
-def main(args=None):
- parser = argparse.ArgumentParser()
-
- parser.add_argument("input_file", metavar="INPUT_FILE")
- parser.add_argument("-o", "--output-file", default=None)
-
- transform_group = parser.add_argument_group()
- transform_group.add_argument(
- "--no-glyf-transform",
- action="store_true",
- help="Do not transform glyf (and loca) tables",
- )
- transform_group.add_argument(
- "--hmtx-transform",
- action="store_true",
- help="Enable optional transformation for 'hmtx' table",
- )
-
- logging_group = parser.add_mutually_exclusive_group(required=False)
- logging_group.add_argument(
- "-v", "--verbose", action="store_true", help="Run more verbosely."
- )
- logging_group.add_argument(
- "-q", "--quiet", action="store_true", help="Turn verbosity off."
- )
- options = parser.parse_args(args)
-
- configLogger(
- logger=logging.getLogger(),
- level=("DEBUG" if options.verbose else "ERROR" if options.quiet else "INFO"),
- )
-
- input_file = options.input_file
-
- if options.output_file:
- output_file = options.output_file
- else:
- output_file = makeOutputFileName(input_file, outputDir=None, extension=".woff2")
-
- if options.no_glyf_transform:
- transform_tables = set()
- else:
- transform_tables = {"glyf", "loca"}
-
- if options.hmtx_transform:
- transform_tables.add("hmtx")
-
- woff2_compress(input_file, output_file, transform_tables)
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/Snippets/woff2_decompress.py b/Snippets/woff2_decompress.py
deleted file mode 100755
index e7c1bea..0000000
--- a/Snippets/woff2_decompress.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function, division, absolute_import
-from fontTools.misc.py23 import *
-from fontTools.ttLib import TTFont
-from fontTools.ttx import makeOutputFileName
-import sys
-import os
-
-
-def make_output_name(filename):
- with open(filename, "rb") as f:
- f.seek(4)
- sfntVersion = f.read(4)
- assert len(sfntVersion) == 4, "not enough data"
- ext = '.ttf' if sfntVersion == b"\x00\x01\x00\x00" else ".otf"
- outfilename = makeOutputFileName(filename, outputDir=None, extension=ext)
- return outfilename
-
-
-def main(args=None):
- if args is None:
- args = sys.argv[1:]
- if len(args) < 1:
- print("One argument, the input filename, must be provided.", file=sys.stderr)
- return 1
-
- filename = args[0]
- outfilename = make_output_name(filename)
-
- print("Processing %s => %s" % (filename, outfilename))
-
- font = TTFont(filename, recalcBBoxes=False, recalcTimestamp=False)
- font.flavor = None
- font.save(outfilename, reorderTables=True)
-
-
-if __name__ == '__main__':
- sys.exit(main())