2 # original mktextfm -- make a new TFM file, 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 # te@dbs.uni-hannover.de, kb@mail.tug.org, and infovore@xs4all.nl.
10 version='$Id: mktextfm,v 1.27 2004/07/03 19:25:15 olaf Exp $'
11 progname=`echo $0 | sed 's%.*/%%'`
12 usage="Usage: $progname [--destdir DESTDIR] FONT.
14 Makes a TFM file for FONT, if possible. Use DESTDIR for the root of where
15 to install into, either the absolute directory name to use (if it starts
16 with a /) or relative to the default DESTDIR (if not)."
18 # Handle non-positional options, except for --version/--help
19 while test $# -gt 0; do
21 --destdir) shift; DEST="$1"; shift ;;
22 --destdir=*) DEST=`echo "$1" | sed 's/--destdir=//'`; shift ;;
23 --version|-version) break ;;
24 --help|-help) break ;;
29 # Common code for all scripts.
30 : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
31 : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
32 test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt"
33 if test ! -f "$MT_MKTEX_OPT"; then
34 echo "$progname: Cannot find mktex.opt; check your installation." >&2
40 # Where do potential mf driver files go?
41 case "$MT_FEATURES" in
43 : ${MT_MFDESTDIR=`pwd`}
47 # start of redirection stdout -> stderr, stdin <- /dev/null
50 NAME=`basename "$1" .tfm`
56 set x `"$MT_MKTEXNAM" $NAME $DPI $MODE $DEST`; shift
61 PKDESTDIR=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
62 TFMDESTDIR=`echo "$TFMDEST" | sed 's%/[^/][^/]*$%%'`
63 PKNAME=`basename "$PKDEST"`
67 if test -r "$TFMDESTDIR/$TFMNAME"; then
68 echo "$progname: $TFMDESTDIR/$TFMNAME already exists." >&2
69 echo "$TFMDESTDIR/$TFMNAME" >$STDOUT
70 "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME
74 # Try to create the destdir first. Do not create fonts, if this fails.
75 "$MT_MKTEXDIR" "$TFMDESTDIR"
76 if test ! -d "$TFMDESTDIR"; then
77 echo "$progname: mktexdir $TFMDESTDIR failed."
81 # Check if this font is supported by hbf2gf else use metafont.
82 if (hbf2gf -q -t $NAME) >/dev/null 2>&1; then
83 cmd="hbf2gf -g $NAME $DPI"
85 # determine the progname of metafont to use; prefer mf-nowin.
86 if (mf-nowin --version) >/dev/null 2>&1; then
87 MF="mf-nowin -progname=mf"
92 cmd="$MF \mode:=$MODE; mag:=$MAG; nonstopmode; input $NAME"
95 echo "$progname: Running $cmd"
97 # Don't abort if only "Strange path", "bad pos" or "angle(0,0)"
99 grep '^!' $NAME.log | sort >$$.errs 2>/dev/null
100 grep '^! Strange path' $$.errs >$$.strange 2>/dev/null
101 grep '^! bad pos.' $$.errs >$$.badpos 2>/dev/null
102 grep '^! angle(0,0) is taken as zero.' $$.errs >$$.angle 2>/dev/null
103 cat $$.badpos $$.strange $$.angle | sort > $$.errs_accept
104 if cmp $$.errs $$.errs_accept >/dev/null 2>&1; then
105 test -s $$.strange >/dev/null 2>&1 \
106 && echo "$progname: warning: \`$cmd' caused strange path errors." >&2
107 test -s $$.badpos >/dev/null 2>&1 \
108 && echo "$progname: warning: \`$cmd' caused bad pos errors." >&2
109 test -s $$.angle >/dev/null 2>&1 \
110 && echo "$progname: warning: \`$cmd' caused angle(0,0) errors." >&2
112 echo "$progname: \`$cmd' failed." >&2
113 test -s $NAME.log && mv -f $NAME.log "$KPSE_DOT"
118 # hbf2gf just produces a .pl file:
119 test -r ./$NAME.pl && pltotf ./$NAME.pl $TFMNAME
120 test -r $TFMNAME || { echo "$progname: \`$cmd' failed to make $TFMNAME."; exit 1; }
122 # Install the TFM file carefully, since others may be working simultaneously.
123 # Use cp when mv fails, since DOS will fail mv for deeply-nested directories.
124 mv $TFMNAME "$TFMDESTDIR/tfm$$.tmp" 2>/dev/null \
125 || cp $TFMNAME "$TFMDESTDIR/tfm$$.tmp" || exit 1
126 cd "$TFMDESTDIR" || exit 1
127 chmod `kpsestat -xst,go-w .` tfm$$.tmp
128 test -r $TFMNAME || mv tfm$$.tmp $TFMNAME || exit 1
130 # OK, success with the TFM.
131 "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME
132 echo "$TFMDESTDIR/$TFMNAME" >$STDOUT
133 echo "$progname: $TFMDESTDIR/$TFMNAME: successfully generated." >&2
135 # Since we probably made a GF(->PK) file, too, may as well install it if
138 if test -r $GFNAME && test ! -f "$PKDESTDIR/$PKNAME"; then
139 gftopk ./$GFNAME $PKNAME || exit 1
140 "$MT_MKTEXDIR" "$PKDESTDIR"
141 mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev/null \
142 || cp $PKNAME "$PKDESTDIR/pk$$.tmp" || exit 1
143 cd "$PKDESTDIR" || exit 1
144 if test -f $PKNAME; then
147 chmod `kpsestat -xst,go-w .` pk$$.tmp
149 "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME