#!/bin/bash

if test "x$2" = "x"; then
    echo "Usage: $0 TeX-name PS-name [expansion]"
    exit 1
fi

export TEXINPUTS="`pwd`:\$TEXMF/tex/{plain,generic,}//"
echo TEXINPUTS = $TEXINPUTS

tname=${1%.*}
pname=${2%.*}

tbase=`echo $tname | sed  's/[+-][0-9]*$//'`
ttag=`expr $tname : '.*\([+-][0-9]*\)$'`
pbase=`echo $pname | sed  's/[+-][0-9]*$//'`
ptag=`expr $pname : '.*\([+-][0-9]*\)$'`
pbase8r=`echo $pbase | sed 's/8a/8r/'`

if test "x$ttag" != "x$ptag"; then
cat <<EOF > a.tex
\input ufntinst.sty
\transformfont{$pname$ttag}{\xscalefont{\add{1000}{$ttag}}{\fromafm{$pname}}}
\bye
EOF
tex a.tex
fi

cat <<EOF > b.tex
\input ufntinst.sty

\installfonts
\installcsfont{$tbase}{$pbase8r}{$ttag}{$pbase}
\endinstallfonts
\bye
EOF
tex b.tex

for f in *.pl; do pltotf ${f%.pl}; done
for f in *.vpl; do vptovf ${f%.vpl}; done
