home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / Xtex / TeXtoXfont.SCR < prev    next >
Text File  |  1991-02-20  |  3KB  |  143 lines

  1. #!/bin/sh
  2. #
  3. #   This script file makes a new X/TeX screen font, because one wasn't
  4. #   found.  Parameters are:
  5. #
  6. #   name dpi bdpi magnification destdir
  7. #
  8. #   `name' is the name of the font, such as `cmr10'.  `dpi' is
  9. #   the resolution the font is needed at.  `bdpi' is the base
  10. #   resolution, useful for figuring out the mode to make the font
  11. #   in.  `magnification' is a string to pass to MF as the
  12. #   magnification.  'destdir' is the directory in which to cache the new
  13. #   font.
  14. #
  15. #   Note that this file must execute Metafont, mftobdf, and then bdftosnf,
  16. #   and place the result in the correct location for X
  17. #   to find it subsequently.  
  18. #
  19. #   Of course, it needs to be set up for your site.
  20. #
  21. # TEMPDIR needs to be unique for each process because of the possibility
  22. # of simultaneous processes running this script.
  23. TEMPDIR=/tmp/bdf-snf.$$
  24. NAME=$1
  25. DPI=$2
  26. BDPI=$3
  27. MAG=$4
  28. MODE=$5
  29. DESTDIR=$6
  30. umask 0
  31.  
  32. #  Something like the following is useful at some sites.
  33. GFNAME=$NAME.$DPI'gf'
  34. BDFNAME=$NAME.$DPI.'bdf'
  35. SNFNAME=$NAME.$DPI.X_FONT_SUFFIX
  36.  
  37. COMPRESS=X_FONT_COMPRESS
  38.  
  39. # check if we're not running with MIT server after all
  40. if xdpyinfo|grep -s 'vendor string: *.*MIT.*'; then
  41.     DESTDIR=/usr/lib/X11/fonts/xtex
  42.     SNFNAME=$NAME.$DPI.'snf'
  43.     COMPRESS=1
  44.     MITSERVER=1
  45. fi
  46.  
  47. if test "$COMPRESS" = "1"
  48. then
  49.   SNFZNAME=${SNFNAME}'.Z'
  50. else
  51.   SNFZNAME=${SNFNAME}
  52. fi
  53.  
  54. # Clean up on normal or abnormal exit
  55. trap "cd /; rm -rf $TEMPDIR $DESTDIR/bdftmp.$$ $DESTDIR/snftmp.$$" 0 1 2 15
  56.  
  57. mkdir $TEMPDIR
  58. cd $TEMPDIR
  59.  
  60. if test -r $DESTDIR/$BDFNAME
  61. then
  62.    echo "$DESTDIR/$BDFNAME already exists!"
  63.    exit 0
  64. fi
  65.  
  66. if test -r $DESTDIR/$SNFNAME
  67. then
  68.    echo "$DESTDIR/$SNFNAME already exists!"
  69.    exit 0
  70. fi
  71.  
  72. if test -r $DESTDIR/$SNFZNAME
  73. then
  74.    echo "$DESTDIR/$SNZFNAME already exists!"
  75.    exit 0
  76. fi
  77.  
  78.  
  79. ##
  80. # First try mftobdf, maybe it exists...
  81. ##
  82.  
  83. echo "1st mftobdf -dpi" $DPI $NAME
  84. mftobdf -dpi $DPI $NAME
  85. if test ! -r $BDFNAME
  86. then 
  87.   echo mf "\mode:=$MODE; mag:=$MAG/1000; scrollmode; input $NAME </dev/null"
  88.   mf "\mode:=$MODE; mag:=$MAG/1000; scrollmode; input $NAME" </dev/null
  89.   if test ! -r $GFNAME
  90.   then
  91. #
  92. # My local metafont gives bogus names occasionally. Don't know why.
  93. #
  94.      echo "Unable to find $GFNAME in directory $cwd"
  95.      echo "Metafont failed for some reason on $GFNAME, but continuing anyway"
  96. #     exit 1
  97.   fi
  98.  
  99.   echo "mftobdf -dpi" $DPI $NAME
  100.   mftobdf -dpi $DPI $NAME
  101.   if test ! -r $BDFNAME
  102.   then 
  103.      echo "Mftobdf failed for some reason on $BDFNAME"
  104.      exit 1
  105.   fi
  106. fi
  107.  
  108. echo "$FONTCOMPILER"
  109. if [ $MITSERVER ]; then
  110.     bdftosnf $BDFNAME > $SNFNAME
  111. else
  112.     X_FONT_COMPILER
  113. fi
  114. if test ! -r $SNFNAME
  115. then
  116.    echo "Font compiler failed for some reason on $SNFNAME"
  117.    exit 1
  118. fi
  119.  
  120. # Install the BDF and SNF files carefully, since others may be doing the same
  121. # as us simultaneously.
  122.  
  123. #cp $BDFNAME $DESTDIR/bdftmp.$$
  124. cp $SNFNAME $DESTDIR/snftmp.$$
  125. cd $DESTDIR
  126. #mv bdftmp.$$ $BDFNAME
  127. mv snftmp.$$ $SNFNAME
  128.  
  129. if test "$COMPRESS" = "1"
  130. then
  131.   compress -f $SNFNAME
  132. fi
  133.  
  134. if [ $MITSERVER ]; then
  135.     mkfontdir $DESTDIR
  136. else
  137.     X_FONT_MAKE_DIR $DESTDIR
  138. fi
  139. X_FONT_PREPEND $DESTDIR
  140. X_FONT_RESET
  141.  
  142. exit 0
  143.