summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/installfont/installfont-tl
blob: bd64a4dbc0f34d1af48c12e7c4dcf0b807b574c3 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
#!/bin/bash
#
# installfont-tl [options]
#
# installs a LaTeX font family (Postscript Type1, Truetype, Opentype)
# (font series from light to ultra bold + (faked) small caps + faked
# slanted, but no expert fonts) for using them with LaTeX (TeXLive) 
# The script tries to rename the fonts automatically (optional).
# Otherwise the *.afm and *.pfb files must be named in Karl Berry scheme
# (e.g. 5bbr8a.pfb)
# (tested with Ubuntu 9.10) v1.6a (03.11.2010)
# (C) Josef Kleber, Christoph Bier 2009-2010  License: LPPL
#
VERSION="v1.6a (2010/11/03)"
#
FONTFAMILY="5bb"
FONTNAME="Softmaker Barbedor"
FONTCOMMAND="FFBarbedor"
FONTSCALEPREFIX="Sbb"
FONTTYPE="pst1"
PACKAGENAME="barbedor"
PACKAGEDATE="2010/03/05"
PACKAGEVERSION="v1.0"
MAPFILENAME=""
OFN="false"
LOCALTEXMF="`kpsexpand '$TEXMFHOME'`"
FONTSUBDIR="MyFonts/Barbedor"
# Font encoding default: 8a (AdobeStandardEncoding)
FONTENCODING="8a"
# Font cut default: r (regular) don't change!
FONTCUT="r"
#
OTFFONTFEATURES="-fkern -fliga"
UNINSTALL="false"
INSTALLAS="rmdefault"
SMFFSTY="%"
LOG="false"
#
function printHelp()
{
  echo -e \
          "  `basename $0` [options]\n"\
          " installs a font family for using it with LaTeX\n\n"\
          " Options:\n\n"\
          " -f, --fontfamily  Name of the LaTeX font family, e.g. ptm (Adobe Times)\n\n"\
          " -n, --fontname  Font name, e.g. Adobe Times\n\n"\
          " -c, --fontcommand  Name of the command that will switch to the font\n\n"\
          " -P, --fontscaleprefix  prefix of the scale macro, which should be different\n"\
          "                        for each font (no digits allowed)\n\n"\
          " -t, --fonttype  Font type (pst1(default)|ttf|otf)\n\n"\
          " -p, --packagename  Name of the LaTeX package\n\n"\
          " -d, --packagedate  Date of the LaTeX package\n\n"\
          " -v, --packageversion  Version of the LaTeX package\n\n"\
          " -l, --localtexmf  root of your local TeX tree, e.g. /cygdrive/c/LocalTeXMF\n\n"\
          " -m, --mapfilename file name of the map file\n\n"\
          " -O. --origfontname  use original font names instead of Karl Berry names\n\n"\
          " -s, --fontsubdir  location where the fonts and support files should be\n"\
          "                   installed, e.g. MyFonts/AdobeTimes\n\n"\
          " -e, --fontencoding   encoding of the font\n"\
          "                      (default: 8a (AdobeStandardEncoding))\n\n"\
          " -o, --otffontfeatures  choosing Opentype font features\n"\
          "                        (default: -fkern -fliga)\n\n"\
          " -u, --uninstall  will uninstall the font family. You must specify\n"\
          "                  --localtexmf and --fontsubdir\n\n"\
          " -R, --rmdefault  installs font family as roman (serif) font family (default)\n\n"\
          " -S, --sfdefault  installs font family as sans serif font family\n\n"\
          " -T, --ttdefault  installs font family as typewriter font family\n\n"\
          " -V, --version  will print the version number of `basename $0`\n\n"\
          " -L, --log  will write the terminal output of the main programms into the\n"\
          "            LOG file instead of the screen\n\n"\
          " -h, --help  will print this help statement\n\n"\
          " See http://latex.josef-kleber.de/index.htm or\n"\
          "     http://latex.josef-kleber.de/en_index.htm\n"\
          " for more information"
  exit 0;
}
function printVersion()
{
  echo "This is version $VERSION of `basename $0`"
  exit 0;
}
#
if [ $# -eq 0 ]
then
  echo -e "`basename $0`: Could not find command line arguments.\nUse the '--help' option for explanation."
  echo -e "Continue with default script variables? (y/n)"
  read ANSWER
  if [ $ANSWER = "n" -o $ANSWER = "N" ]
  then
    exit 1
  fi
fi
#
LONGOPTS="fontfamily:,fontname:,fontcommand:,fontscaleprefix:,fonttype:,packagename:,packagedate:,packageversion:,mapfilename:,origfilename,localtexmf:,fontsubdir:,fontencoding:,otffontfeatures:,uninstall,rmdefault,sfdefault,ttdefault,log,version,help"
SHORTOPTS="f:n:c:P:t:p:d:v:m:Ol:s:e:o:uRSTVLh"
ARGS=$(getopt -l "$LONGOPTS" "$SHORTOPTS" "$@")
if [ $? -ne 0 ]
then
  echo -e "`basename $0`: Could not process command line arguments.\nUse the '--help' option for explanation."
  exit 1
fi
#
eval set -- "$ARGS"
#
while [ $# -gt 0 ]; do
  ARG=$1
  case "$ARG" in
      --help|-h)            shift; printHelp;;
      --version|-V)         shift; printVersion;;
      --rmdefault|-R)       shift; INSTALLAS="rmdefault";;
      --sfdefault|-S)       shift; INSTALLAS="sfdefault";;
      --ttdefault|-T)       shift; INSTALLAS="ttdefault";;
      --uninstall|-u)       shift; UNINSTALL="true";;
      --log|-L)             shift; LOG="true";;
      --fontfamily|-f)      shift; FONTFAMILY="$1"; shift;;
      --fontname|-n)        shift; FONTNAME="$1"; shift;;
      --fontcommand|-c)     shift; FONTCOMMAND="$1"; shift;;
      --fontscaleprefix|-P) shift; FONTSCALEPREFIX="$1"; shift;;
      --fonttype|-t)        shift; FONTTYPE="$1"; shift;;
      --packagename|-p)     shift; PACKAGENAME="$1"; shift;;
      --packagedate|-d)     shift; PACKAGEDATE="$1"; shift;;
      --packageversion|-v)  shift; PACKAGEVERSION="$1"; shift;;
      --mapfilename|-m)     shift; MAPFILENAME="$1"; shift;;
      --origfontname|-O)    shift; OFN="true";;
      --localtexmf|-l)      shift; LOCALTEXMF="$1"; shift;;
      --fontsubdir|-s)      shift; FONTSUBDIR="$1"; shift;;
      --fontencoding|-e)    shift; FONTENCODING="$1"; shift;;
      --otffontfeatures|-o) shift; FONTFAMILY="$1"; shift;;
      --)                   shift; break;;
      *)                    break;;
  esac
done
#
rm LOG 2>>/dev/null;
#
if [ -z $MAPFILENAME ]
then
  MAPFILENAME=$FONTFAMILY
fi
#
typeset -i STEP=0
#
if [ $UNINSTALL = "true" ]
then
  DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/"
  echo -e "$\n\n$DIR"
  DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/"
  echo $DIR
  DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/"
  echo $DIR
  DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/"
  echo $DIR
  DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/"
  echo $DIR
  echo -e "\n\nDo you want to delete these directories? (y/n)"
  read ANSWER
  if [ $ANSWER = "y" -o $ANSWER = "Y" ]
  then
    DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/"
    rm -f -r $DIR
    DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/"
    rm -f -r $DIR
    DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/"
    rm -f -r $DIR
    DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/"
    rm -f -r $DIR
    DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/"
    rm -f -r $DIR
    exit 0
  else
    exit 1
  fi
fi
#
if [ $FONTTYPE = "ttf" ]
then
  ((STEP++))
  echo -e "\n\n$STEP) Convert font(s) to Postscript Type1\n\n"
  for file in *.TTF;
  do
    mv "$file" "${file%TTF}ttf" 2>>/dev/null;
  done
  for file in *.ttf; 
  do
    ttf2pt1 -a -b -l adobestd "$file";
  done
fi
#
if [ $FONTTYPE = "otf" ]
then
  ((STEP++))
  echo -e "\n\n$STEP) Convert font(s) to Postscript Type1\n\n"
  for file in *.OTF;
  do
    mv "$file" "${file%OTF}otf" 2>>/dev/null;
  done
  for file in *.otf; 
  do
    otftotfm $OTFFONTFEATURES -e - "$file" 555;
  done
  for file in *.pfb; 
  do
    pf2afm "$file";
  done
  rm *.tfm
  rm *.enc
fi
#
echo -e "\n\nTry to rename the font(s) automatically? (y/n)"
read ANSWER
if [ $ANSWER = "y" -o $ANSWER = "Y" ]
then
  ((STEP++))
  echo -e "\n\n$STEP) Renaming fonts\n\n"
  mkdir -p Backup
  cp *.afm *.AFM ./Backup 2>>/dev/null
  cp *.pfb *.PFB ./Backup 2>>/dev/null
  for file in *.AFM;
  do
    mv "$file" "${file%AFM}afm" 2>>/dev/null;
  done
  for file in *.PFB;
  do
    mv "$file" "${file%PFB}pfb" 2>>/dev/null;
  done
  FONTNUMBER=$(ls -al *.pfb 2>>/dev/null | wc -l)
  if [ $FONTNUMBER -le 1 ]
  then
    if [ $FONTNUMBER -eq 0 ]
    then
      echo "No font(s) to rename!"
      exit 1
    else
      for file in *.afm; 
      do
        mv "$file" ${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      done
      for file in *.pfb; 
      do
        mv "$file" ${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
        echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.pfb}/" >>map.sed;
      done
    fi
  else
    mkdir -p Rename
    # rename small caps font(s)
    FILES=$(grep -e "Smc" -e "Caps" -e "SCOsF" *.afm | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      FONTCUT="rc"
      FWEIGHT=$(grep -e "Light" "$file" | wc -l)
      if [ $FWEIGHT -gt 0 ]
      then
        FONTCUT="lc"
      else
        FWEIGHT=$(grep -e "Semibold" -e "SemiBold" "$file" | wc -l)
        if [ $FWEIGHT -gt 0 ]
        then
          FONTCUT="sc"
        else
          FWEIGHT=$(grep -e "Demi" -e "Demibold" -e "DemiBold" "$file" | wc -l)
          if [ $FWEIGHT -gt 0 ]
          then
            FONTCUT="dc"
          else
            FWEIGHT=$(grep -e "Extrabold" -e "ExtraBold" "$file" | wc -l)
            if [ $FWEIGHT -gt 0 ]
            then
              FONTCUT="xc"
            else 
              FWEIGHT=$(grep -e "Heavy" -e "Ultrabold" -e "UltraBold" "$file" | wc -l)
              if [ $FWEIGHT -gt 0 ]
              then
                FONTCUT="uc"
              else
                FWEIGHT=$(grep -e "Bold" -e "bold" "$file" | wc -l)
                if [ $FWEIGHT -gt 0 ]
                then
                  FONTCUT="bc"
                fi
              fi
            fi
          fi
        fi
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
    done
    # rename the light font(s)
    FILES=$(grep -e "Light" *.afm | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="li"
      else
        FONTCUT="l"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
	  SMFFSTY="\RequirePackage{softmakerfreefont}%"
    done
    # rename the semi(bold) font
    FILES=$(grep -e "Semibold" -e "SemiBold" *.afm | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="si"
      else
        FONTCUT="s"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
	  SMFFSTY="\RequirePackage{softmakerfreefont}%"
    done
    # rename the demi(bold) font
    FILES=$(grep -e "FontName" -e "FullName" *.afm | grep -e "Demi" -e "Demibold" -e "DemiBold" | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="di"
      else
        FONTCUT="d"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
	  SMFFSTY="\RequirePackage{softmakerfreefont}%"
    done
    # rename the extra bold font
    FILES=$(grep -e "Extrabold" -e "ExtraBold" *.afm | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="xi"
      else
        FONTCUT="x"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
    done
    # rename the ultra bold/heavy font
    FILES=$(grep -e "Heavy" -e "Ultrabold" -e "UltraBold" *.afm | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="ui"
      else
        FONTCUT="u"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
	  SMFFSTY="\RequirePackage{softmakerfreefont}%"
    done
    # rename the bold font
    FILES=$(grep -e "Bold" -e "bold" *.afm | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="bi"
      else
        FONTCUT="b"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
    done
    # rename the regular font
    FILES=$(grep -e "Regular" -e "Medium" -e "Book" --exclude=installfont * | grep -e ".afm" | cut -d':' -f1 | uniq)
    for file in $FILES
    do
      ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1)
      if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ]
      then
        FONTCUT="ri"
      else
        FONTCUT="r"
      fi
      mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm;
      mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb;
      echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed;
    done
    mv ./Rename/* .
    rmdir ./Rename
  fi
  ls -al *.pfb *.afm
  echo -e "\n\nPlease check the font name(s). Continue? (y/n)"
  read ANSWER
  if [ $ANSWER = "n" -o $ANSWER = "N" ]
  then
    rm *.afm
    rm *.pfb
    rm *.sed
    mv ./Backup/* .
    rmdir ./Backup
    exit 1
  fi
fi
#
((STEP++))
echo -e "\n\n$STEP) Creating metrics and virtual fonts\n\n"
cat >${FONTFAMILY}-drv.tex <<EOF
\input fontinst.sty
\needsfontinstversion{1.926}
\recordtransforms{${FONTFAMILY}-rec.tex}
\latinfamily{${FONTFAMILY}}{}
\endrecordtransforms
\bye
EOF
if [ $LOG = "true" ]
then
  tex ${FONTFAMILY}-drv.tex >>LOG 2>&1
else
  tex ${FONTFAMILY}-drv.tex
fi
#
((STEP++))
echo -e "\n\n$STEP) Compiling metrics and virtual fonts\n\n"
for file in *.pl; 
do  
  if [ $LOG = "true" ]
  then
    pltotf $file ${file%pl}tfm >>LOG 2>&1
  else
    pltotf $file ${file%pl}tfm
  fi
done
for file in *.vpl; 
do  
  if [ $LOG = "true" ]
  then
    vptovf $file ${file%vpl}vf ${file%vpl}tfm >>LOG 2>&1
  else
    vptovf $file ${file%vpl}vf ${file%vpl}tfm
  fi
done
#
((STEP++))
echo -e "\n\n$STEP) Creating the map file\n\n"
cat >${FONTFAMILY}-map.tex <<EOF
\input finstmsc.sty
\resetstr{PSfontsuffix}{.pfb}
\adddriver{dvips}{${FONTFAMILY}.map}
\input ${FONTFAMILY}-rec.tex
\donedrivers
\bye
EOF
if [ $LOG = "true" ]
then
  tex ${FONTFAMILY}-map.tex >>LOG 2>&1
else
  tex ${FONTFAMILY}-map.tex
fi
if [ $OFN = "true" ]
then
  sed -f map.sed ${FONTFAMILY}.map >${MAPFILENAME}.map
  unix2dos ${MAPFILENAME}.map 2>>/dev/null;
  rm ${FONTFAMILY}.map
  UMAP="${MAPFILENAME}"
else
  UMAP="${FONTFAMILY}"
fi
#
((STEP++))
echo -e "\n\n$STEP) Creating the style file"
cat >${PACKAGENAME}.sty <<EOF
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{$PACKAGENAME}[$PACKAGEDATE $PACKAGEVERSION $FONTNAME]%
\RequirePackage{textcomp}%
\RequirePackage{xkeyval}%
\define@key{${PACKAGENAME}.sty}{scaled}[1.0]%
{%
  \def\\${FONTSCALEPREFIX}@scale{#1}%
}%
\define@key{${PACKAGENAME}.sty}{leading}[1.0]%
{%
  \linespread{#1}%
}%
\ExecuteOptionsX{scaled}%
\ProcessOptionsX\relax%
\renewcommand*{\\${INSTALLAS}}{$FONTFAMILY}%
\newcommand\\${FONTCOMMAND}{\fontfamily{$FONTFAMILY}\fontseries{m}\fontshape{n}\selectfont}%
\endinput%
EOF
#
((STEP++))
echo -e "\n\n$STEP) Insert scale factor into the fd files"
cat >installfont.sed <<EOF
9 i\\
\\n\\\\expandafter\\\\ifx\\\\csname ${FONTSCALEPREFIX}@scale\\\\endcsname\\\\relax\\n  \\\\let\\\\${FONTSCALEPREFIX}@@scale\\\\@empty\\n\\\\else\\n  \\\\edef\\\\${FONTSCALEPREFIX}@@scale{s*[\\\\csname ${FONTSCALEPREFIX}@scale\\\\endcsname]}\\n\\\\fi\\n
s/<-> /<-> \\\\${FONTSCALEPREFIX}@@scale /
EOF
#
for file in *.fd;
do
  mv $file ${file%fd}fdb;
  sed -f installfont.sed ${file%fd}fdb >$file;
done
#
((STEP++))
echo -e "\n\n$STEP) Installing font(s) and support files"
DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/"
if [ ! -d $DIR ]
then
  mkdir -p $DIR
fi
mv *.tfm $DIR
DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/"
if [ ! -d $DIR ]
then
  mkdir -p $DIR
fi
mv *.vf $DIR
DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/"
if [ $OFN = "true" ]
then
  cd Backup
  if [ ! -d $DIR ]
  then
    mkdir -p $DIR
  fi
  cp *.pfb $DIR
  cd ..
else
  if [ ! -d $DIR ]
  then
    mkdir -p $DIR
  fi
  cp *.pfb $DIR
fi
DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/"
if [ ! -d $DIR ]
then
  mkdir -p $DIR
fi
mv *.map $DIR
DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/"
if [ ! -d $DIR ]
then
  mkdir -p $DIR
fi
mv *.fd $DIR
DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/"
if [ ! -d $DIR ]
then
  mkdir -p $DIR
fi
mv *.sty $DIR
#
((STEP++))
echo -e "\n\n$STEP) Include the map file"
echo -e "\n\n"
updmap --enable Map ${UMAP}.map
rm *.mtx
rm *.pl
rm *.vpl
rm *.log
rm *.tex
rm *.fdb
rm *.sed
if [ -d Backup ]
then
  rm *.afm
  rm *.pfb
  mv ./Backup/* .
  rmdir ./Backup
fi
echo -e "\n\nThe font(s) should be installed now!"
exit 0