:
# installfont
# Usage: installfont
#
# David MacKenzie
# Latest revision: 07/21/88

#fontdir=/usr/lib/hpfont
finfodir=/usr/lib/hpfontinfo

# No cleanup performed currently.
#trap 'exit' 1 2 3 15

echo '
This program installs an HP LaserJet soft font family for troff use.
Three types of files are involved in this process:

1.  LaserJet font files (typically with extension .sfp or .usp)
2.  width files for troff (called ftXX)
3.  fontinfo files for troff2lj (called fiXX)

Starting out with a file of type 1., this program generates the other two.

You need to run this program once for each style in each font family
(i.e., Roman, Bold, Italic, any other variation), but for only one
pointsize within each style (which pointsize you use does not matter).'

valid=false
while [ $valid = false ]
do
echo '
Enter full path name of LaserJet font file to install:'
read fontfile

if [ -f "$fontfile" ]
then
    valid=true
else
    echo 'File not found.  Try again.'
fi
done

echo '
Currently used names for type 2. and 3. files are:'
ls /usr/lib/font

valid=false
while [ $valid = false ]
do
echo '
Enter 1-or-2-character name (XX) to use for generated type 2. and 3. files:'
read ext

extlen=`expr "$ext" : '.*'`
if [ $extlen -eq 0 -o $extlen -gt 2 ]
then
    echo 'Illegal name.  Try again.'
else
    valid=true
fi

done    

valid=false
while [ $valid = false ]
do
echo "
You have two options for where I will put the type 2. and 3. files that
I generate:

1.  Put them both in the current directory
2.  Put the ft$ext file in /usr/lib/font and the fi$ext file in $finfodir
    (they will be generated in the current directory and then moved to
    the appropriate directories)

Select one:"
read place

case $place in
    1) mvfiles=false; valid=true ;;
    2) mvfiles=true; valid=true ;;
    *) echo 'Illegal location.  Try again.' ;;
esac
done

echo "
Generating ft$ext..."
# Generate ftXX file for troff.
hpwidth $fontfile > ft$ext.c
ccfont ft$ext
rm ft$ext.c
if [ $mvfiles = true ]
then
    mv ft$ext /usr/lib/font
fi

echo "
Generating fi$ext..."
# Generate fiXX file for troff2lj.
mkhpfi $fontfile fi$ext
if [ $mvfiles = true ]
then
    mv fi$ext $finfodir
fi

echo '
Done.'
