1
0
Fork 0
mirror of synced 2024-05-17 11:03:33 +12:00
FiraCode/script/build_variable.sh

46 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
set -o errexit -o nounset -o pipefail
cd "$(dirname "$0")/.."
2020-06-18 08:06:57 +12:00
[ -d venv ] && source venv/bin/activate
2020-06-09 02:10:00 +12:00
family_name=${FIRACODE_FAMILY_NAME:-"Fira Code"}
glyphs_file=${FIRACODE_GLYPHS_FILE:-"FiraCode.glyphs"}
2020-04-10 04:56:19 +12:00
dir="distr/variable_ttf/${family_name}"
file="${dir}/FiraCode-VF.ttf"
echo "=============="
echo
echo " [i] Creating variable font file!"
echo
mkdir -p "${dir}"
rm -rf "${dir:?}/"*
# make a temporary file here to avoid parallel runs from stepping on each other's toes
vf_glyphs=$(mktemp --suffix=".glyphs")
awk '/name = Retina;/ { print; print "exports = 0;"; next }1' \
"${glyphs_file}" > "${vf_glyphs}"
fontmake -g "${vf_glyphs}" -o variable --output-path "${file}"
rm -f "${vf_glyphs}"
2020-04-10 04:56:19 +12:00
# fix variable font metadata very important
gftools fix-vf-meta "${file}"
mv "${file}.fix" "${file}"
2020-04-10 04:56:19 +12:00
# other fixes for metadata and hinting
gftools fix-nonhinting "${file}" "${file}.fix"
mv "${file}.fix" "${file}"
gftools fix-gasp --autofix "${file}"
mv "${file}.fix" "${file}"
gftools fix-dsig --autofix "${file}"
2020-04-10 04:56:19 +12:00
# cleanup of temp files
rm -rf "${dir}/"*-gasp.ttf
2020-04-10 04:56:19 +12:00
# TODO (late 2019?): use TTFautohint-VF for variable font (current support is minimal)