Skip to content

Instantly share code, notes, and snippets.

@wolkenschieber
Created January 1, 2021 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolkenschieber/6d5bc93a99d8f918f82953310b232824 to your computer and use it in GitHub Desktop.
Save wolkenschieber/6d5bc93a99d8f918f82953310b232824 to your computer and use it in GitHub Desktop.
Convert WOFF and WOFF2 to TTF using fontforge
#!/usr/bin/env bash
set -o nounset
shopt -s nullglob
function convertFont() {
fontfile="${1}"
filename=$(basename -- "$fontfile")
extension="${filename##*.}"
filename="${filename%.*}"
targetfontfile="${filename}.ttf"
echo "Converting ${fontfile} to ${targetfontfile}"
fontforge -lang=ff -c 'Open($1); Generate($2)' "${fontfile}" "${targetfontfile}"
}
function main() {
for wofffile in *.woff; do
convertFont "${wofffile}"
done;
for woff2file in *.woff2; do
convertFont "${woff2file}"
done;
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment