Go to the first, previous, next, last section, table of contents.

METAFONT

Getting METAFONT to do what you want

METAFONT allows you to create your own fonts, and most TeX users will never need to use it. METAFONT, unlike TeX, requires some customisation: each output device for which you will be generating fonts needs a mode associated with it. Modes are defined using the mode_def convention described on page 94 of The METAFONTbook (see TeX-related books). You will need a file, which conventionally called local.mf, containing all the mode_defs you will be using. If local.mf doesn't already exist, Karl Berry's collection of modes, available as fonts/modes/modes.mf, is a good starting point (it can be used as a `local.mf' without modification in a `big enough' implementation of METAFONT). Lists of settings for various output devices are also published periodically in TUGboat (see TUG). Now create a plain base file using inimf, plain.mf, and local.mf:

   % inimf
   This is METAFONT...
   **plain # you type plain
   (output)
   *input local # you type this
   (output)
   *dump # you type this
   Beginning to dump on file plain...
   (output)

This will create a base file named plain.base (or something similar; for example, it will be PLAIN.BAS on MS-DOS systems) which should be moved to the directory containing the base files on your system (note that some systems have two or more such directories, one for each `size' of METAFONT used).

Now you need to make sure METAFONT loads this new base when it starts up. If METAFONT loads the plain base by default on your system, then you're ready to go. Under Unix (using the default web2c distribution) this does indeed happen, but we could for instance define a command mf which executes virmf &plain loading the plain base file.

The usual way to create a font with plain METAFONT is to start it with the line

\mode=<mode name>; mag=<magnification>; input <font file name>

in response to the `**' prompt or on the METAFONT command line. (If <mode name> is unknown or omitted, the mode defaults to `proof' and METAFONT will produce an output file called .2602gf) The <magnification> is a floating point number or `magstep' (magsteps are defined in The METAFONTbook and The TeXbook). If mag=<magnification> is omitted, then the default is 1 (magstep 0). For example, to generate cmr10 at 12pt for an epson printer you would type

  mf \mode=epson; mag=magstep 1; input cmr10

Note that under Unix the \ and ; characters must usually be quoted or escaped, so this would typically look something like

  mf '\mode=epson; mag=magstep 1; input cmr10'

If you don't have inimf or need a special mode that isn't in the base, you can put its commands in a file (e.g., ln03.mf) and invoke it on the fly with the \smode command. For example, to create cmr10.300gf for an LN03 printer, using the file

   % This is ln03.mf as of 2/27/90
   % mode_def courtesy of John Sauter
   proofing:=0;
   fontmaking:=1;
   tracingtitles:=0;
   pixels_per_inch:=300;
   blacker:=0.65;
   fillin:=-0.1;
   o_correction:=.5;

(note the absence of the mode_def and enddef commands), you would type

   mf \smode="ln03"; input cmr10

This technique isn't one you should regularly use, but it may prove useful if you acquire a new printer and want to experiment with parameters, or for some other reason are regularly editing the parameters you're using. Once you've settled on an appropriate set of parameters, you should use them to rebuild the base file that you use.

A summary of the above written by Geoffrey Tobin, and tips about common pitfalls in using METAFONT, is available as info/metafont-for-beginners.tex

Which font files should be kept

METAFONT produces from its run three files, a metrics (TFM) file, a generic font (GF) file, and a log file; all of these files have the same base name as does the input (e.g., if the input file was cmr10.mf, the outputs will be cmr10.tfm, cmr10.nnngf and cmr10.log).

For TeX to use the font, you need a TFM file, so you need to keep that. However, you are likely to generate the same font at more than one magnification, and each time you do so you'll (incidentally) generate another TFM file; these files are all the same, so you only need to keep one of them.

To preview or to produce printed output, the DVI processor will need a font raster file; this is what the GF file provides. However, while there used (once upon a time) to be DVI processors that could use GF files, modern processors use packed raster (PK) files. Therefore, you need to generate a PK file from the GF file; the program gftopk does this for you, and once you've done that you may throw the GF file away.

The log file should never need to be used, unless there was some sort of problem in the METAFONT run, and need not be ordinarily kept.

Getting bitmaps from the archives

Most people these days start using TeX with a 300 dots-per-inch (dpi) laser printer, and Computer Modern bitmap fonts for this resolution are supplied with most TeX packages. There are also two such sets available on CTAN: fonts/cm/pk/pk300.zip (for write-black printer engines) and fonts/cm/pk/pk300w.zip (for write-white engines). However, some users want to send their work to high quality typesetting machines (typically with a resolution of 1270 dpi or greater); it is also becoming more common to use a 600 dpi laser printer. Why don't the archives or suppliers provide bitmap fonts at these sizes? There are two reasons:

  1. When a bitmap font is created with METAFONT, it needs to know the characteristics of the device; who knows what 600 or 1270 dpi device you have? (Of course, this objection applies equally well to 300 dpi printers.)
  2. Bitmap fonts get big at high resolutions. Who knows what fonts at what sizes you need?
It would be possible to provide some set of 1270 dpi bitmap fonts in the archives, but it would take a lot of space, and might not be right for you.

So what to do? You can build the fonts you need yourself with METAFONT: this isn't at all hard, and some drivers help you (dvips, and the emTeX drivers) construct the METAFONT commands. You might need to look at Karl Berry's collection of METAFONT modes (fonts/modes/modes.mf). Alternatively, if it is a PostScript device you have, consider using the fonts in Type 1 font format. You can buy all the Computer Modern fonts in outline form from Blue Sky Research, Kinch or Y&Y (commercial vendors for addresses), or you can use Basil Malyshev's public domain versions in fonts/cm/ps-type1 (the Paradissa collection is complete, but has largely been replaced by the better BaKoMa collection).


Go to the first, previous, next, last section, table of contents.