home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / bbs / programs / amiga / metafont.lha / MF / REXX / MakeTeXFont.rexx < prev    next >
OS/2 REXX Batch file  |  1994-06-01  |  14KB  |  501 lines

  1. /*
  2. ** AREXX $VER: MakeTeXFont 1.05
  3. **
  4. ** Send new features and bug reports to 
  5. **
  6. ** Martin Bokaemper
  7. ** Reuthstr. 12
  8. ** 91099 Poxdorf
  9. ** Germany
  10. **
  11. ** Email: mnbokaem@cip.e-technik.uni-erlangen.de (Internet)
  12. **        mab@ame.zer (Zerberus)
  13. **
  14. ** Ulrich Wisser
  15. ** Heerstr. 125
  16. ** 53111 Bonn
  17. **
  18. ** HISTORY:
  19. **
  20. ** 0.80: My 'works-fine-for-me' version modified by Georg Hessmann 13.04.91
  21. **       + Variables for all directories and filenames
  22. **       + ^C and ^D detection 
  23. **       + support for a 'modefile' containing site-specific information
  24. **       + searches for standard magsteps 
  25. **       + support for different format-files
  26. **
  27. ** 0.81: + take new Parameters 'drivertype' and 'pkfilename' 
  28. **       Georg Hessmann 17.04.91
  29. **
  30. ** 0.82: + History 
  31. **       + a lot of small improvements and bugfixes
  32. **       + looking for PK-directory for each device 
  33. **       + checking if the font already exists
  34. **       Martin Bokaemper 21.04.91
  35. **
  36. ** 0.84: + add new parameter 'pkdir' (new since driver version V1.10)
  37. **       Georg Hessmann 09.06.91
  38. **
  39. ** 0.85: + fixed a pkdir/pkfilename mixing bug
  40. **       + slight modifications, now works with old driver versions
  41. **       + changed exit codes
  42. **       + always calls uses plain.base (absolutely no gain in using cmbase)
  43. **       J\"org H\"ohle 24.6.91, 01.08.91
  44. **
  45. ** 0.86: + fixed makedir(pkname) bug
  46. **       J\"org H\"ohle 06.08.91
  47. **
  48. ** 0.90: + add makedir(pkdir)
  49. **       + delete localfont entry in 'modes' file
  50. **       Georg Hessmann 28.08.91
  51. **
  52. ** 1.00: + only one logfile entry per call
  53. **       + ERROR: now reports interpreted sourceline
  54. **       + fonts can be copied to mf:<mode> for font-caching
  55. **       + magstep calculation improved.  now same as in ShowDVI/DVIPrint
  56. **       + MISSING: \scrollmode correctly inserted
  57. **       Ulrich Wisser 25.08.92
  58. **
  59. ** 1.01: + bumped revision number because of partial integration of
  60. **       + versions 0.91 and 1.0 and some personal modifications.
  61. **       Andreas Scherer 31.10.93
  62. **
  63. ** 1.02: + negative magnification factors and dpi values installed.
  64. **       Andreas Scherer 18.01.94
  65. **
  66. ** 1.03: + support for dvips 5.523 resulted in a modified analysis of
  67. **       + the `modes' file.  PKDIR now *always* comes as an argument
  68. **       + of this script (as implemented by Ulrich Wisser).
  69. **       Andreas Scherer 19.01.94
  70. **
  71. ** 1.04: + METAFONT 2.71 returns 0, 5, 10, and 20, so a different ERROR
  72. **       + handling is necessary (and possible).
  73. **       Andreas Scherer 2.5.94
  74. **
  75. ** 1.05: + add MyGetEnv at the end of the file
  76. **       + add ENV:MFLOGDIR to change the logging directory
  77. **         Change default to T:MFlog.
  78. **       + add ENV:MFTMPDIR to change the working directory
  79. **         The directory, where virmf will be started. MF: isn't
  80. **         a good choice, because this can be on a CD-ROM (ro).
  81. **         Change default woring directory from MF: to T:
  82. **       + use the PKDIR from the argument, not from the TeX:config/modes
  83. **         file. This dir variable is renamed to MODEPKDIR but is noop.
  84. **       Georg Heßmann 13.05.94
  85. */
  86.  
  87. Signal On BREAK_C
  88. Signal On BREAK_D
  89.  
  90. /*
  91. ** Files / Directories
  92. */
  93.  
  94. LOGDIR = Word(MyGetEnv("MFLOGDIR"),1)    /* not to MF: .. it could be on CD-ROM */
  95. If "" = LOGDIR Then
  96.   LOGDIR       = "T:MFlog"              /* directory of the logfiles           */
  97.                                         /* without trailing slash!             */
  98.  
  99. WORKDIR = Word(MyGetEnv("MFTMPDIR"),1)    /* working directory                   */
  100. If "" = WORKDIR Then            /* not MF: .. it could be on CD-ROM    */
  101.   WORKDIR       = "T:"
  102.  
  103.  
  104. LOGNAME      = LOGDIR"/MakeTeXFont.log" /* logfile                      */
  105. MODEFILENAME = "MF:config/modes"        /* description of the modes     */
  106. TEXTFM       = "TeX:fonts/"             /* TeX tfm-files directory      */
  107. VIRMF        = "MF:bin/VirMF"
  108. GFTOPK       = "MF:bin/GFtoPK"
  109. FONTFILENAME = "TeX:config/fontvols"
  110.  
  111. /*
  112. ** Bases. Put in others, if you like.
  113. */
  114. NORMALBASE = "plain"
  115. DXBASE     = "dxbase"            /* base for dc-fonts        */
  116. CMBASE     = "cmbase"            /* base for cm-fonts        */
  117.  
  118. /*
  119. ** Arguments
  120. */
  121. Parse Arg FNTNAME DPI HBASEDPI VBASEDPI DRIVERTYPE PKFILENAME PKDIR .
  122.  
  123. Say "Making font "FNTNAME" at "DPI" dpi and base ("HBASEDPI","VBASEDPI")"
  124.  
  125. If ~Show('Libraries','rexxsupport.library') Then Do
  126.   If ~AddLib('rexxsupport.library',0,-30) Then Do
  127.      Say "No RexxSupport.library ... No Metafont!"
  128.      Exit 5
  129.   End
  130. End
  131.  
  132. DUMMY = Time("Reset")
  133.  
  134. If ~Exists(LOGDIR) Then Do
  135.   Address COMMAND 'MakeDir 'LOGDIR
  136.   If ~Exists(LOGDIR) Then Do
  137.     Call Log("Could not create logdir="LOGDIR)
  138.     Exit 5
  139.   End
  140.   Say "logfile-directory ("LOGDIR"/) did not exist. It was created."
  141. End
  142.  
  143. If ~Exists(LOGNAME) Then Do
  144.   Address COMMAND 'echo >'||LOGNAME
  145.   If ~Exists(LOGNAME) Then Do
  146.     Call Log("Could not create logfile="LOGDIR"/"LOGNAME)
  147.     Exit 5
  148.   End
  149.   Say "logfile did not exist. It was created."
  150. End
  151.  
  152. FNTNAME    = Translate(FNTNAME,XRange('a','z'),XRange('A','Z')) /* lower */
  153. DPI        = Strip(DPI)
  154. HBASEDPI   = Strip(HBASEDPI)
  155. VBASEDPI   = Strip(VBASEDPI)
  156. DRIVERTYPE = Translate(DRIVERTYPE,XRange('a','z'),XRange('A','Z')) /* lower */
  157. PKFILENAME = Translate(PKFILENAME,XRange('a','z'),XRange('A','Z')) /* lower */
  158. PKDIR      = Translate(PKDIR,XRange('a','z'),XRange('A','Z')) /* lower */
  159.  
  160. /*
  161. ** Changed 19.07.92 by Ulrich Wisser
  162. ** Needed to calculate correct DPI sizes
  163. */
  164. Numeric DIGITS 12
  165.  
  166. /*
  167. ** What magstep should the font have?
  168. */
  169. MAG = DPI/HBASEDPI
  170.  
  171. /*
  172. ** MAGMULT.NUM.I set to correct values!
  173. ** 21.07.92 by Ulrich Wisser
  174. ** Needed to calculate correct DPI values.
  175. **
  176. ** Some more values for magstep(-0.5)..magstep(-4) included.
  177. ** 18.01.94 by Andreas Scherer.
  178. */
  179. MAGMULT.0      = 23            /* number of saved MagSteps */
  180.  
  181. MAGMULT.NUM.1  = 1.0           /* MagStep(0)    */
  182. MAGMULT.STR.1  = "0"
  183. MAGMULT.NUM.2  = 1.09544511501 /* MagStep(0.5)  */
  184. MAGMULT.STR.2  = "0.5"
  185. MAGMULT.NUM.3  = 1.2           /* MagStep(1)    */
  186. MAGMULT.STR.3  = "1"
  187. MAGMULT.NUM.4  = 1.31453413801 /* MagStep(1.5)  */
  188. MAGMULT.STR.4  = "1.5"
  189. MAGMULT.NUM.5  = 1.44          /* MagStep(2)    */
  190. MAGMULT.STR.5  = "2"
  191. MAGMULT.NUM.6  = 1.57744096561 /* MagStep(2.5)  */
  192. MAGMULT.STR.6  = "2.5"
  193. MAGMULT.NUM.7  = 1.728         /* MagStep(3)    */
  194. MAGMULT.STR.7  = "3"
  195. MAGMULT.NUM.8  = 2.0736        /* MagStep(4)    */
  196. MAGMULT.STR.8  = "4"
  197. MAGMULT.NUM.9  = 2.48832       /* MagStep(5)    */
  198. MAGMULT.STR.9  = "5"
  199. MAGMULT.NUM.10 = 2.985984      /* MagStep(6)    */
  200. MAGMULT.STR.10 = "6"
  201. MAGMULT.NUM.11 = 3.5831808     /* MagStep(7)    */
  202. MAGMULT.STR.11 = "7"
  203. MAGMULT.NUM.12 = 4.29981696    /* MagStep(8)    */
  204. MAGMULT.STR.12 = "8"
  205. MAGMULT.NUM.13 = 5.159780352   /* MagStep(9)    */
  206. MAGMULT.STR.13 = "9"
  207. MAGMULT.NUM.14 = 0.91287092917 /* magstep(-0.5) */
  208. MAGMULT.STR.14 = "-0.5"
  209. MAGMULT.NUM.15 = 0.83333333333 /* magstep(-1)   */
  210. MAGMULT.STR.15 = "-1"
  211. MAGMULT.NUM.16 = 0.76072577431 /* magstep(-1.5) */
  212. MAGMULT.STR.16 = "-1.5"
  213. MAGMULT.NUM.17 = 0.69444444444 /* magstep(-2)   */
  214. MAGMULT.STR.17 = "-2"
  215. MAGMULT.NUM.18 = 0.63393814526 /* magstep(-2.5) */
  216. MAGMULT.STR.18 = "-2.5"
  217. MAGMULT.NUM.19 = 0.5787037037  /* magstep(-3)   */
  218. MAGMULT.STR.19 = "-3"
  219. MAGMULT.NUM.20 = 0.52828178771 /* magstep(-3.5) */
  220. MAGMULT.STR.20 = "-3.5"
  221. MAGMULT.NUM.21 = 0.48225308641 /* magstep(-4)   */
  222. MAGMULT.STR.21 = "-4"
  223. MAGMULT.NUM.22 = 0.44023482309 /* magstep(-4.5) */
  224. MAGMULT.STR.22 = "-4.5"
  225. MAGMULT.NUM.23 = 0.40187757201 /* magstep(-5)   */
  226. MAGMULT.STR.23 = "-5"
  227.  
  228. MAGMULT.STR.DEFAULT = "???"
  229. MAGSTR              = MAGMULT.STR.DEFAULT
  230.  
  231. /*
  232. ** Changed 21.07.92 by Ulrich Wisser
  233. ** DPI rounding caused troubles sometimes, e.g., for
  234. ** magstep2 with ShowDVI 44x44
  235. */
  236. Do I = 1 To MAGMULT.0
  237.   MAGDPI = (MAGMULT.NUM.I * HBASEDPI) + 0.5
  238.   If Pos('.',MAGDPI) > 0 Then
  239.     MAGDPI = Left(MAGDPI,Pos('.',MAGDPI)-1)
  240.   If MAGDPI = DPI Then Do
  241.     MAG    = MAGMULT.NUM.I
  242.     MAGSTR = MAGMULT.STR.I
  243.     Leave I
  244.   End
  245. End
  246.  
  247. If MAGSTR ~= MAGMULT.STR.DEFAULT Then MAG = 'magstep('magstr')'
  248.  
  249. /*
  250. ** Modes ... search the correct mode in the file MODEFILENAME (see above).
  251. */
  252. If ~Open('MODEFILE',MODEFILENAME,'READ') Then Do
  253.   Call Log("Can't find file "MODEFILENAME"!")
  254.   Exit 5
  255. End
  256.  
  257. Do Until(XRES==HBASEDPI & YRES==VBASEDPI) | EOF('MODEFILE')
  258.   LINE = ReadLn('MODEFILE')
  259.   LINE = Strip(T