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 # Primarily written by Thomas Esser, Karl Berry, and Olaf Weber.
10 version
='$Id: mktextfm 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 [--destdir DESTDIR] FONT.
20 Makes a TFM file for FONT, if possible. Use DESTDIR for the root of where
21 to install into, either the absolute directory name to use (if it starts
22 with a /) or relative to the default DESTDIR (if not).
24 Report bugs to: tex-k@tug.org
25 TeX Live home page: <http://tug.org/texlive/>
28 # Handle non-positional options, except for --version/--help
29 while test $# -gt 0; do
31 --destdir) shift; DEST
="$1"; shift ;;
32 --destdir=*) DEST
=`echo "$1" | sed 's/--destdir=//'`; shift ;;
33 --version|
-version) break ;;
34 --help|
-help) break ;;
39 # Common code for all scripts.
40 : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
41 : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
42 test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT
="$MT_TEXMFMAIN/web2c/mktex.opt"
43 if test ! -f "$MT_MKTEX_OPT"; then
44 echo "$progname: Cannot find mktex.opt; check your installation." >&2
50 # Where do potential mf driver files go?
51 case "$MT_FEATURES" in
53 : ${MT_MFDESTDIR=`pwd`}
57 # start of redirection stdout -> stderr, stdin <- /dev/null
60 NAME
=`basename "$1" .tfm`
61 MAG
=1 # mag=0 fails with larm1000.mf
66 set x
`"$MT_MKTEXNAM" $NAME $DPI $MODE $DEST`; shift
71 PKDESTDIR
=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
72 TFMDESTDIR
=`echo "$TFMDEST" | sed 's%/[^/][^/]*$%%'`
73 PKNAME
=`basename "$PKDEST"`
77 if test -r "$TFMDESTDIR/$TFMNAME"; then
78 echo "$progname: $TFMDESTDIR/$TFMNAME already exists." >&2
79 echo "$TFMDESTDIR/$TFMNAME" >$STDOUT
80 "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME
84 # Try to create the destdir first. Do not create fonts, if this fails.
85 "$MT_MKTEXDIR" "$TFMDESTDIR"
86 if test ! -d "$TFMDESTDIR"; then
87 echo "$progname: mktexdir $TFMDESTDIR failed."
91 # Check if this font is supported by hbf2gf else use metafont.
92 if (hbf2gf
-q -t $NAME) >/dev
/null
2>&1; then
93 cmd
="hbf2gf -g $NAME $DPI"
95 # determine the progname of metafont to use; prefer mf-nowin.
96 if (mf-nowin
--version) >/dev
/null
2>&1; then
97 MF
="mf-nowin -progname=mf"
102 cmd
="$MF \mode:=$MODE; mag:=$MAG; nonstopmode; input $NAME"
105 echo "$progname: Running $cmd"
107 # Don't abort if only "Strange path", "bad pos" or "angle(0,0)"
109 grep '^!' $NAME.log |
sort >$$.errs
2>/dev
/null
110 grep '^! Strange path' $$.errs
>$$.strange
2>/dev
/null
111 grep '^! bad pos.' $$.errs
>$$.badpos
2>/dev
/null
112 grep '^! angle(0,0) is taken as zero.' $$.errs
>$$.angle
2>/dev
/null
113 cat $$.badpos $$.strange $$.angle |
sort > $$.errs_accept
114 if cmp $$.errs $$.errs_accept
>/dev
/null
2>&1; then
115 test -s $$.strange
>/dev
/null
2>&1 \
116 && echo "$progname: warning: \`$cmd' caused strange path errors." >&2
117 test -s $$.badpos
>/dev
/null
2>&1 \
118 && echo "$progname: warning: \`$cmd' caused bad pos errors." >&2
119 test -s $$.angle
>/dev
/null
2>&1 \
120 && echo "$progname: warning: \`$cmd' caused angle(0,0) errors." >&2
122 echo "$progname: \`$cmd' failed." >&2
123 test -s $NAME.log
&& mv -f $NAME.log
"$KPSE_DOT"
128 # hbf2gf just produces a .pl file:
129 test -r .
/$NAME.pl
&& pltotf .
/$NAME.pl
$TFMNAME
130 test -r $TFMNAME ||
{ echo "$progname: \`$cmd' failed to make $TFMNAME."; exit 1; }
132 # Install the TFM file carefully, since others may be working simultaneously.
133 # Use cp when mv fails, since DOS will fail mv for deeply-nested directories.
134 mv $TFMNAME "$TFMDESTDIR/tfm$$.tmp" 2>/dev
/null \
135 ||
cp $TFMNAME "$TFMDESTDIR/tfm$$.tmp" ||
exit 1
136 cd "$TFMDESTDIR" ||
exit 1
137 chmod `kpsestat -xst,go-w .` tfm$$.tmp
138 test -r $TFMNAME ||
mv tfm$$.tmp
$TFMNAME ||
exit 1
140 # OK, success with the TFM.
141 "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME
142 echo "$TFMDESTDIR/$TFMNAME" >$STDOUT
143 echo "$progname: $TFMDESTDIR/$TFMNAME: successfully generated." >&2
145 # Since we probably made a GF(->PK) file, too, may as well install it if
148 if test -r $GFNAME && test ! -f "$PKDESTDIR/$PKNAME"; then
149 gftopk .
/$GFNAME $PKNAME ||
exit 1
150 "$MT_MKTEXDIR" "$PKDESTDIR"
151 mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev
/null \
152 ||
cp $PKNAME "$PKDESTDIR/pk$$.tmp" ||
exit 1
153 cd "$PKDESTDIR" ||
exit 1
154 if test -f $PKNAME; then
157 chmod `kpsestat -xst,go-w .` pk$$.tmp
159 "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME