File: txttosrc

package info (click to toggle)
blockade 20041028-9
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k, lenny
  • size: 500 kB
  • ctags: 804
  • sloc: ansic: 7,485; sh: 177; makefile: 86
file content (45 lines) | stat: -rwxr-xr-x 1,564 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /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