build_variable.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. set -o errexit -o nounset -o pipefail
  3. cd "$(dirname "$0")/.."
  4. [ -d venv ] && source venv/bin/activate
  5. family_name=${FIRACODE_FAMILY_NAME:-"Fira Code"}
  6. glyphs_file=${FIRACODE_GLYPHS_FILE:-"FiraCode.glyphs"}
  7. dir="distr/variable_ttf/${family_name}"
  8. file="${dir}/FiraCode-VF.ttf"
  9. echo "=============="
  10. echo
  11. echo " [i] Creating variable font file!"
  12. echo
  13. mkdir -p "${dir}"
  14. rm -rf "${dir:?}/"*
  15. # make a temporary file here to avoid parallel runs from stepping on each other's toes
  16. vf_glyphs=$(mktemp)
  17. mv ${vf_glyphs} ${vf_glyphs}.glyphs
  18. vf_glyphs=${vf_glyphs}.glyphs
  19. awk '/name = Retina;/ { print; print "exports = 0;"; next }1' \
  20. "${glyphs_file}" > "${vf_glyphs}"
  21. fontmake -g "${vf_glyphs}" -o variable --output-path "${file}"
  22. rm -f "${vf_glyphs}"
  23. # other fixes for metadata and hinting
  24. gftools fix-nonhinting "${file}" "${file}.fix"
  25. mv "${file}.fix" "${file}"
  26. gftools fix-gasp --autofix "${file}"
  27. mv "${file}.fix" "${file}"
  28. # cleanup of temp files
  29. rm -rf "${dir}/"*-gasp.ttf
  30. # TODO (late 2019?): use TTFautohint-VF for variable font (current support is minimal)