#!/bin/sh
# Rebuild the Vicentino TrueType fonts.
# Needs: METAFONT (mf), mftrace, potrace, FontForge with its Python module.
# Run from this directory: sh build.sh  -> writes ../*.ttf
# (set PYTHON=python3.x if FontForge is installed for a specific Python)
set -e
HERE=$(pwd)
W=$(mktemp -d)
export MFINPUTS="$HERE:$HERE/../../kraml:"
export TFMFONTS="$W:"
cd "$W"
FONTS="vcxc10 vcxcb10 vcxm10 vcxmb10 vcxt10 vcxtb10 vcca10 vccba10 vcma10 vcmba10 vcta10 vctba10"
for f in $FONTS; do mf "\\mode=ljfour; batchmode; input $f" >/dev/null || true; done
for f in $FONTS; do
  mftrace --potrace -f pfa,afm --keep-trying -e "$HERE/vicentino.enc" --magnification=2000 $f
done
${PYTHON:-python3} "$HERE/build.py" "$W" "$HERE/.."
rm -f "$HERE"/../*.sfd
