#!/bin/sh

progname=`basename $0`

case "$progname" in
alldc)	encoding=T1  ;;
*)	encoding=OT1 ;;
esac

case "$1" in
-r)	DVIPS=dvired
	shift
	;;
*)	DVIPS=dvips
	;;
esac

body()
{
	cat <<-'eof'
		\pagestyle{empty}
		\parindent0in
		\textheight9.5in
		\textwidth6.5in
		\newcommand{\TestSizes}{{%
		\tiny Test\scriptsize Test\footnotesize Test\small Test
		\normalsize Test
		\large Test\Large Test\LARGE Test\huge Test\Huge Test}}
		\newcommand{\TestRM}{rm-family: {\rmfamily\TestSizes}\newline}
		\newcommand{\TestSF}{sf-family: {\sffamily\TestSizes}\newline}
		\newcommand{\TestTT}{tt-family: {\ttfamily\TestSizes}\newline}
		\newcommand{\TestFamilies}{\TestRM\TestSF\TestTT\newline}
		\newcommand{\TestMD}{md-series: {\mdseries\TestFamilies}}
		\newcommand{\TestBF}{bf-series: {\bfseries\TestFamilies}}
		\newcommand{\TestSeries}{\TestBF\TestMD\par}
		\newcommand{\TestUP}{up-shape: {\upshape\TestSeries}\par}
		\newcommand{\TestIT}{it-shape: {\itshape\TestSeries}\par}
		\newcommand{\TestSL}{sl-shape: {\slshape\TestSeries}\par}
		\newcommand{\TestSC}{sc-shape: {\scshape\TestSeries}\par}
		\newcommand{\TestShapes}{\TestUP\TestIT\TestSL\TestSC}
		\begin{document}
		\TestShapes
		\end{document}
	eof
}

head()
{
	echo '\documentclass['$1'pt]{article}'
	echo '\usepackage['$encoding']{fontenc}'
}

cd /tmp
mkdir tmp$$ && cd tmp$$ || exit
trap "cd / ; rm -rf /tmp/tmp$$; trap '' 0; exit 0" 0 1 2 15

echo >&2
echo "---------------------------------------------------------------------" >&2
echo ">>>>>>>>>>>  Generating testfiles for 10pt, 11pt and 12pt. <<<<<<<<<<" >&2
echo "---------------------------------------------------------------------" >&2
head 10 > allcm10.tex
head 11 > allcm11.tex
head 12 > allcm12.tex
body >> allcm10.tex
body >> allcm11.tex
body >> allcm12.tex

echo >&2
echo "---------------------------------------------------------------------" >&2
echo ">>>>>>>>>>>  Calling latex (expect some warnings)...       <<<<<<<<<<" >&2
echo "---------------------------------------------------------------------" >&2
latex allcm10
latex allcm11
latex allcm12

echo >&2
echo "---------------------------------------------------------------------" >&2
echo ">>>>>>>>>>>  Now, calling $DVIPS to make missing fonts...  <<<<<<<<<<" >&2
echo "---------------------------------------------------------------------" >&2
$DVIPS -f "$@" allcm10 > /dev/null
$DVIPS -f "$@" allcm11 > /dev/null
$DVIPS -f "$@" allcm12 > /dev/null
cd /
rm -rf /tmp/tmp$$
