#! /bin/sh
#
# Front-end for /usr/local/X/bin/xdvi, the TeX previewer
#
# What we want is an easy way to specify the fonts to use:
#
#	1. -P<printer> flag
#	2. The environment variable PRINTER
#	3. The default is "psc"
#
# Besides we want to add our own fonts and most notably the Go diagram
# fonts of Hanna Kolodziejska.
#
# Author: Jan van der Steen
# Date	: Fri Aug 30 11:58:52 MET DST 1991

usage="xdvi [-P<printer>] [xdvi_options] dvi_file"

#
# System settings
#
BITMAPS=/usr/local/TeX/lib/fonts
XDVI=/usr/local/X11R5/bin/xdvi

#
# Available fonts
#
psc="300:329:360:432:518:622:746"
agfa="406:445:487:585:702:842:1010"
oce="508:556:610:732:878:1053:1264"
compu="1200:1315:1440:1728:2074:2488:2986"

#
# Get the options
#
case $1 in
    -P*)
	PRINTER=`expr ${1} : '-P\(.*\)'`
	case ${PRINTER} in
	    #
	    # See /etc/printcap for legal/equal PRINTER values
	    #
	    psc)				PRINTER="psc"		;;
	    hqpsc|agfa|P400|hq2psc|sjors|ag|hq3psc|sjimmie|fa)
						PRINTER="agfa"		;;
	    oce|ps|PostScript|postscript)	PRINTER="oce"		;;
	    compu|compugraphic)			PRINTER="compugraphic"	;;
	esac
	shift;;
    *)	PRINTER=${PRINTER-"psc"};;
esac

#
# The Go font bitmaps
#
GOTEX=/ufs/jansteen/games2/go/TeX/Hanna
GOPSC=${GOTEX}/Go_300pk
GOOCE=${GOTEX}/Go_508pk

case ${PRINTER} in
    psc)		resolution="300"; EXTRA=${GOPSC} ;;
    agfa)		resolution="406" ;;
    oce)		resolution="508"; EXTRA=${GOOCE} ;;
    compugraphic)	resolution="1200";;
    *)	echo "Bad printer specification" >&2; echo "${usage}" >&2; exit 2;;
esac

XDVIFONTS="${EXTRA}:.:${BITMAPS}/${PRINTER}:/tmp/TeX_pk"; export XDVIFONTS
XDVISIZES="${EXTRA}:${PRINTER}";			  export XDVISIZES

#
# Execute /usr/local/X/bin/xdvi
#
exec ${XDVI} -p ${resolution} -hushspecials -margins 1 $*
