summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/mktexmf
blob: f6b8991e8d11ce9b90e0ad47defcc3206311790f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh
# original mktexmf -- make a new MF file, because one wasn't found.
# 
# (If you change or delete the word `original' on the previous line,
# installation won't write this script over yours.)
# 
# Originally written by Thomas Esser.
# Public domain.

version='$Id$'

# preferentially use subprograms from our own directory.
mydir=`echo "$0" | sed 's,/[^/]*$,,'`
mydir=`cd "$mydir" && pwd`
PATH="$mydir:$PATH"; export PATH

usage="Usage: $0 FONT.

Makes the Metafont source file for FONT, if possible. For example,
\`ecr12' or \`cmr11'.

Report bugs to: tex-k@tug.org
TeX Live home page: <http://tug.org/texlive/>
"

# Common code for all scripts.
: ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
: ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt"
if test ! -f "$MT_MKTEX_OPT"; then
  echo "$progname: Cannot find mktex.opt; check your installation." >&2
  exit 1
fi

. "$MT_MKTEX_OPT"

(
# See comments in mktexpk.
name="`echo $1 | sed 's%.*/%%; s%\.mf$%%'`"
rootname=`echo "$name" | sed 's/[0-9]*$//'`
pointsize=`echo "$name" | sed "s/^$rootname//"`

sauterroot=`kpsewhich b-$rootname.mf 2>/dev/null`
if test -n "$sauterroot"; then
  rootfile=$sauterroot
  rootname=b-$rootname
else
  case $name in
    # csso12[0-5][0-9] from CJK package; unsupported by mktexmf
    csso12[0-5][0-9])
      rootfile=;;
    *)
      case $rootname in
        cs*|lcsss*|icscsc*|icstt*|ilcsss*)
          rootfile=`kpsewhich cscode.mf`;;
        wn[bcdfirstuv]*|rx[bcdfiorstuvx][bcfhilmostx]|l[abcdhl][bcdfiorstuvx]*)
          lhprefix=`echo "$name" | sed 's/^\(..\).*/\1/'`
          rootfile=`kpsewhich ${lhprefix}codes.mf 2>/dev/null`;;
        *)
          rootfile=`kpsewhich $rootname.mf 2>/dev/null`;;
      esac;;
  esac
fi
{ test -z "$rootfile" || test ! -f "$rootfile"; } && exit 1

#if test -z "$MT_MFNAME"; then
OIFS=$IFS; IFS=$SEP
set x `"$MT_MKTEXNAM" $name`; shift
IFS=$OIFS
MT_MFNAME="$3"
#fi

destdir=`echo "$MT_MFNAME" | sed 's%/[^/][^/]*$%%'`
test -d "$destdir" || "$MT_MKTEXDIR" "$destdir" || exit 1
cd "$destdir" || exit 1

case "$pointsize" in
  "") echo "$progname: no pointsize."; exit 1;;
  11) realsize=10.95;;      # \magstephalf
  14) realsize=14.4;;  # \magstep2
  17) realsize=17.28;; # \magstep3
  20) realsize=20.74;; # \magstep4
  25) realsize=24.88;; # \magstep5
  30) realsize=29.86;; # \magstep6
  36) realsize=35.83;; # \magstep7
        # The new convention is to have three or four letters for the
        # font name and four digits for the pointsize. The number is
        # pointsize * 100. We effectively divide by 100 by ignoring the
        # last two digits.
  ????|?????) realsize=`echo "$pointsize" | sed 's/\(..\)$/.\1/'`;;
  *) realsize="$pointsize";;
esac

mfname="$name.mf"
if test -r "$mfname"; then
  echo "$progname: $destdir/$mfname already exists."
  echo "$destdir/$mfname" >$STDOUT
  "$MT_MKTEXUPD" "$destdir" "$mfname"
  exit 0
fi

case "$name" in
  ec*|tc*)
    cat > "mf$$.tmp" <<END
if unknown exbase: input exbase fi;
gensize:=$realsize;
generate $rootname;
END
    ;;
  dc*)
    cat > "mf$$.tmp" <<END
if unknown dxbase: input dxbase fi;
gensize:=$realsize;
generate $rootname;
END
    ;;
  cs*|lcsss*|icscsc*|icstt*|ilcsss*)
    cat > "mf$$.tmp" <<END
input cscode
use_driver;
END
    ;;
  wn[bcdfirstuv]*|rx[bcdfiorstuvx][bcfhilmostx]*|l[abcdhl][bcdfiorstuvx]*)
    cat > "mf$$.tmp" <<END
input fikparm;
END
    ;;
  g[lmorst][bijmtwx][cilnoru]*)
    # A small superset of the names of the cbgreek fonts.
    cat > "mf$$.tmp" <<END
% generated by mktexmf
input cbgreek;
END
    ;;
  *)
    cat > "mf$$.tmp" <<END
design_size := $realsize;
input $rootname;
END
    ;;
esac

chmod `kpsestat -xst,go-w .` "mf$$.tmp"
rm -f "$mfname"
mv "mf$$.tmp" "$mfname"

echo "$destdir/$mfname" >$STDOUT
echo "$progname: $destdir/$mfname: successfully generated." >&2
"$MT_MKTEXUPD" "$destdir" "$mfname"
exit 0
) 1>&2 </dev/null