#!/bin/sh
#
#   This script file makes a new .mf file because one wasn't
#   found.  Usage:
#
#   MakeTeXMF name
#
#   'Name' is the name of the file, such as 'dcr10.mf'
#
#   Heavily modified for the debian distribution of TeX by:
#     Nils Rennebarth <nils@hertha.exp-math.uni-essen.de>
#
# This script must echo the name of the generated .mf file (and nothing
# else) to standard output.
#
# Currently it just makes an input file to generate a dc-font at
# a specified size.
NAME=$1

# Where to put the new file
DESTDIR=/var/spool/texmf/fonts/source

# Have we been spuriously called? No harm done, if so.
if test -r $DESTDIR/$NAME; then
  echo "$DESTDIR/$NAME already exists!" 1>&2
  echo $DESTDIR/$NAME
  exit 0
fi
 
case $NAME in
  dc*.mf)  if expr $NAME : '[^0-9]*[0-9]*p[0-9]*\.mf' >/dev/null; then
              SIZE=`echo $NAME | sed -e 's/[^0-9]*\([0-9]*\)p\([0-9]*\)\.mf/\1.\2/'`
           elif expr $NAME : '[^0-9]*[0-9][0-9]*\.mf' >/dev/null; then
              SIZE=`echo $NAME | sed -e 's/[^0-9]*\([0-9]*\)\.mf/\1/'`
           else
              echo "$NAME contains no recognizable size!" 1>&2
              exit 1
        fi
	BASE=`echo $NAME | sed -e 's/\([^0-9]*\)[0-9]*.*/\1/'`
	echo "% This is $NAME, automatically generated by MakeTeXMF" > $DESTDIR/$NAME
	echo "if unknown dxbase: input dxbase fi;" >> $DESTDIR/$NAME
        echo "gensize:=$SIZE; generate $BASE;"    >> $DESTDIR/$NAME
        echo $DESTDIR/$NAME
        exit 0 ;;
   *)   echo "I don't know how to generate $NAME!" 1>&2
        exit 1 ;;
esac

