2017-07-10 18:47:01 +02:00
|
|
|
#!/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
|
|
|
)
|
2017-07-10 18:47:01 +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
|
|
|
|
|
2018-01-07 00:53:51 +01:00
|
|
|
exit 0
|
2017-07-10 18:47:01 +02:00
|
|
|
exit $error
|