#!/bin/sh
#
# Mojikyo TrueType Font (for Windows) installer for mjfonts2
# (C) Nobuyuki Tsuchimura (tutimura@nn.iij4u.or.jp)
# 2001/ 5/18 http://www.nn.iij4u.or.jp/~tutimura/tex/

DST=/usr/share/fonts/TrueType
VFONTCAP="/etc/vfontcap /usr/share/fonts/TrueType/vfontcap.mjfonts2.add"
# modify these two files at the same time for RPM

if [ -z "$1" ]; then
    cat <<EOF
usage : mjfonts2inst [install directory] MOJIK*.EXE
    Install Mojikyo TrueType Font (for Windows) and
    modify "$VFONTCAP".
    Default install directory is "$DST".

    To uninstall TrueType Font, remove TTF files by hand.
EOF
    exit 0
fi

while [ -n "$1" ]; do
    if [ -d $1 ]; then
	pushd $1 > /dev/null
	DST=`pwd`
	popd > /dev/null
	echo "install dir = $DST"
    elif [ -e $1 ]; then
	NAME=`lha l $1 | grep -i ttf | head -1 | awk '{print $NF}'`
	lha -xw=$DST $1 $NAME || exit 1
	for f in $VFONTCAP; do
	    cp -f $f $f.tmp || exit 1
	    sed -e "s|:ff=/.*/$NAME:|:ff=$DST/$NAME:|ig" <$f.tmp >$f || exit 1
	    rm -f $f.tmp
	done
    fi
    shift 1
done
