home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / text / tex / 10967 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  10.8 KB

  1. Path: sparky!uunet!munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!lugb!luxor.latrobe.edu.au!ecsgrt
  2. From: ecsgrt@luxor.latrobe.edu.au (Geoffrey Tobin)
  3. Newsgroups: comp.text.tex
  4. Subject: MetaFont for Beginners.  (Comments welcome.)
  5. Message-ID: <1992Sep6.070903.20725@lugb.latrobe.edu.au>
  6. Date: 6 Sep 92 07:09:03 GMT
  7. Sender: news@lugb.latrobe.edu.au (USENET News System)
  8. Organization: La Trobe University
  9. Lines: 323
  10.  
  11. METAFONT for Beginners.    Sun, 6 Sep 1992.    Geoffrey Tobin.
  12. -----------------------
  13.  
  14. It's a common experience to have initial (and medial and final :-)
  15. difficulty with running MetaFont, and not all "TeXperts" are as
  16. familiar with MF as they are with TeX.  So let's be of good cheer,
  17. and get down to work.
  18.  
  19.  
  20. 1.  Overview.
  21.  
  22.  
  23. 1a.  Base files and Modes.
  24.  
  25. Plain Metafont loads a so-called "base" file, "plain.base", when it
  26. starts.  The plain base defines all sorts of useful things.  (See
  27. Appendix B of "The METAFONTbook", if you have it around - maybe a
  28. library has it - I'm learning from a copy I've borrowed from the
  29. local university's library.)
  30.  
  31. The plain base is made from a Metafont file named "plain.mf" and,
  32. commonly, from some other file, often called "local.mf" or "modes.mf".
  33.  
  34. To each printer, the local or modes file associates a fontmaking
  35. "mode", which is a description of some refinements that must be made
  36. in order to produce good-looking output.  For example, how dark to
  37. make the characters.
  38.  
  39. Base files are "precompiled binaries" that MetaFont loads faster than
  40. it loads font source files like "plain.mf" and "local.mf".
  41.  
  42. If you want to make a base, you need a variant of the MetaFont program
  43. called "inimf".  (See The METAFONTbook, p 279.)  For example,
  44. "plain.base" can be made in unix by typing:
  45.  
  46.     inimf 'plain; input local; dump'
  47.  
  48. If using the emTeX version of MetaFont for a PC, type:
  49.  
  50.     mf/i plain; input local; dump
  51.  
  52.  
  53. 1b.  Proof Mode.
  54.  
  55. The first obstacle to beware of is that Metafont uses "proof" mode by
  56. default.  That means writing unmagnified font files with a resolution
  57. of 2601.72 dots per inch (dpi); that's 36 pixels per point.  (One
  58. point is 1/72.27 of an inch.)  Proof mode does NOT produce a TFM file.
  59.  
  60. What good is proof mode, and why is it the default?  Proofs are blown
  61. up copies of characters used by font designers to judge whether they
  62. like the results of their work.  Naturally, proofs come first, and
  63. normal sized character production later - if you're a font designer.
  64.  
  65. So there are two clues that proof mode is on:  font files with
  66. extensions like ".2602gf" (or on DOS, ".260"), and the "failure" to
  67. produce any TFM file.
  68.  
  69.  
  70. 1c.  Localfont Mode.
  71.  
  72. When using a stable font, we don't want proof mode, we want our local
  73. printer's mode.  Usually, Metafont is installed with a "localfont"
  74. assigned in the local/modes file.  On our department's Sun Network, we
  75. have assigned "localfont:=CanonCX".  We use Karl Berry's "modes.mf",
  76. which contains modes for many, many printers.  We chose the CanonCX
  77. mode because "modes.mf" recommends it for Apple Laserwriters and HP
  78. Laserjets, which we use.
  79.  
  80. On some installations of Metafont, if the name of a Metafont source
  81. file is typed on the command line, then "localfont" will be used:
  82.  
  83.     mf myfont10
  84.  
  85. This processes file "myfont.mf", and should produce a GF font file,
  86. "myfont10.300gf" and a TFM file, "myfont10.tfm".
  87.  
  88. But other installations need the local font specified.  On unix:
  89.  
  90.     mf '\mode=localfont; input pics'
  91.  
  92. On MS-DOS, type it without the apostrophes:
  93.  
  94.     mf \mode=localfont; input pics
  95.  
  96. These command lines are a bit long, very often used, and rather
  97. intolerant of mistakes (see section 2c below), so you might type the
  98. repetitive parts into a unix shell script or a DOS batch file, as
  99. appropriate.
  100.  
  101.  
  102. 1d.  Font Naming.
  103.  
  104. By the way, if you plan to modify a CM font, you must give it a new
  105. name.  This is an honest practice, and will avoid later confusion.
  106.  
  107.  
  108. 1e.  Using a New Font in TeX.
  109.  
  110. To use a new font in a TeX document, select it specifically.  Example:
  111. in a TeX macro file, or in a LaTeX style file, to define "\mine" as
  112. a font-selection command for "myfont.tfm", say:
  113.  
  114.     \font\mine=myfont10
  115.  
  116. Then to typeset "Mary had a little lamb," in the "myfont10" font, and
  117. then to revert to the previous font, type
  118.  
  119.     {\mine Mary had a little lamb,}
  120.  
  121.  
  122. 1f.  Magnification (and Resolution).
  123.  
  124. Now suppose that you want myfont10 to be magnified, say to magstep 1
  125. (magnified by 1.2), for a "jumbo" printer.  Assuming that the
  126. local/modes file has a mode for the jumbo printer, you need then to
  127. run Metafont as follows.  On DOS:
  128.  
  129.     mf \mode=jumbo; mag=magstep(1); input myfont10
  130.  
  131. to produce "myfile10.tfm" (again!) and a GF font, "myfile10.360".
  132.  
  133. On unix, the csh and sh interpret semicolons, backslashes and
  134. parentheses specially, so these will have to be 'quoted'.  Either
  135.  
  136.     mf '\mode=jumbo; mag=magstep(1);' input myfont10
  137. or
  138.     mf '\mode=jumbo; mag=magstep(1); input myfont10'
  139.  
  140. will do.  This will produce "myfile10.tfm" and the GF font
  141. "myfile10.360gf".
  142.  
  143. The "360" is "300 * 1.2", indicating the magnification.  A 360 dpi
  144. font can be used either as a magnification 1.2 font on a 300 dpi
  145. printer or as a normal sized font on a 360 dpi printer.
  146.  
  147.  
  148. 1g.  GFtoPK.
  149.  
  150. TeX uses only the TFM file, which Metafont will produce if it's not in
  151. proofing mode.  Most DVI drivers read the PK font format, but Metafont
  152. makes a GF (Generic Font) file.  So we need also to apply the "gftopk"
  153. utility:
  154.  
  155.     gftopk myfile10.300gf
  156.  
  157. to produce the wanted "myfile.300pk" (or, on DOS, "myfile.pk") PK
  158. font.
  159.  
  160.  
  161. 1h.  Storing the Fonts.
  162.  
  163. Now we have the fonts, where do we store them?  TeX and Metafont are
  164. compiled with default locations written in.  These can be overridden
  165. by certain environment variables.  The names of these variables differ
  166. between systems, but on unix they might be "TEXTFMS" and "TEXFONTS",
  167. for example.  You can find out what environment variables you now
  168. have, by typing "set".  (This works in both unix and DOS.)
  169.  
  170. If you want TeX and Metafont to find files in the current directory,
  171. you must have "." in the paths they use, either compiled into TeX and
  172. Metafont, or in the environment variables that they read.  (This is
  173. true for both unix and DOS.)
  174.  
  175. On the other hand, you may be content with your new font, and you may
  176. have write access to the place where most of the fonts are stored.  In
  177. that case, copy your font to there.  There will be a place for the TFM
  178. files, and another for the PK files.  It's up to you or your local
  179. system administrator(s) to know where these directories are, because
  180. their names are very locale dependent.
  181.  
  182.  
  183. 2.  WHAT WENT WRONG?
  184.  
  185. The complexity of wrong things far exceeds that of things intended.
  186.  
  187. Small typing errors are so common, and yet undocumented (why are
  188. common mistakes not documented?), that I thought I'd list several that
  189. have tripped me up on innumerable occasions.  After all, why reinvent
  190. the car crash?
  191.  
  192.  
  193. 2a.  Base Loading.
  194.  
  195. MetaFont will load the "plain" (or in Web2c Unix TeX, "mf.base"), if
  196. you type:
  197.  
  198.     mf fred
  199.  
  200. But if you omit the argument,
  201.  
  202.     mf
  203.  
  204. then _no_ base is preloaded, so "mf" is then equivalent to "virmf",
  205. which only understands MetaFont's primitives, which are the commands
  206. preceded by an asterisk in the Index to The METAFONTbook.
  207.  
  208. Then mf displays a "**" prompt, to which you may have to type
  209. everything in fine detail:
  210.  
  211.     ** &plain \mode=localfont; mag=magstep(1); input fred
  212.  
  213. In unix, this has the advantage that those pesky apostrophes are not
  214. needed.  The "&" tells MetaFont that "plain" refers to "plain.base",
  215. not to "plain.mf".
  216.  
  217.  
  218. 2b.  Big fonts, but unwanted.
  219.  
  220. Recently, I found myself accidentally producing fonts with extensions
  221. like "3122gf".  How?
  222.  
  223. MF will take _anything_ as an excuse to revert to PROOFING MODE.  The
  224. "3122" is a magstep 1 proofing mode.  It's
  225.  
  226.     (1.2)^1 * 2601.72  = 3122.16  dots per inch.
  227.  
  228. My intention was for MetaFont on a PC to use an HP Laserjet mode in
  229. place of proofing mode.  However, MetaFont's command line resembles
  230. the law:  every stroke of the pen is significant.  What I had
  231. forgotten was that on my setup, "localfont" must be explicitly
  232. requested.
  233.  
  234. EmTeX's MetaFont, with plain.mf, defaults to proofing mode.  However,
  235. I usually want a local printer's fontmaking mode.  So I need to say:
  236.  
  237.     mf '\mode=localfont; input pics'
  238.  
  239.  
  240. 2c.  Consequences of Some Typing Errors on MetaFont's command line.
  241.  
  242. Consider a source file "pics.mf" that contains "mag=1200/1000;", so it
  243. is automatically scaled by 1.2 (ie, by magstep 1).  If the target
  244. printer has 300 dpi, then a 360 dpi GF font is wanted.
  245.  
  246. Here is the gist of what happens for various typing errors, when using
  247. emTeX's "mf186" on a 286 PC to process "pics.mf".
  248.  
  249. 1)  mf186  ->  mf behaves as virmf:
  250.  
  251.     **
  252.  
  253. We can type the contents of the command line here.  In fact, MetaFont
  254. usually echoes its interpretation of the command line to its own **
  255. prompt, as the .log ("transcript") file shows.
  256.  
  257. 2)  mf186 pics  ->  proofing mode:
  258.  
  259.     ! Value is too large (5184)
  260.  
  261. No tfm is produced, and the gf file has resolution 3122 dpi.  (3121.72
  262. dpi, to be precise.)
  263.  
  264. 3)  mf186 mode=localfont; input pics  ->  misinterpretation:
  265.  
  266.     ! I can't find file `modes=localfont.mf'.
  267.  
  268. So, "modes" needs that backslash, otherwise mf thinks it's the start
  269. of a source font's filename.
  270.  
  271. 4)  mf186 \mode=localfont input pics  ->  weird effect:
  272.  
  273.     >> unknown string mode_name1.2
  274.     ! Not a string
  275.     <to be read again>
  276.                       ;
  277.     mode_setup-> ...ode)else:mode_name[mode]fi;
  278.     l.6 mode_setup
  279.                   ;
  280.  
  281. Wow!  What a difference a semicolon can make!
  282.  
  283. 5)  mf186 \mode=localfont pics  ->  almost nothing happens:
  284.  
  285.     ** \mode=localfont pics
  286.  
  287.     *
  288.  
  289. There's the echo I mentioned.  From the lack of activity, pics
  290. evidently needs to be "input".
  291.  
  292. 6)  mf186 \mode=localfont; pics  ->
  293.  
  294.     Same as 5.
  295.  
  296. So, yes, when the mode is specified, we need "input" before "pics".
  297.  
  298. 7)  mf186 &plain \mode=localfont; input pics  ->
  299.  
  300.     Works.
  301.  
  302. Just as without the "&plain", it writes a GF file, "pics.360gf", which
  303. is correct.  (DOS truncates the name to "pics.360".)  So, redundancy
  304. seems okay.  Does it waste time, though?
  305.  
  306.  
  307. 2d.  Finding the Fonts.
  308.  
  309. Finding the fonts (*.mf, *.tfm, *.gf, *.pk) trips up TeX, MF, GFtoPK
  310. and the output drivers continually.  "pics.tfm" needs to be put where
  311. TeX will look for TFMs, so I needed to ensure that "." was in the
  312. appropriate path environment variable.  Similarly for the MF, GF and
  313. PK font files.
  314.  
  315. Environment variables can be tricky.  For example, emTeX's fontmaking
  316. automation program "mfjob" cannot make fonts in the current directory
  317. unless both "." and ".." are added to MFINPUT.  This was not
  318. documented.
  319.  
  320.  
  321. 3.  Conclusion.
  322.  
  323. MetaFont, like TeX and many another "portable" program of any
  324. complexity, justify the warning:  "Watch out for the first step."
  325.  
  326. It's my hope that this document like this one may help to prevent
  327. domestic accidents involving MetaFont, and so contribute to making the
  328. task of using and designing meta-fonts an enjoyable one.  My brief
  329. experience with MetaFont suggests that it can be so.
  330.  
  331.  
  332. All the Best!
  333. Geoffrey Tobin
  334.