1 | #!/bin/sh |
---|
2 | # |
---|
3 | # This script file makes a new TeX PK font, because one wasn't found. |
---|
4 | # |
---|
5 | # It must echo the name of the generated PK file (and nothing else) to |
---|
6 | # standard output or to the designated file descriptor. |
---|
7 | # Yes, this is different from the original dvips. |
---|
8 | # |
---|
9 | # Parameters are: |
---|
10 | # |
---|
11 | # name dpi bdpi magnification [mode [destdir [redirect]]] |
---|
12 | # |
---|
13 | # `name' is the name of the font, such as `cmr10'. |
---|
14 | # `dpi' is the resolution the font is needed at. |
---|
15 | # `bdpi' is the base resolution, useful for figuring out the mode to |
---|
16 | # make the font in. |
---|
17 | # `magnification' is a string to pass to MF as the magnification. |
---|
18 | # `mode' (if supplied) is the mode to use. If it's `default,' |
---|
19 | # then we guess. |
---|
20 | # `destdir' (if supplied) is the absolute directory name to use. |
---|
21 | # `redirect' (if supplied) is a string of the form '>&n', where n is the |
---|
22 | # number of the file descriptor which is to receive, |
---|
23 | # instead of stdout, the name of the newly created pk file. |
---|
24 | # |
---|
25 | # Note that this file must execute Metafont, and then gftopk, |
---|
26 | # and place the result in the correct location for the PostScript |
---|
27 | # driver to find it subsequently. If this doesn't work, it will |
---|
28 | # be evident because this file will be invoked over and over again. |
---|
29 | # |
---|
30 | # Of course, it needs to be set up for your site. |
---|
31 | # |
---|
32 | TEXDIR=/usr/lib/tex |
---|
33 | LOCALDIR=/LocalLibrary/Fonts/TeXFonts |
---|
34 | DESTDIR=$LOCALDIR/pk |
---|
35 | MAPFILE=/usr/local/tex/lib/dvips/psfonts.map |
---|
36 | # |
---|
37 | # TEMPDIR needs to be unique for each process because of the possibility |
---|
38 | # of simultaneous processes running this script. |
---|
39 | # |
---|
40 | if test "$TMPDIR" = "" |
---|
41 | then |
---|
42 | TEMPDIR=/tmp/mtpk.$$ |
---|
43 | else |
---|
44 | TEMPDIR=$TMPDIR/mtpk.$$ |
---|
45 | fi |
---|
46 | NAME=$1 |
---|
47 | DPI=$2 |
---|
48 | BDPI=$3 |
---|
49 | MAG=$4 |
---|
50 | MODE=$5 |
---|
51 | # |
---|
52 | # Prevent display under the X Window System. Except it doesn't always work; |
---|
53 | # some sh'ells don't seem to understand unset. There are also some |
---|
54 | # versions of METAFONT that don't work if the DISPLAY isn't set and |
---|
55 | # the term type is set to xterm. |
---|
56 | # |
---|
57 | # unset DISPLAY |
---|
58 | umask 0 |
---|
59 | |
---|
60 | if test "$MODE" = "" |
---|
61 | then |
---|
62 | if test $BDPI = 300 |
---|
63 | then |
---|
64 | MODE=imagen |
---|
65 | elif test $BDPI = 200 |
---|
66 | then |
---|
67 | MODE=FAX |
---|
68 | elif test $BDPI = 360 |
---|
69 | then |
---|
70 | MODE=nextII |
---|
71 | elif test $BDPI = 400 |
---|
72 | then |
---|
73 | MODE=nexthi |
---|
74 | elif test $BDPI = 100 |
---|
75 | then |
---|
76 | MODE=nextscreen |
---|
77 | elif test $BDPI = 72 |
---|
78 | then |
---|
79 | MODE=seventwo |
---|
80 | elif test $BDPI = 635 |
---|
81 | then |
---|
82 | MODE=linolo |
---|
83 | elif test $BDPI = 1270 |
---|
84 | then |
---|
85 | MODE=linohi |
---|
86 | elif test $BDPI = 2540 |
---|
87 | then |
---|
88 | MODE=linosuper |
---|
89 | else |
---|
90 | echo "I don't know the mode for $BDPI" >&2 |
---|
91 | echo "Have your system admin update MakeTeXPK" >&2 |
---|
92 | exit 1 |
---|
93 | fi |
---|
94 | fi |
---|
95 | |
---|
96 | # Something like the following is useful at some sites. |
---|
97 | # DESTDIR=/usr/local/lib/tex/fonts/pk.$MODE |
---|
98 | GFNAME=$NAME.$DPI'gf' |
---|
99 | PKNAME=$NAME.$DPI'pk' |
---|
100 | |
---|
101 | if test "$6" != "" |
---|
102 | then |
---|
103 | DESTDIR="$6" |
---|
104 | fi |
---|
105 | |
---|
106 | if test ! -d $DESTDIR |
---|
107 | then |
---|
108 | mkdir $DESTDIR |
---|
109 | chmod 777 $DESTDIR |
---|
110 | fi |
---|
111 | |
---|
112 | REDIRECT= |
---|
113 | if test -n "$7"; then |
---|
114 | REDIRECT=`echo "$7" | sed 's/^>&//'` |
---|
115 | if test `(cat /dev/null >&$REDIRECT) 2>&1 | wc -l` -ne 0; then |
---|
116 | echo "$0: argument '$7' ignored - bad file number" >&2 |
---|
117 | REDIRECT= |
---|
118 | fi |
---|
119 | fi |
---|
120 | |
---|
121 | |
---|
122 | # added by gwb, to allow searching in current dir before cd'ing |
---|
123 | if test "$MFINPUTS" != "" |
---|
124 | then |
---|
125 | MFINPUTS=$MFINPUTS:`pwd`; export MFINPUTS |
---|
126 | fi |
---|
127 | |
---|
128 | |
---|
129 | # Beginning of main function definition. |
---|
130 | generate() |
---|
131 | { |
---|
132 | |
---|
133 | mkdir $TEMPDIR |
---|
134 | cd $TEMPDIR |
---|
135 | |
---|
136 | if test -r $DESTDIR/$PKNAME |
---|
137 | then |
---|
138 | echo "$DESTDIR/$PKNAME already exists!" |
---|
139 | showname $DESTDIR/$PKNAME |
---|
140 | exit 0 |
---|
141 | fi |
---|
142 | |
---|
143 | # check also in the standard place |
---|
144 | |
---|
145 | if test -r $TEXDIR/fonts/pk/$PKNAME |
---|
146 | then |
---|
147 | echo $TEXDIR/fonts/pk/$PKNAME already exists! |
---|
148 | showname $TEXDIR/fonts/pk/$PKNAME |
---|
149 | exit 0 |
---|
150 | fi |
---|
151 | |
---|
152 | if egrep \^$NAME'([ ]|$)' $MAPFILE > /dev/null |
---|
153 | then |
---|
154 | |
---|
155 | gsftopk $NAME $DPI || exit 1 |
---|
156 | |
---|
157 | else |
---|
158 | |
---|
159 | unset DISPLAY |
---|
160 | echo "mf \"\\mode:=$MODE; mag:=$MAG; scrollmode; input $NAME\" </dev/null" |
---|
161 | mf "\mode:=$MODE; mag:=$MAG; scrollmode; input $NAME" </dev/null |
---|
162 | if test ! -r $GFNAME |
---|
163 | then |
---|
164 | echo "Metafont failed for some reason on $GFNAME" |
---|
165 | exit 1 |
---|
166 | fi |
---|
167 | |
---|
168 | gftopk -v ./$GFNAME ./$PKNAME |
---|
169 | |
---|
170 | fi |
---|
171 | |
---|
172 | # Install the PK file carefully, since others may be doing the same |
---|
173 | # as us simultaneously. |
---|
174 | |
---|
175 | mv $PKNAME $DESTDIR/pktmp.$$ |
---|
176 | cd $DESTDIR |
---|
177 | mv pktmp.$$ $PKNAME |
---|
178 | chmod a+r $PKNAME |
---|
179 | showname $DESTDIR/$PKNAME |
---|
180 | |
---|
181 | } |
---|
182 | # end of main function definition |
---|
183 | |
---|
184 | |
---|
185 | if test -z "$REDIRECT"; then |
---|
186 | |
---|
187 | showname() |
---|
188 | { |
---|
189 | echo "$@" > $TEMPDIR/mtout.$$ |
---|
190 | } |
---|
191 | |
---|
192 | # Clean up on normal or abnormal exit. |
---|
193 | trap 'cd /; test -f $TEMPDIR/mtout.$$ && cat $TEMPDIR/mtout.$$; rm -rf $TEMPDIR; trap "" 0; exit 0' 0 1 2 15 |
---|
194 | |
---|
195 | (generate) >&2 |
---|
196 | |
---|
197 | else |
---|
198 | |
---|
199 | showname() |
---|
200 | { |
---|
201 | echo "$@" >&$REDIRECT |
---|
202 | } |
---|
203 | |
---|
204 | # Clean up on normal or abnormal exit. |
---|
205 | trap 'cd /; rm -rf $TEMPDIR; trap "" 0; exit 0' 0 1 2 15 |
---|
206 | |
---|
207 | generate |
---|
208 | |
---|
209 | fi |
---|