#!/bin/ksh
# leave WINDOWSTTFDIR empty if ttf2tfm can find ttf files on it's own (this
# should be the case if installed properly)
#WINDOWSTTFDIR=/u/local/ttf/windows95/
WINDOWSTTFDIR=
DIR=`pwd`
WGL4ENC=$DIR/T1-WGL4.enc
WINHEBENC=$DIR/WINHEB.enc
WINHEBENC2=$DIR/WINHEB2.enc
WINHEBENC3=$DIR/WINHEB3.enc
cd $DIR || exit 1
mkdir tfm || exit 1
chmod a+rx tfm || exit 1
cd tfm || exit 1
TTFONTSMAP=ttfonts.map
: > $TTFONTSMAP

# English Windows-95 fonts
ttf2tfm ${WINDOWSTTFDIR}times.ttf -T $WGL4ENC times| tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}timesbd.ttf -T $WGL4ENC timesbd | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}timesbi.ttf -T $WGL4ENC timesbi | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}timesbs.ttf -T $WGL4ENC timesbs | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}timesi.ttf -T $WGL4ENC timesi | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}comic.ttf -T $WGL4ENC comic| tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}comicbd.ttf -T $WGL4ENC comicbd| tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}cour.ttf -T $WGL4ENC cour| tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}courbd.ttf -T $WGL4ENC courbd | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}courbi.ttf -T $WGL4ENC courbi | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}courbs.ttf -T $WGL4ENC courbs | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}couri.ttf -T $WGL4ENC couri | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}arial.ttf -T $WGL4ENC arial| tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}arialbd.ttf -T $WGL4ENC arialbd | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}arialbi.ttf -T $WGL4ENC arialbi | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}arialbs.ttf -T $WGL4ENC arialbs | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}ariali.ttf -T $WGL4ENC ariali | tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}zinjaron.ttf -T $WGL4ENC zinjaron | tail -1 >>$TTFONTSMAP

echo HEBREW FONTS:
# Hebrew Windows-95 fonts
# Enc3
ttf2tfm ${WINDOWSTTFDIR}gyadl.ttf -N -T $WINHEBENC3 gyadl| tail -1 >>$TTFONTSMAP
#
ttf2tfm ${WINDOWSTTFDIR}gyadbr.ttf -N -T $WINHEBENC3 gyadbr| tail -1 >>$TTFONTSMAP
ttf2tfm ${WINDOWSTTFDIR}gyadxl.ttf -N -T $WINHEBENC3 gyadxl| tail -1 >>$TTFONTSMAP

# Encoding 1 (david fonts)
# usage: hebenc1prepare FILE.TTF FILE.TFM "options"
maketfm_enc1(){
        echo $2:
	# old code: without ligatures: only the following line
	#  ttf2tfm $1 $3 -N -T $WINHEBENC $2 | tail -1 >>$TTFONTSMAP   
	
	ttf2tfm $1 $3 -N -T $WINHEBENC -v tmp.vpl $2 |
		tail -1 >>$TTFONTSMAP
	vptovf tmp.vpl tmp.vfm $2 # overwrite the tfm
	rm tmp.vpl tmp.vfm
}
maketfm_enc1 ${WINDOWSTTFDIR}david.ttf   david.tfm
maketfm_enc1 ${WINDOWSTTFDIR}davidbd.ttf davidbd.tfm
maketfm_enc1 ${WINDOWSTTFDIR}david.ttf   davids.tfm   "-s 0.4"
maketfm_enc1 ${WINDOWSTTFDIR}ahronbd.ttf ahronbd.tfm

# Encoding 2 (times fonts)
# usage: hebenc1prepare FILE.TTF FILE.TFM "options"
maketfm_enc2(){
        echo $2:
	ttf2tfm $1 $3 -N -T $WINHEBENC2 -v tmp.vpl $2 |
		tail -1 >>$TTFONTSMAP
	vptovf tmp.vpl tmp.vfm $2 # overwrite the tfm
	rm tmp.vpl tmp.vfm
}
# note: the -P .. -E .. options should be removed and -n above changed to -N
# once the bug is fixed.
maketfm_enc2 ${WINDOWSTTFDIR}hdas.ttf    hdas.tfm
maketfm_enc2 ${WINDOWSTTFDIR}hdasbd.ttf  hdasbd.tfm
maketfm_enc2 ${WINDOWSTTFDIR}times.ttf   htimes.tfm
maketfm_enc2 ${WINDOWSTTFDIR}timesbd.ttf htimesbd.tfm
maketfm_enc2 ${WINDOWSTTFDIR}timesbi.ttf htimesbi.tfm
maketfm_enc2 ${WINDOWSTTFDIR}timesi.ttf  htimesi.tfm
maketfm_enc2 ${WINDOWSTTFDIR}arial.ttf   harial.tfm
maketfm_enc2 ${WINDOWSTTFDIR}arialbd.ttf harialbd.tfm
maketfm_enc2 ${WINDOWSTTFDIR}arialbi.ttf harialbi.tfm
maketfm_enc2 ${WINDOWSTTFDIR}ariali.ttf  hariali.tfm
# ligatures -- don't work for cour... why??
maketfm_enc2 ${WINDOWSTTFDIR}cour.ttf    hcour.tfm
maketfm_enc2 ${WINDOWSTTFDIR}courbd.ttf  hcourbd.tfm
maketfm_enc2 ${WINDOWSTTFDIR}courbi.ttf  hcourbi.tfm
maketfm_enc2 ${WINDOWSTTFDIR}couri.ttf   hcouri.tfm
