Skip to content

Instantly share code, notes, and snippets.

@iamso
Created January 23, 2017 14:15
Show Gist options
  • Save iamso/5c68aa70ffda8a5fffc271ca58249605 to your computer and use it in GitHub Desktop.
Save iamso/5c68aa70ffda8a5fffc271ca58249605 to your computer and use it in GitHub Desktop.
Convert fonts to .woff and .woff2
#!/usr/bin/env bash
cd "$PWD"
shopt -s globstar
for f in *.otf *.ttf ; do
FILE=$(basename "$f")
if [ "$FILE" != "." ] && [ "$FILE" != ".." ] && [ "$FILE" != "*.otf" ] && [ "$FILE" != "*.ttf" ]
then
echo "Converting $FILE"
sfnt2woff-zopfli $FILE >/dev/null
woff2_compress $FILE >/dev/null
fi
done
echo ""
echo "All done."
@iamso
Copy link
Author

iamso commented Jan 23, 2017

requires the sfnt2woff-zopfli and woff2 command line tools to be installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment