#!/bin/sh
#script to setup 24x24 font file
setKfont()
{
	while true
	do
		echo -n "The Kai font HBF font table (ex. kck24.hbf) "
		read Kfont;
		if [ -f "$Kfont" ] 
		then
			echo "The Kai font is $Kfont"
			break
		else
			echo "The font table $Kfont not found.Try again!"
			
		fi
	done
}

setMfont()
{
	while true
	do
		echo  -n "The Ming font HBF font table(ex. kcm24.hbf) "
		read Mfont;
		if [  -f "$Mfont" ] 
		then
			echo "The Ming font is $Mfont"
			break
		else
			echo "The font table $Kfont not found.Try again!"
		fi
	done
}
setLfont()
{
	while true
	do
		echo  -n "The Li font HBF font table(ex. kcm24j.hbf) "
		read Lfont;
		if [ -f "$Lfont" ] 
		then 
			echo "The Li font is $Lfont"
			break
		else
			echo  "The font table $Kfont not found.Try again!"
		fi
	done
}

setDfont()
{
	while true
	do
		echo The default font table is 
		echo  "(1) $Mfont"
		echo  "(2) $Lfont"
		echo  "(3) $Kfont"
		echo -n "please choice (1-3) "
		read sele
		case $sele in
		1) Dfont="$Mfont"
		   break;;	
		2) Dfont="$Lfont"
		   break;;
		3) Dfont="$Kfont"
		   break;;	
		esac
		echo "Wrong choice $sele"
	done	
}			

echo  "The shell script is used to set the HBF font used in cnprint 24x24"

setKfont;
setMfont;
setLfont;
setDfont;

if [ ! -d /usr/local/chinese ]
then
	mkdir /usr/local/chinese
fi

if [ ! -d /usr/local/chinese/HBF ]
then
	mkdir /usr/local/chinese/HBF	
fi

cp -f $Mfont /usr/local/chinese/HBF
cp -f $Lfont /usr/local/chinese/HBF
cp -f $Kfont /usr/local/chinese/HBF
ln -sf /usr/local/chinese/HBF/$Mfont /usr/local/chinese/cnm24.hbf
ln -sf /usr/local/chinese/HBF/$Lfont /usr/local/chinese/cnl24.hbf
ln -sf /usr/local/chinese/HBF/$Kfont /usr/local/chinese/cnk24.hbf
ln -sf /usr/local/chinese/HBF/$Dfont /usr/local/chinese/cnj24.hbf
(echo The font used by cnprint command is setup complete
echo The corresponding font to the HBF table you set right now MUST 
echo be put in the directory /usr/local/chinese
echo !!!! NOTICE !!!! the command gsprint must be setup to correct 
echo printer )
 

		
