#! /bin/sh

# unpackfont: Unpack one or more of the font collections.  You specify
# the collections to unpack with command-line arguments, like this:

#	unpackfont European Asian

# unpackfont unpacks the fonts into subdirectories of the current
# directory.  If this directory is different from the `intlfonts'
# directory which contains the font collections, then run this script
# using its location in that directory, as in (for example)

#       ../intlfonts/unpackfont European Asian

# The arguments to this script should be the names of the font
# groups to be unpacked.  It is optional whether to include
# the .tar suffix in the argument.

# This script does NOT take care of telling the X server to use the
# fonts you have just unpacked!  That is because we are not sure how
# to do that portably and make the effect permanent.  This probably
# has to be done by editing certain files in your X installation.

# If you can modify this to script do that reliably,
# that would be a very useful improvement.


startdir=`pwd`

for arg in $*; do
  collection=`basename $arg .tar`
  sourcedir=`dirname $0`
  tarfile=$sourcedir/$collection.tar

  cd $startdir

  # Untar font
  tar xf $tarfile

  # Unpack
  cd $collection
  for i in *.gz
  do gunzip $i
  done

  # Convert to the pcf format from the bitmap format
  for i in *.bdf
    do 
      b=`basename $i .bdf`
      bdftopcf $i > $b.pcf
    done

  rm -f *.bdf
  mkfontdir   # Create fonts.dir

# You can tell one X server session to use these fonts with these commands
#  xset +fp . 
#      some systems need xset +fp `pwd`
#  xset fp rehash
# but this works only if the X server can read the files in this directory.
# It won't work with just any X server anywhere on the network.

done
