2 # maketexnam -- find PK and TFM names.
3 # Primarily written by Thomas Esser, Karl Berry, and Olaf Weber.
6 version
='$Id: mktexnam 34656 2014-07-18 23:38:50Z karl $'
8 # preferentially use subprograms from our own directory.
9 mydir
=`echo "$0" | sed 's,/[^/]*$,,'`
10 mydir
=`cd "$mydir" && pwd`
11 PATH
="$mydir:$PATH"; export PATH
13 usage
="Usage: $0 NAME [DPI MODE] [DESTDIR].
14 Output the PK, TFM, and MF names for a font NAME.
16 Report bugs to: tex-k@tug.org
17 TeX Live home page: <http://tug.org/texlive/>
21 # Common code for all scripts.
22 : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
23 : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
24 test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT
="$MT_TEXMFMAIN/web2c/mktex.opt"
25 if test ! -f "$MT_MKTEX_OPT"; then
26 echo "$0: Cannot find mktex.opt; check your installation." >&2
34 1|
2) DPI
=$BDPI; DEST
=$2;;
35 3|
4) DPI
=$2; MODE
=$3; DEST
=$4;;
39 : ${MT_PKDESTDIR='$MT_DESTROOT/$MT_PKDESTREL'}
40 : ${MT_TFMDESTDIR='$MT_DESTROOT/$MT_TFMDESTREL'}
41 : ${MT_MFDESTDIR='$MT_DESTROOT/$MT_MFDESTREL'}
42 : ${MT_PKBASE='$NAME.${DPI}pk'}
43 : ${MT_TFMBASE='$NAME.tfm'}
44 : ${MT_MFBASE='$NAME.mf'}
45 : ${MT_DEFAULT_SUPPLIER=unknown}
46 : ${MT_DEFAULT_TYPEFACE=unknown}
47 : ${MT_DEFAULT_NAMEPART='$MT_SUPPLIER/$MT_TYPEFACE'}
48 : ${MT_DEFAULT_PKDESTREL='pk/modeless/$MT_NAMEPART'}
49 : ${MT_DEFAULT_TFMDESTREL='tfm/$MT_NAMEPART'}
50 : ${MT_DEFAULT_MFDESTREL='source/$MT_NAMEPART'}
51 : ${MT_DEFAULT_DESTROOT=$KPSE_DOT}
53 # Find the font: test tfm first, then mf, then possible sauterized mf.
54 fullname
=`kpsewhich "$NAME.tfm" 2>/dev/null`
55 test -z "$fullname" && fullname
=`kpsewhich "$NAME.mf" 2>/dev/null`
56 if test -z "$fullname"; then
57 rootname
=`echo $NAME | sed 's/[0-9]*$//'`
58 fullname
=`kpsewhich "b-$rootname.mf" 2>/dev/null`
59 # LH fonts get special treatment:
60 if test -z "$fullname"; then
62 # Czech/Slovak fonts get special treatment:
63 cs
*|lcsss
*|icscsc
*|icstt
*|ilcsss
*)
64 fullname
=`kpsewhich cscode.mf`
66 # LH fonts get special treatment:
67 wn
[bcdfirstuv
]*|rx
[bcdfiorstuvx
][bcfhilmostx
]|l
[abcdhl
][bcdfiorstuvx
]*)
68 lhprefix
=`echo $NAME | sed 's/^\(..\).*/\1/'`
69 fullname
=`kpsewhich "${lhprefix}codes.mf" 2>/dev/null`;;
70 *) fullname
=`kpsewhich "$rootname.mf" 2>/dev/null`
76 # After all this, do we _have_ a font?
77 if test -z "$fullname"; then
78 : ${MT_DESTROOT="$MT_VARTEXFONTS"}
80 # Normalize $fullname.
81 fullname
=`echo "$fullname" | sed 's%//*%/%g'`
82 # See if $fullname comes from a standard location.
84 set x
`kpsewhich --expand-path='$TEXMF/fonts'"$SEP$MT_VARTEXFONTS"`
88 test -z "$i" && continue
91 # We now have a preliminary value for the destination root.
93 # When we're done, relfmt contains one of these:
94 # "/source/$MT_NAMEPART/"
95 # "/$MT_NAMEPART/source/"
96 # while namepart contains the actual namepart.
97 relfmt
=`echo "$fullname" | \
98 sed -e 's%^'"$i"'\(/.*/\)[^/]*$%\1%' \
99 -e 's%^/tfm/%/source/%' \
100 -e 's%/tfm/$%/source/%'`
101 namepart
=`echo "$relfmt" | sed -e 's%/source/%/%'`
102 # See if namepart is empty.
103 if test "$namepart" != "/"; then
104 relfmt
=`echo "$relfmt" | \
105 sed -e 's%'"$namepart"'%/$MT_NAMEPART/%'`
108 relfmt
='/source/$MT_NAMEPART/'
111 # Determine supplier and typeface from namepart. If there is
112 # only one part in the namepart, we take it to be the typeface.
113 MT_SUPPLIER
=`echo $namepart | sed 's%^/\([^/]*\)/\(.*\)$%\1%'`
114 MT_TYPEFACE
=`echo $namepart | sed 's%^/\([^/]*\)/\(.*\)$%\2%'`
115 if test -z "$MT_TYPEFACE"; then
116 MT_TYPEFACE
="$MT_SUPPLIER";
119 # Phew. Now we create the relative paths for pk, tfm and source.
120 : ${MT_NAMEPART='$MT_SUPPLIER/$MT_TYPEFACE'}
121 : ${MT_PKDESTREL=`echo "$relfmt" | sed 's%/source/%/pk/$MT_MODE/%'`}
122 : ${MT_TFMDESTREL=`echo "$relfmt" | sed 's%/source/%/tfm/%'`}
123 : ${MT_MFDESTREL=`echo "$relfmt"`}
129 # In case some variables remain unset.
130 : ${MT_SUPPLIER=$MT_DEFAULT_SUPPLIER}
131 : ${MT_TYPEFACE=$MT_DEFAULT_TYPEFACE}
132 : ${MT_NAMEPART=$MT_DEFAULT_NAMEPART}
133 : ${MT_PKDESTREL=$MT_DEFAULT_PKDESTREL}
134 : ${MT_TFMDESTREL=$MT_DEFAULT_TFMDESTREL}
135 : ${MT_MFDESTREL=$MT_DEFAULT_MFDESTREL}
137 # We have found nothing, so force using the fontmaps as a last resort.
138 # This also means mktexnam can be queried for advice on where to
140 if test "x$MT_SUPPLIER" = xunknown \
141 ||
test "x$MT_TYPEFACE" = xunknown
; then
142 MT_FEATURES
="$MT_FEATURES:fontmaps"
145 # Handle the options.
146 test -n "$MT_MKTEXNAM_OPT" && .
"$MT_MKTEXNAM_OPT"
148 # Adjust MT_DESTROOT, if necessary.
149 if test -n "${MT_DESTROOT}"; then
150 # We distinguish system trees from the rest.
151 systexmf
="`kpsewhich --expand-path='{$SYSTEXMF}/fonts'`$SEP$MT_VARTEXFONTS"
152 case "$SEP$systexmf$SEP" in
153 *$SEP$MT_DESTROOT$SEP*) # A system tree.
154 # If the texmfvar option is set, use TEXMFVAR tree.
155 # Some additional uglyness handles the case where $TEXMFVAR exists
156 # but $TEXMFVAR/fonts doesn't (yet).
157 if test "x$USE_TEXMFVAR" = x1
; then
158 : ${MT_TEXMFVAR=`kpsewhich --var-value=TEXMFVAR`}
159 MT_DESTROOT
=$MT_TEXMFVAR/fonts
160 if test -z "$MT_TEXMFVAR"; then
161 # Path expansion of $TEXMFVAR was empty.
163 elif test -d "$MT_DESTROOT"; then
164 # Do we have write access and permission?
165 kpseaccess
-w "$MT_DESTROOT" || FALLBACK
=1
166 test -w "$MT_DESTROOT" || FALLBACK
=1
167 elif test -d "$MT_TEXMFVAR"; then
168 # De we have write access and permission?
169 kpseaccess
-w "$MT_TEXMFVAR" || FALLBACK
=1
170 test -w "$MT_TEXMFVAR" || FALLBACK
=1
171 elif test -e "$MT_TEXMFVAR"; then
172 # TEXMFVAR defined and exists, but it is not a directory?
175 # TEXMFVAR defined but does not exist, try to create it
176 MT_FEATURES
=none
"$MT_MKTEXDIR" "$MT_TEXMFVAR" || FALLBACK
=1
179 # Do we have write access and permission?
180 kpseaccess
-w "$MT_DESTROOT" || FALLBACK
=1
181 test -w "$MT_DESTROOT" || FALLBACK
=1
183 # Fall back on VARTEXFONTS if the varfonts option is set, or
184 # we cannot write in the given tree.
185 if test "x$USE_VARTEXFONTS" = x1 ||
test "x$FALLBACK" = x1
; then
186 MT_DESTROOT
=$MT_VARTEXFONTS
188 *) # A non-system tree.
189 # Do we have write access and permission?
190 kpseaccess
-w "$MT_DESTROOT" || FALLBACK
=1
191 test -w "$MT_DESTROOT" || FALLBACK
=1
192 # If we cannot write fall back of defaults.
193 test "x$FALLBACK" = x1
&& MT_DESTROOT
=;;
197 if test -z "$MT_DESTROOT"; then
198 MT_DESTROOT
=$MT_DEFAULT_DESTROOT
199 MT_PKDESTDIR
=$MT_DEFAULT_DESTROOT
200 MT_TFMDESTDIR
=$MT_DEFAULT_DESTROOT
201 MT_MFDESTDIR
=$MT_DEFAULT_DESTROOT
206 /* |
[A-z
]:/*) # Absolute, explicit destdir => use it.
211 *) # Relative destdir => append to the default.
215 eval MT_MODE
=\"$MODE\"
216 eval MT_NAMEPART
=\"$MT_NAMEPART\"
217 eval MT_DESTROOT
=\"$MT_DESTROOT\"
218 eval MT_PKDESTREL
=\"$MT_PKDESTREL\"
219 eval MT_TFMDESTREL
=\"$MT_TFMDESTREL\"
220 eval MT_MFDESTREL
=\"$MT_MFDESTREL\"
221 eval MT_PKDESTDIR
=\"$MT_PKDESTDIR\"
222 eval MT_TFMDESTDIR
=\"$MT_TFMDESTDIR\"
223 eval MT_MFDESTDIR
=\"$MT_MFDESTDIR\"
224 eval MT_PKNAME
=\"$MT_PKDESTDIR/$MT_PKBASE\"
225 eval MT_TFMNAME
=\"$MT_TFMDESTDIR/$MT_TFMBASE\"
226 eval MT_MFNAME
=\"$MT_MFDESTDIR/$MT_MFBASE\"
228 echo "$MT_PKNAME$SEP$MT_TFMNAME$SEP$MT_MFNAME" |
sed 's%//*%/%g'