A Makefile for automatically building a font subset in WOFF2 and WOFF-with-Zopfli.
You must install Fonttools and SFNT2WOFF-Zopfli to use the functionality in this repo. You will also need to ensure that the brotli library is available for Fonttools.
Fonttools can be easily installed using Homebrew, by doing brew install fonttools. If you installed via Brew, you can install the brotli extension using
/usr/local/Cellar/fonttools/3.5.0/libexec/bin/pip install brotliSFNT2WOFF-Zopfli is a bit harder to install. You can do it by downloading the source off of GitHub and then running make inside the downloaded directory.
First create a directory to hold this script and it's work-dir. Inside the dir, copy over the Makefile and create the directories input and output. Place your original font-files in the input-directory
You also need to create a file called subset.txt that contains all of the characters you want the subsetted font to contain.
If you starting font-files are not in .woff, you need to open up the Makefile and modify the variable INPUT_EXT to e.g. woff2 or otf.
Simply run make in the directory.
If Fonttools isn't in your path, use FONTTOOLS_DIR to change where to search for the tools. Similarly for SFNT2WOFF-Zopfli where you can use SFNT2WOFF_DIR to modify the search-path.
If you wish to change the number of iterations that Zopfli runs, then you can use the variable ITERATIONS
If you want to utilize more than one CPU, you can use the -j-flag, which enables parallel processing in Make.
If you have Fonttools installed via Brews (and thus in your path), but have SFNT2WOFF-Zopfli in your user-directory (Users/xyz/sfnt2woff-zopfli), and you want to run 50 Zopfli-iterations and utilize 4 CPU-cores, you can use
SFNT2WOFF_DIR=/Users/xyz/sfnt2woff-zopfli ITERATIONS=50 make -j4