#!/bin/bash

##################################

# font rename

function fr {

echo 
echo

echo /"$1"-Ogonki findfont

cat <<EOF
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
currentdict end
EOF


echo 
echo
echo /"$1" exch definefont pop

}

#################################

if [ -z "$Ogonkify_path" ] ; then Ogonkify_path="/usr/share/ogonkify/" ; fi

if [ -z "$Ted_encoding" ] ; then Ted_encoding="latin2" ; fi

c=""

while [ -z "$c" ] ; do

read line

if [ "$line" != "%%BeginProlog" ] ; then echo $line

else

c="STOP"

cat "$Ogonkify_path""$Ted_encoding".enc

cat "$Ogonkify_path"compose.ps

cat "$Ogonkify_path"ogonki.enc

# Fonts

#  pcr - Courier
#  phv - Helvetica
#  ptm - Times Roman

cat "$Ogonkify_path"{pcr*.ps,phv*.ps,ptm*.ps}

fr Courier
fr Courier-Bold
fr Courier-BoldOblique
fr Courier-Oblique

fr Helvetica
fr Helvetica-Bold
fr Helvetica-BoldOblique
fr Helvetica-Oblique

fr Times-Roman
fr Times-Bold
fr Times-BoldItalic
fr Times-Italic

echo %%BeginProlog

sed s/ISOLatin1Encoding/ISOLatin2Encoding/g

fi

done

