xref: /plan9/rc/bin/printfont (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1#!/bin/rc
2# Formatted dump of encoded characters in one or more PostScript fonts.
3# Arguments should be PostScript font names or the word all, which dumps
4# all ROM and disk based fonts.
5#
6
7POSTLIB=/sys/lib/postscript/prologues
8PROLOGUE=$POSTLIB/printfont.ps
9
10OPTIONS=''
11COPYFILE=''
12MODE=portrait
13FONTENCODING=Default
14
15NONCONFORMING='%!PS'
16ENDPROLOG='%%EndProlog'
17BEGINSETUP='%%BeginSetup'
18ENDSETUP='%%EndSetup'
19TRAILER='%%Trailer'
20
21SETUP=setup
22
23while (! ~ $#* 0 && ~ $1 -*) {
24	switch ($1) {
25	case -a;  shift; OPTIONS=$OPTIONS' /axescount $1 def'
26	case -a*; OPTIONS=$OPTIONS' /axescount '`{echo $1 | sed s/-a//}' def'
27
28	case -b;  shift; OPTIONS=$OPTIONS' /radix '$1' def'
29	case -b*; OPTIONS=$OPTIONS' /radix '`{echo $1 | sed s/-b//}' def'
30
31	case -c;  shift; OPTIONS=$OPTIONS' /#copies '$1' store'
32	case -c*; OPTIONS=$OPTIONS' /#copies '`{echo $1 | sed s/-c//}' store'
33
34	case -f;  shift; OPTIONS=$OPTIONS' /labelfont /'$1' def'
35	case -f*; OPTIONS=$OPTIONS' /labelfont /'`{echo $1 | sed s/-f//}' def'
36
37	case -g;  shift; OPTIONS=$OPTIONS' /graynotdef '$1' def'
38	case -g*; OPTIONS=$OPTIONS' /graynotdef '`{echo $1 | sed s/-g//}' def'
39
40	case -p;  shift; MODE=$1
41	case -p*; MODE=`{echo $1 | sed s/-p//}
42
43	case -q;  OPTIONS=$OPTIONS' /longnames false def /charwidth false def'
44
45	case -m;  shift; OPTIONS=$OPTIONS' /magnification '$1' def'
46	case -m*; OPTIONS=$OPTIONS' /magnification '`{echo $1 | sed s/-m//}' def'
47
48	case -v;  OPTIONS=$OPTIONS' /longnames true def /charwidth true def'
49
50	case -w;  shift; OPTIONS=$OPTIONS' /linewidth '$1' def'
51	case -w*; OPTIONS=$OPTIONS' /linewidth '`{echo $1 | sed s/-w//}' def'
52
53	case -x;  shift; OPTIONS=$OPTIONS' /xoffset '$1' def'
54	case -x*; OPTIONS=$OPTIONS' /xoffset '`{echo $1 | sed s/-x//}' def'
55
56	case -y;  shift; OPTIONS=$OPTIONS' /yoffset '$1' def'
57	case -y*; OPTIONS=$OPTIONS' /yoffset '`{echo $1 | sed s/-y//}' def'
58
59	case -z;  shift; OPTIONS=$OPTIONS' /zerocell '$1' def'
60	case -z*; OPTIONS=$OPTIONS' /zerocell '`{echo $1 | sed s/-z//}' def'
61
62	case -C;  shift; COPYFILE=$COPYFILE' '$1
63	case -C*; COPYFILE=$COPYFILE' '`{echo $1 | sed s/-C//}
64
65	case -E;  shift; FONTENCODING=$1
66	case -E*; FONTENCODING=`{echo $1 | sed s/-E//}
67
68	case -L;  shift; PROLOGUE=$1
69	case -L*; PROLOGUE=`{echo $1 | sed s/-L//}
70
71	case -*;  echo $0:' illegal option '$1 >[1=2]; exit 1
72	}
73	shift
74}
75
76switch ($MODE) {
77case l*; OPTIONS=$OPTIONS' /landscape true def'
78case *;	OPTIONS=$OPTIONS' /landscape false def'
79}
80
81echo $NONCONFORMING
82cat $PROLOGUE
83echo $ENDPROLOG
84echo $BEGINSETUP
85if (~ $#COPYFILE 0 || ~ $COPYFILE '') COPYFILE=/dev/null
86cat $COPYFILE
87echo $OPTIONS
88
89switch ($FONTENCODING) {
90case /*; cat $FONTENCODING
91case ?*; cat $POSTLIB^/$FONTENCODING^.enc >[2]/dev/null
92}
93
94echo $SETUP
95echo $ENDSETUP
96
97for (i) {
98	switch ($i) {
99	case all; echo AllFonts
100	case /*;  echo $i' PrintFont'
101	case ?*;  echo /$i' PrintFont'
102	}
103}
104
105echo $TRAILER
106