xref: /plan9/sys/src/cmd/postscript/buildtables/buildtables.sh (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1#
2# Builds one or more font width tables or the typesetter description
3# file on a PostScript printer. Assumes you have direct access to the
4# printer's serial port. No arguments means build a standard collection
5# of tables - usually the LaserWriter Plus set. See trofftable and the
6# shell library files /usr/lib/font/dev*/shell.lib for more details.
7#
8
9set -e
10
11POSTBIN=/usr/lbin/postscript
12POSTLIB=/usr/lib/postscript
13FONTDIR=/usr/lib/font
14
15POSTIO=$POSTBIN/postio
16TROFFTABLE=$POSTBIN/trofftable
17
18BAUDRATE=
19DEVICE=
20LIBRARY=
21
22while [ -n "$1" ]; do
23    case $1 in
24	-C)  shift; OPTIONS="$OPTIONS -C$1";;
25	-C*) OPTIONS="$OPTIONS $1";;
26
27	-F)  shift; FONTDIR=$1;;
28	-F*) FONTDIR=`echo $1 | sed s/-F//`;;
29
30	-H)  shift; OPTIONS="$OPTIONS -H$1";;
31	-H*) OPTIONS="$OPTIONS $1";;
32
33	-S)  shift; LIBRARY=$1;;
34	-S*) LIBRARY=`echo $1 | sed s/-S//`;;
35
36	-T)  shift; DEVICE=$1;;
37	-T*) DEVICE=`echo $1 | sed s/-T//`;;
38
39	-b)  shift; BAUDRATE=$1;;
40	-b*) BAUDRATE=`echo $1 | sed s/-b//`;;
41
42	-c)  shift; OPTIONS="$OPTIONS -c$1";;
43	-c*) OPTIONS="$OPTIONS $1";;
44
45	-l)  shift; LINE=$1;;
46	-l*) LINE=`echo $1 | sed s/-l//`;;
47
48	-s)  shift; OPTIONS="$OPTIONS -s$1";;
49	-s*) OPTIONS="$OPTIONS $1";;
50
51	-t)  shift; OPTIONS="$OPTIONS -t$1";;
52	-t*) OPTIONS="$OPTIONS $1";;
53
54	-?)  OPTIONS="$OPTIONS $1$2"; shift;;
55	-?*) OPTIONS="$OPTIONS $1";;
56
57	*)   break;;
58    esac
59    shift
60done
61
62if [ ! "$DEVICE" -a ! "$LIBRARY" ]; then
63    echo "$0: no device or shell library" >&2
64    exit 1
65fi
66
67LIBRARY=${LIBRARY:-${FONTDIR}/dev${DEVICE}/shell.lib}
68
69#
70# No arguments means build everything return by the AllTables function.
71#
72
73if [ $# -eq 0 ]; then
74    . $LIBRARY
75    set -- `AllTables`
76fi
77
78for i do
79    SHORT=`echo $i | awk '{print $1}'`
80    LONG=`echo $i | awk '{print $2}'`
81
82    if [ "$LINE" ]
83	then echo "==== Building table $SHORT ===="
84	else echo "==== Creating table program $SHORT.ps ===="
85    fi
86
87    $TROFFTABLE -S$LIBRARY $OPTIONS $SHORT $LONG >$SHORT.ps
88
89    if [ "$LINE" ]; then
90	$POSTIO -t -l$LINE ${BAUDRATE:+-b${BAUDRATE}} $SHORT.ps >$SHORT
91	rm -f $SHORT.ps
92    fi
93done
94
95