#! /bin/sh # Copyright status: this file is in the public domain. name=$1 tmp=/tmp/txttosrc.$$ trap 'rm -f $tmp.* ; exit' 0 1 2 15 egrep -v '^#' < "$name" | pbmtext -font font.pbm > $tmp.1 set `< $tmp.1 tr -cs '[P0-9]' '\012' | sed -n -e 2,3p` x=$1 y=$2 # UTSLing reveals that the left border is two characters wide and the top # border is one character high. Why isn't this documented and/or variable? # We want to preserve one X and two Y pixels of the border. x=`expr $x - 17` y=`expr $y - 12` pnmcut 17 12 $x $y < $tmp.1 > $tmp.2 if [ $x -ge 480 ]; then pnmcut 0 0 480 $y < $tmp.2 > $tmp.1 else # pbmmake has -white and -black reversed; it should take -0 and -1! pbmmake -white `expr 480 - $x` $y | pnmcat -lr $tmp.2 - > $tmp.1 fi if [ $y -ge 288 ]; then pnmcut 0 0 480 288 < $tmp.1 > $tmp.2 else # ditto above comment on pbmmake pbmmake -white 480 `expr 288 - $y` | pnmcat -tb $tmp.1 - > $tmp.2 fi uq=$$\_`date | tr -c a-zA-Z0-9_ _` ( echo '#ifndef lint' echo '/* As far as I can tell the copyright requires me to include' echo ' this notice even in the resulting binary, sigh.... */' echo '' ( echo char copyright_$uq'[] = "@' echo 'Characters in this bitmap are taken from the font@n@' ) | tr @ \\\\ egrep '^#' < font.pbm | sed -e 's/^# *//' -e s/\"/\\\\\"/g -e 's/^/ /' -e 's/^[ ]*$//' -e s/\$/\\\\n\\\\/ ( echo @n@ echo Their arrangement is in the public domain.@n@ ) | tr @ \\\\ echo '";' echo '#endif /* #ifndef lint */' echo unsigned char "$name"_img_bits'[] = {' pbmtoxbm < $tmp.2 | sed -e 1,3d ) > blockade-info-"$name".c