#! /bin/sh

# convert an 18x18 BDF font into a corresponding 20x20 BDF font
# padding an empty margin of 1 pixel to each side

padfont () {
	echo Calculating shifted font cells for font "$1" >&2
	echo This may take 30 minutes or more, please be patient >&2

	LC_ALL=C sed -f `dirname $0`/`basename $0`.sed "$1" | sh
}

case "$1" in
"")	echo Transforming all 18x18 fonts in current directory to 20x20 >&2 ;;
esac

for f in ${*-18x18*.bdf}
do	f20=`echo $f | sed -e "s,18,20,g"`
	if [ -f $f20 ]
	then	echo Font file $f20 already exists. Rename / Remove, then repeat >&2
	else	echo Transforming $f to $f20 >&2
		padfont $f > $f20
	fi
done
