3172
|
1 #!/bin/sh |
|
2 # maketexnam -- find PK and TFM names. |
|
3 # te@informatik.uni-hannover.de, kb@mail.tug.org, and infovore@xs4all.nl. |
|
4 # Public domain. |
|
5 |
|
6 version='$Id: mktexnam,v 1.20 1998/03/16 18:25:12 olaf Exp $' |
|
7 usage="Usage: $0 NAME [DPI MODE] [DESTDIR]. |
|
8 Output the PK, TFM, and MF names for a font NAME." |
|
9 mt_max_args=4 |
|
10 |
|
11 # Common code for all scripts. |
|
12 : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`} |
|
13 : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`} |
|
14 test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt" |
|
15 if test ! -f "$MT_MKTEX_OPT"; then |
|
16 echo "$0: Cannot find mktex.opt; check your installation." >&2 |
|
17 exit 1 |
|
18 fi |
|
19 |
|
20 . "$MT_MKTEX_OPT" |
|
21 |
|
22 NAME=$1 |
|
23 case $# in |
|
24 1|2) DPI=$BDPI; DEST=$2;; |
|
25 3|4) DPI=$2; MODE=$3; DEST=$4;; |
|
26 *) help;; |
|
27 esac |
|
28 |
|
29 MT_PKDESTDIR='$MT_DESTROOT/$MT_PKDESTREL' |
|
30 MT_TFMDESTDIR='$MT_DESTROOT/$MT_TFMDESTREL' |
|
31 MT_MFDESTDIR='$MT_DESTROOT/$MT_MFDESTREL' |
|
32 MT_PKMODEPART='$MT_PKPART/$MT_MODE' |
|
33 MT_PKBASE='$NAME.${DPI}pk' |
|
34 MT_TFMBASE='$NAME.tfm' |
|
35 MT_MFBASE='$NAME.mf' |
|
36 MT_DEFAULT_SUPPLIER=unknown |
|
37 MT_DEFAULT_TYPEFACE=unknown |
|
38 MT_DEFAULT_NAMEPART=tmp |
|
39 MT_DEFAULT_PKDESTREL='' |
|
40 MT_DEFAULT_TFMDESTREL='' |
|
41 MT_DEFAULT_MFDESTREL='' |
|
42 MT_DEFAULT_DESTROOT='$KPSE_DOT' |
|
43 |
|
44 # Find the font: test tfm first, then mf, then possible sauterized mf. |
|
45 fullname=`kpsewhich "$NAME.tfm" 2>/dev/null` |
|
46 test -z "$fullname" && fullname=`kpsewhich "$NAME.mf" 2>/dev/null` |
|
47 if test -z "$fullname"; then |
|
48 rootname=`echo $NAME | sed 's/[0-9]*$//'` |
|
49 fullname=`kpsewhich "b-$rootname.mf" 2>/dev/null` |
|
50 # Fonts starting with wn* get special treatment: |
|
51 if test -z "$fullname"; then |
|
52 case $rootname in |
|
53 wn*) lhname=`echo $NAME | sed 's/^wn/lh/'` |
|
54 fullname=`kpsewhich "$lhname.mf" 2>/dev/null`;; |
|
55 *) fullname=`kpsewhich "$rootname.mf" 2>/dev/null` |
|
56 esac |
|
57 fi |
|
58 fi |
|
59 |
|
60 # After all this, do we _have_ a font? |
|
61 if test -z "$fullname"; then |
|
62 # We have found nothing, so force using the fontmaps as a last resort. |
|
63 # This also means mktexnam can be queried for advice on where to |
|
64 # place fonts. |
|
65 MT_FEATURES="$MT_FEATURES:fontmaps" |
|
66 MT_DESTROOT="$MT_VARTEXFONTS" |
|
67 else |
|
68 # Normalize $fullname. |
|
69 fullname=`echo "$fullname" | sed 's%//*%/%g'` |
|
70 # See if $fullname comes from a standard location. |
|
71 OIFS=$IFS;IFS=$SEP |
|
72 for i in `kpsewhich --expand-path='$TEXMF/fonts'"$SEP$MT_VARTEXFONTS"` |
|
73 do |
|
74 case "$fullname" in |
|
75 $i/*) |
|
76 # We now have a preliminary value for the destination root. |
|
77 MT_DESTROOT="$i" |
|
78 # When we're done, relfmt contains one of these: |
|
79 # "/source/$MT_NAMEPART/" |
|
80 # "/$MT_NAMEPART/source/" |
|
81 # while namepart contains the actual namepart. |
|
82 relfmt=`echo "$fullname" | \ |
|
83 sed -e 's%^'"$i"'\(/.*/\)[^/]*$%\1%' \ |
|
84 -e 's%^/tfm/%/source/%' \ |
|
85 -e 's%/tfm/$%/source/%'` |
|
86 namepart=`echo "$relfmt" | sed -e 's%/source/%/%'` |
|
87 # See if namepart is empty. |
|
88 if test "$namepart" != "/"; then |
|
89 relfmt=`echo "$relfmt" | \ |
|
90 sed -e 's%'"$namepart"'%/$MT_NAMEPART/%'` |
|
91 else |
|
92 # Assume TDS. |
|
93 relfmt='/source/$MT_NAMEPART/' |
|
94 namepart='' |
|
95 fi |
|
96 # Determine supplier and typeface from namepart. If there is |
|
97 # only one part in the namepart, we take it to be the typeface. |
|
98 MT_SUPPLIER=`echo $namepart | sed 's%^/\([^/]*\)/\(.*\)$%\1%'` |
|
99 MT_TYPEFACE=`echo $namepart | sed 's%^/\([^/]*\)/\(.*\)$%\2%'` |
|
100 if test -z "$MT_TYPEFACE"; then |
|
101 MT_TYPEFACE="$MT_SUPPLIER"; |
|
102 MT_SUPPLIER='' |
|
103 fi |
|
104 # Phew. Now we create the relative paths for pk, tfm and source. |
|
105 MT_NAMEPART='$MT_SUPPLIER/$MT_TYPEFACE' |
|
106 MT_PKDESTREL=`echo "$relfmt" | sed 's%/source/%/pk/$MT_MODE/%'` |
|
107 MT_TFMDESTREL=`echo "$relfmt" | sed 's%/source/%/tfm/%'` |
|
108 MT_MFDESTREL=`echo "$relfmt"` |
|
109 # And we're done with the loop now. |
|
110 break |
|
111 esac |
|
112 done |
|
113 IFS=$OIFS |
|
114 fi |
|
115 |
|
116 # In case some variables remain unset. |
|
117 : ${MT_DESTROOT=$MT_DEFAULT_DESTROOT} |
|
118 : ${MT_SUPPLIER=$MT_DEFAULT_SUPPLIER} |
|
119 : ${MT_TYPEFACE=$MT_DEFAULT_TYPEFACE} |
|
120 : ${MT_NAMEPART=$MT_DEFAULT_NAMEPART} |
|
121 : ${MT_PKDESTREL=$MT_DEFAULT_PKDESTREL} |
|
122 : ${MT_TFMDESTREL=$MT_DEFAULT_TFMDESTREL} |
|
123 : ${MT_MFDESTREL=$MT_DEFAULT_MFDESTREL} |
|
124 |
|
125 # Handle the options. |
|
126 test -n "$MT_MKTEXNAM_OPT" && . "$MT_MKTEXNAM_OPT" |
|
127 |
|
128 # Adjust MT_DESTROOT, if necessary. |
|
129 if test "x$MT_DESTROOT" != "x$MT_DEFAULT_DESTROOT"; then |
|
130 # Do we have write access and permission? |
|
131 access -w "$MT_DESTROOT" || USE_ALTERNATE=1 |
|
132 test -w "$MT_DESTROOT" || USE_ALTERNATE=1 |
|
133 # We distinguish system trees from the rest. |
|
134 systexmf="`kpsewhich --expand-path='{$SYSTEXMF}/fonts'`$SEP$MT_VARTEXFONTS" |
|
135 case "$SEP$systexmf$SEP" in |
|
136 *$SEP$MT_DESTROOT$SEP*) # A system tree, check for varfonts. |
|
137 if test "x$USE_VARTEXFONTS" = x1 || test "x$USE_ALTERNATE" = x1; then |
|
138 MT_DESTROOT=$MT_VARTEXFONTS |
|
139 fi ;; |
|
140 *) # A non-system tree. |
|
141 test "x$USE_ALTERNATE" = x1 && MT_DESTROOT=$MT_DEFAULT_DESTROOT ;; |
|
142 esac |
|
143 fi |
|
144 |
|
145 case "$DEST" in |
|
146 "") ;; |
|
147 /* | [A-z]:/*) # Absolute, explicit destdir => use it. |
|
148 MT_PKDESTDIR=$DEST |
|
149 MT_TFMDESTDIR=$DEST |
|
150 MT_MFDESTDIR=$DEST |
|
151 MT_NAMEPART=;; |
|
152 *) # Relative destdir => append to the default. |
|
153 MT_NAMEPART=$DEST;; |
|
154 esac |
|
155 |
|
156 eval MT_MODE=\"$MODE\" |
|
157 eval MT_NAMEPART=\"$MT_NAMEPART\" |
|
158 eval MT_DESTROOT=\"$MT_DESTROOT\" |
|
159 eval MT_PKDESTREL=\"$MT_PKDESTREL\" |
|
160 eval MT_TFMDESTREL=\"$MT_TFMDESTREL\" |
|
161 eval MT_MFDESTREL=\"$MT_MFDESTREL\" |
|
162 eval MT_PKDESTDIR=\"$MT_PKDESTDIR\" |
|
163 eval MT_TFMDESTDIR=\"$MT_TFMDESTDIR\" |
|
164 eval MT_MFDESTDIR=\"$MT_MFDESTDIR\" |
|
165 eval MT_PKNAME=\"$MT_PKDESTDIR/$MT_PKBASE\" |
|
166 eval MT_TFMNAME=\"$MT_TFMDESTDIR/$MT_TFMBASE\" |
|
167 eval MT_MFNAME=\"$MT_MFDESTDIR/$MT_MFBASE\" |
|
168 |
|
169 echo "$MT_PKNAME$SEP$MT_TFMNAME$SEP$MT_MFNAME" | sed 's%//*%/%g' |