2999
|
1 #!/bin/sh |
|
2 # original MakeTeXPK -- make a new PK font, because one wasn't found. |
|
3 # |
|
4 # (If you change or delete the word `original' on the previous line, |
|
5 # installation won't write this script over yours.) |
|
6 # |
|
7 # te@informatik.uni-hannover.de and kb@mail.tug.org. Public domain. |
|
8 |
|
9 version='$Id: MakeTeXPK,v 1.1 1997-05-23 03:02:10 jwe Exp $' |
|
10 usage="Usage: $0 NAME DPI BDPI MAG [MODE [DESTDIR]]. |
|
11 Try to create a PK file for NAME at resolution DPI, |
|
12 with an assumed device base resolution of BDPI, |
|
13 and a Metafont \`mag' of MAG. |
|
14 Use MODE for the Metafont mode if supplied, unless MODE is \`default', in |
|
15 which case guess as usual. (This is so you can specify DESTDIR without MODE.) |
|
16 Use DESTDIR for the root of where to install into, either the absolute |
|
17 directory name to use (if it starts with a /) or relative to the default |
|
18 DESTDIR (if not)." |
|
19 mt_min_args=4 |
|
20 mt_max_args=6 |
|
21 |
|
22 : ${TEXMFMAIN=`kpsewhich -expand-var='$TEXMFMAIN'`} |
|
23 if test -z "$TEXMFMAIN"; then |
|
24 echo "$0: No \$TEXMFMAIN; set the environment variable or in texmf.cnf." >&2 |
|
25 exit 1 |
|
26 fi |
|
27 : ${TEXMFCNF_DIR=`kpsewhich -expand-var='$TEXMFCNF_DIR'`} |
|
28 test -n "$TEXMFCNF_DIR" || TEXMFCNF_DIR=$TEXMFMAIN/web2c |
|
29 . $TEXMFCNF_DIR/MakeTeXcommon |
|
30 |
|
31 # Since we want to pass the generated filename and only that filename |
|
32 # back to the caller on standard output, we do some redirections so |
|
33 # regular echo's will end up on stderr, and do an echo >$STDOUT at the end. |
|
34 # Then the contents of $STDOUT will be echoed to stdout by a trap. |
|
35 |
|
36 # start of redirection stdout -> stderr, stdin <- /dev/null |
|
37 ( |
|
38 : ${PSMAPFILE=`kpsewhich psfonts.map`} |
|
39 |
|
40 NAME=$1 |
|
41 DPI=$2 |
|
42 BDPI=$3 |
|
43 MAG=$4 |
|
44 MODE=$5 |
|
45 DEST=$6 |
|
46 |
|
47 # grep for the font in $PSMAPFILE. These are base font names, such as |
|
48 # rpplr (the original) or pplr0 (an interim step) or pplr8r (current). |
|
49 pattern="^r?$NAME"'(0|8r)?([ ]|$)' |
|
50 psline=`egrep "$pattern" $PSMAPFILE` |
|
51 if test -n "$psline"; then |
|
52 MODE=modeless |
|
53 # ps_to_pk set in MakeTeXcommon and/or MakeTeX.site. |
|
54 cmd="$ps_to_pk $NAME $DPI" |
|
55 else |
|
56 # Check that $BDPI and $MODE are consistent; if not, ignore the mode and |
|
57 # hope we can correctly guess it from bdpi. (People like to specify the |
|
58 # resolution on the command line, not the mode so much.) |
|
59 if test -n "$MODE"; then |
|
60 mf_bdpi=`mf \ |
|
61 '\mode:='$MODE';mode_setup;message"BDPI= "&decimal round pixels_per_inch;end.'\ |
|
62 </dev/null \ |
|
63 | awk '/DPI=/ {print $2}'` |
|
64 if test $mf_bdpi != $BDPI; then |
|
65 echo "$0: Mismatched mode $MODE and resolution $BDPI; ignoring mode." >&2 |
|
66 MODE= |
|
67 fi |
|
68 fi |
|
69 |
|
70 # If an explicit mode is not supplied, try to guess. You can get a |
|
71 # list of extant modes from ftp://ftp.tug.org/tex/modes.mf. |
|
72 if test -z "$MODE" || test "$MODE" = default; then |
|
73 case "$BDPI" in |
|
74 300) MODE=cx;; |
|
75 600) MODE=ljfour;; |
|
76 *) echo "$0: Can't guess mode for $BDPI dpi devices." >&2 |
|
77 echo "$0: Use a config file, or update me." >&2 |
|
78 exit 1 |
|
79 esac |
|
80 fi |
|
81 |
|
82 # Run Metafont. Always use plain Metafont, since reading cmbase.mf |
|
83 # does not noticeably slow things down. |
|
84 cmd="mf \mode:=$MODE; mag:=$MAG; scrollmode; input $NAME" |
|
85 fi |
|
86 |
|
87 set - `$TEXMFCNF_DIR/MakeTeXnames $NAME $DPI $MODE $DEST` |
|
88 PKDEST=$1 |
|
89 PKDESTDIR=`echo $PKDEST | sed 's%/[^/][^/]*$%%'` # can't rely on dirname |
|
90 PKNAME=`basename $PKDEST` |
|
91 GFNAME=$NAME.${DPI}gf |
|
92 |
|
93 if test -r $PKDESTDIR/$PKNAME; then |
|
94 echo "$0: $PKDESTDIR/$PKNAME already exists." >&2 |
|
95 echo $PKDESTDIR/$PKNAME >$STDOUT |
|
96 $TEXMFCNF_DIR/MakeTeXupdate $PKDESTDIR $PKNAME |
|
97 exit 0 |
|
98 fi |
|
99 |
|
100 $TEXMFCNF_DIR/MakeTeXmkdir $PKDESTDIR |
|
101 if test ! -d $PKDESTDIR; then |
|
102 echo "$0: MakeTeXmkdir $PKDESTDIR failed." >&2 |
|
103 exit 1 |
|
104 fi |
|
105 |
|
106 echo "$0: Running $cmd" |
|
107 $cmd </dev/null || { echo "$0: \`$cmd' failed." >&2; exit 1; } |
|
108 |
|
109 test -r $GFNAME && { gftopk ./$GFNAME $PKNAME || exit 1; } |
|
110 test ! -f $PKNAME && test -f $NAME.${DPI}pk && mv $NAME.${DPI}pk $PKNAME |
|
111 if test ! -s $PKNAME; then |
|
112 echo "$0: \`$cmd' failed to make $PKNAME." >&2 |
|
113 exit 1 |
|
114 fi |
|
115 |
|
116 # Install the PK file carefully, since others may be working simultaneously. |
|
117 mv $PKNAME $PKDESTDIR/pktmp.$$ || exit 1 |
|
118 cd $PKDESTDIR || exit 1 |
|
119 test -r $PKNAME || mv pktmp.$$ $PKNAME || exit 1 |
|
120 chmod $MT_FILE_PERMS $PKNAME |
|
121 |
|
122 # Update ls-R if necessary. |
|
123 $TEXMFCNF_DIR/MakeTeXupdate $PKDESTDIR $PKNAME |
|
124 |
|
125 # If this line (or an equivalent) is not present, dvipsk/xdvik/dviljk |
|
126 # will think MakeTeXPK failed. Any other output to stdout will also lose. |
|
127 echo $PKDESTDIR/$PKNAME >$STDOUT |
|
128 |
|
129 ) 1>&2 </dev/null |
|
130 # end of redirection stdout, stdin |