14
0
mirror of https://github.com/belluzj/fantasque-sans.git synced 2024-11-14 21:21:33 +01:00
fantasque-sans/Scripts/validate-font

33 lines
635 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
# Validate a font file with FontForge.
if ! type fontforge &> /dev/null; then echo "ERROR: Missing dependency: fontforge" 1>&2; exit 1; fi
name=$1
basename=$(basename "$name" .sfdir)
echo -e "\e[1;37mValidating ${basename}... \e[0m"
output=$(fontforge --quiet -lang=py -script - "$name" <<EOF
import fontforge;
import sys;
font = fontforge.open(sys.argv[1]);
bitmask = font.validate();
if bitmask != 0:
exit(42);
EOF
2017-07-12 20:15:48 +02:00
)
error=$?
if [ "x$error" != "x0" ]; then
echo -e "\e[1;31mError in ${basename}.\e[0m"
if [ "x$error" = "x42" ]; then
echo "Font ${basename}.sfd is not valid"
fi
fi
exit $error