Skip to content

Instantly share code, notes, and snippets.

@mfd
Last active November 25, 2023 05:48
Show Gist options
  • Save mfd/351fd7ed29a1d6ea5a7d3b5ba7d83ff7 to your computer and use it in GitHub Desktop.
Save mfd/351fd7ed29a1d6ea5a7d3b5ba7d83ff7 to your computer and use it in GitHub Desktop.
webfont convert

Make WEBFONTS (woff/woff2/eot)

Installation

Install Webfontools from Homebrew:

brew tap bramstein/webfonttools
brew update

brew install sfnt2woff-zopfli
brew install woff2
brew install sfntly

Convert

go to folder with *.ttf/otf files, put webfont.sh and run it

sh webfont.sh
#!/usr/bin/env bash
for f in *.otf *.ttf ; do
FILE=$(basename "$f")
if [ "$FILE" != "." ] && [ "$FILE" != ".." ] && [ "$FILE" != "*.otf" ] && [ "$FILE" != "*.ttf" ]
then
echo "Converting $FILE"
echo "=> woff"
sfnt2woff-zopfli $FILE >/dev/null
echo "=> woff2"
woff2_compress $FILE >/dev/null
echo "=> eot"
#sfnttool -ex $FILE >/dev/null
fi
done
echo ""
echo "All done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment