2 # original mktexpk -- make a new PK font, because one wasn't found.
4 # (If you change or delete the word `original' on the previous line,
5 # installation won't write this script over yours.)
7 # Originally written by Thomas Esser, Karl Berry, and Olaf Weber.
10 version
='$Id: mktexpk 34656 2014-07-18 23:38:50Z karl $'
11 progname
=`echo $0 | sed 's%.*/%%'`
13 # preferentially use subprograms from our own directory.
14 mydir
=`echo "$0" | sed 's,/[^/]*$,,'`
15 mydir
=`cd "$mydir" && pwd`
16 PATH
="$mydir:$PATH"; export PATH
18 usage
="Usage: $progname [OPTIONS] NAME [REDIRECT],
21 --dpi DPI use resolution DPI.
22 --bdpi BDPI use base resolution BDPI.
23 --mag MAG use magnificiation MAG.
24 --mfmode MODE use MODE as the METAFONT mode.
25 --destdir DESTDIR write fonts in DESTDIR.
27 Try to create a bitmap PK file for NAME at resolution DPI, with an
28 assumed device base resolution of BDPI, and a Metafont \`mag' of
29 MAG. Use MODE for the METAFONT mode. Use DESTDIR for the root of where
30 to install into, either the absolute directory name to use (if it starts
31 with a /) or relative to the default DESTDIR (if not). REDIRECT, if
32 supplied, is a string of the form '>&n', where n is the number of the
33 file descriptor which is to receive, instead of stdout, the name of the
34 newly created pk file.
36 If you expected the font to be available as an outline, and thus this
37 script does not work and should not have been called, most likely the
38 font's .tfm name is missing from the relevant map file (e.g.,
39 psfonts.map for dvips, pdftex.map for pdftex). These map files are
40 typically maintained using updmap; q.v.
42 For step-by-step instructions on making new fonts known to TeX, see
43 http://tug.org/fonts/fontinstall.html.
45 Report bugs to: tex-k@tug.org
46 TeX Live home page: <http://tug.org/texlive/>
49 # Handle non-positional options, except for --version/--help
50 while test $# -gt 0; do
52 --destdir) shift; DEST
="$1"; shift ;;
53 --destdir=*) DEST
=`echo "$1" | sed 's/--destdir=//'`; shift ;;
54 --dpi) shift; DPI
="$1"; shift ;;
55 --dpi=*) DPI
=`echo "$1" | sed 's/--dpi=//'`; shift ;;
56 --bdpi) shift; BDPI
="$1"; shift ;;
57 --bdpi=*) BDPI
=`echo "$1" | sed 's/--bdpi=//'`; shift ;;
58 --mfmode) shift; test "x$1" != "x/" && MODE
="$1"; shift ;;
59 --mfmode=*) test "x$1" != "x--mfmode/" \
60 && MODE
=`echo "$1" | sed 's/--mfmode=//'`; shift ;;
61 --mag) shift; MAG
="$1"; shift;;
62 --mag=*) MAG
=`echo "$1" | sed '/s--mag=//'`; shift;;
63 --version|
-version) break ;;
64 --help|
-help) break ;;
69 if test "x$2" != x
; then
70 tail="`echo \"x$2\" | sed 's/^x>&//' | grep '^[0-9]*$'`"
71 if test -z "$tail"; then
72 echo "$progname: argument '$2' ignored - bad file number" >&2
73 elif test "$tail" != 1; then
80 # Common code for all scripts.
81 : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
82 : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
83 test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT
="$MT_TEXMFMAIN/web2c/mktex.opt"
84 if test ! -f "$MT_MKTEX_OPT"; then
85 echo "$progname: Cannot find mktex.opt; check your installation." >&2
91 # Where do potential driver files belong?
92 case "$MT_FEATURES" in
94 : ${MT_MFDESTDIR=`pwd`}
98 # Since we want to pass the generated filename and only that filename
99 # back to the caller on standard output, we do some redirections so
100 # regular echo's will end up on stderr, and do an echo >$STDOUT at the end.
101 # Then the contents of $STDOUT will be echoed to stdout by a trap.
103 # start of redirection stdout -> stderr, stdin <- /dev/null
108 if kpsewhich
$NAME.mf
>/dev
/null
2>&1 || mktexmf
$NAME >/dev
/null
2>&1; then
109 # determine the progname of metafont to use; prefer mf-nowin.
110 if (mf-nowin
--version) >/dev
/null
2>&1; then
111 MF
="mf-nowin -progname=mf"
116 # Check that $BDPI and $MODE are consistent; if not, ignore the mode and
117 # hope we can correctly guess it from bdpi. (People like to specify the
118 # resolution on the command line, not the mode so much.)
119 if test -n "$MODE"; then
121 '\mode:='$MODE';mode_setup;message"BDPI= "&decimal round pixels_per_inch;end.'\
123 | awk '/DPI=/ {print $2}'`
124 if test "x$mf_bdpi" != x
$BDPI; then
125 echo "$progname: Mismatched mode $MODE and resolution $BDPI; ignoring mode." >&2
130 # If an explicit mode is not supplied, try to guess. You can get a
131 # list of extant modes from ftp://ftp.tug.org/tex/modes.mf.
132 if test -z "$MODE" ||
test "x$MODE" = xdefault
; then
144 8000) MODE
=dpdfezzz
;;
145 *) echo "$progname: Can't guess mode for $BDPI dpi devices." >&2
146 echo "$progname: Use a config file or option to specify the mode; see:" >&2
147 echo "$progname: http://tug.org/texinfohtml/kpathsea.html#Unable-to-generate-fonts" >&2
152 # Run Metafont. Always use plain Metafont, since reading cmbase.mf
153 # does not noticeably slow things down.
154 cmd
="$MF \mode:=$MODE; mag:=$MAG; nonstopmode; input $NAME"
157 # ps_to_pk is set in mktex.opt
160 if $ps_to_pk -t "$NAME"; then
161 cmd
="$ps_to_pk $NAME $DPI"
164 # grep for the font in $PSMAPFILE. These are base font names, such as
165 # rpplr (the original) or pplr0 (an interim step) or pplr8r (current).
166 : ${PSMAPFILE=`kpsewhich --format=map psfonts.map ps2pk.map`}
167 pattern
="^$NAME"'([ ]|$)'
168 psline
=`egrep "$pattern" $PSMAPFILE | tail -1`
169 if test -n "$psline"; then
170 set x
`echo "$psline" | sed 's%[<["]%%g'`
172 encoding
=; psname
=; slant
=; extend
=
173 while test ! -z "$1"; do
175 *.enc
) encoding
="-e $1";;
176 *.pf
[ab
]) psname
="$1";;
177 *SlantFont
) slant
="-S $lastopt";;
178 *ExtendFont
) extend
="-E $lastopt";;
183 # Guessing the name of the type1 font file as fallback:
184 ANAME
=`echo $NAME | sed 's/8r$/8a/'`
185 for i
in $NAME.pfa
$NAME.pfb
$ANAME.pfa
$ANAME.pfb
; do
186 if kpsewhich
$i >/dev
/null
2>&1; then
192 if [ -n "$psname" ]; then
193 cmd
="ps2pk -v -X$DPI -R$BDPI $slant $extend $encoding $psname $NAME.${DPI}pk"
195 if gsftopk
-t "$NAME"; then
196 echo "$progname: cannot find $NAME.pfa or $NAME.pfb. Trying gsftopk." >&2
197 cmd
="gsftopk $NAME $DPI"
203 # unsupported by $ps_to_pk, try other conversions:
204 if test -z "$cmd"; then
205 if (ttf2pk
-t -q $NAME) >/dev
/null
2>&1; then
206 cmd
="ttf2pk -q $NAME $DPI"
207 elif (hbf2gf
-t -q $NAME) >/dev
/null
2>&1; then
208 cmd
="hbf2gf -q -p $NAME $DPI"
210 echo "$progname: don't know how to create bitmap font for $NAME." >&2
211 echo "$progname: perhaps $NAME is missing from the map file." >&2
218 set x
`"$MT_MKTEXNAM" $NAME $DPI $MODE $DEST`; shift
222 PKDESTDIR
=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
223 PKNAME
=`basename "$PKDEST"`
224 GFNAME
=$NAME.
${DPI}gf
226 if test -r "$PKDESTDIR/$PKNAME"; then
227 echo "$progname: $PKDESTDIR/$PKNAME already exists." >&2
228 echo "$PKDESTDIR/$PKNAME" >$STDOUT
229 "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME
233 "$MT_MKTEXDIR" "$PKDESTDIR"
234 if test ! -d "$PKDESTDIR"; then
235 echo "$progname: $MT_MKTEXDIR $PKDESTDIR failed." >&2
239 echo "$progname: Running $cmd"
241 # Don't abort if only "Strange path", "bad pos" or "angle(0,0)"
243 grep '^!' $NAME.log |
sort >$$.errs
2>/dev
/null
244 grep '^! Strange path' $$.errs
>$$.strange
2>/dev
/null
245 grep '^! bad pos.' $$.errs
>$$.badpos
2>/dev
/null
246 grep '^! angle(0,0) is taken as zero.' $$.errs
>$$.angle
2>/dev
/null
247 cat $$.badpos $$.strange $$.angle |
sort > $$.errs_accept
248 if cmp $$.errs $$.errs_accept
>/dev
/null
2>&1; then
249 test -s $$.strange
>/dev
/null
2>&1 \
250 && echo "$progname: warning: \`$cmd' caused strange path errors." >&2
251 test -s $$.badpos
>/dev
/null
2>&1 \
252 && echo "$progname: warning: \`$cmd' caused bad pos errors." >&2
253 test -s $$.angle
>/dev
/null
2>&1 \
254 && echo "$progname: warning: \`$cmd' caused angle(0,0) errors." >&2
256 echo "$progname: \`$cmd' failed." >&2
257 test -s $NAME.log
&& mv -f $NAME.log
"$KPSE_DOT"
262 test -r $GFNAME && { gftopk .
/$GFNAME $PKNAME ||
exit 1; }
263 test ! -f $PKNAME && test -f $NAME.
${DPI}pk
&& mv $NAME.
${DPI}pk
$PKNAME
264 if test ! -s $PKNAME; then
265 echo "$progname: \`$cmd' failed to make $PKNAME." >&2
269 # Install the PK file carefully, since others may be working simultaneously.
270 # Use cp when mv fails, since DOS will fail mv for deeply-nested directories.
271 mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev
/null \
272 ||
cp $PKNAME "$PKDESTDIR/pk$$.tmp" ||
exit 1
273 cd "$PKDESTDIR" ||
exit 1
274 chmod `kpsestat -xst,go-w .` pk$$.tmp
275 test -r $PKNAME ||
mv pk$$.tmp
$PKNAME ||
exit 1
277 # Update ls-R if necessary.
278 "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME
280 # If this line (or an equivalent) is not present, dvipsk/xdvik/dviljk
281 # will think mktexpk failed. Any other output to stdout will also lose.
282 echo "$PKDESTDIR/$PKNAME" >$STDOUT
283 echo "$progname: $PKDESTDIR/$PKNAME: successfully generated." >&2