]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/printfont
merge
[plan9front.git] / rc / bin / printfont
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
7 POSTLIB=/sys/lib/postscript/prologues
8 PROLOGUE=$POSTLIB/printfont.ps
9
10 OPTIONS=''
11 COPYFILE=''
12 MODE=portrait
13 FONTENCODING=Default
14
15 NONCONFORMING='%!PS'
16 ENDPROLOG='%%EndProlog'
17 BEGINSETUP='%%BeginSetup'
18 ENDSETUP='%%EndSetup'
19 TRAILER='%%Trailer'
20
21 SETUP=setup
22
23 while (! ~ $#* 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
76 switch ($MODE) {
77 case l*; OPTIONS=$OPTIONS' /landscape true def'
78 case *; OPTIONS=$OPTIONS' /landscape false def'
79 }
80
81 echo $NONCONFORMING
82 cat $PROLOGUE
83 echo $ENDPROLOG
84 echo $BEGINSETUP
85 if (~ $#COPYFILE 0 || ~ $COPYFILE '') COPYFILE=/dev/null
86 cat $COPYFILE
87 echo $OPTIONS
88
89 switch ($FONTENCODING) {
90 case /*; cat $FONTENCODING
91 case ?*; cat $POSTLIB^/$FONTENCODING^.enc >[2]/dev/null
92 }
93
94 echo $SETUP
95 echo $ENDSETUP
96
97 for (i) {
98         switch ($i) {
99         case all; echo AllFonts
100         case /*;  echo $i' PrintFont'
101         case ?*;  echo /$i' PrintFont'
102         }
103 }
104
105 echo $TRAILER