MF

Section: User Commands (1)
Updated: 2/10/89
Index Return to Main Contents
 

NAME

cmmf, inimf, virmf - METAFONT, a language for font design  

SYNOPSIS

cmmf [ first line ]

inimf [ first line ]

virmf [ first line ]

 

DESCRIPTION

METAFONT reads the program in the specified files and outputs font rasters (in gf format) and font metrics (tfm files). METAFONT capabilities and language are described in The METAFONTbook by Donald E. Knuth, published by Addison-Wesley. There is also an older manual, TeX and METAFONT, which describes the older version of METAFONT, now called METAFONT-in-SAIL, but this description is now obsolete.

Like TeX , METAFONT is normally used with a large body of precompiled macros, and font generation in particular requires the support of several macro files. The basic programs as compiled are called inimf and virmf, and are distinguished by the fact that inimf can be used to precompile macros into a ``*.base'' file, which is used by virmf. Virmf can read a precompiled ``*.base'' file, but it cannot create one. It is the version of METAFONT which lies behind most font production systems.

By convention, the program used to compile the Computer Modern fonts is called cmmf, which is essentially an alias for virmf with the Computer Modern support macros loaded in as a ``base'' file. In the following discussion, the name METAFONT will be used whenever the behavior of all varieties of the program is the same. Otherwise, it should be assumed that the behavior described is unique to the program named. Any arguments given on the command line to one of the METAFONT programs, such as cmmf, are passed to them as the first input line. As described in The METAFONTbook, that line should begin with a file name or a \controlsequence. The normal usage is to say

cmmf  ' \mode=<printengine>; [\mag=magstep(n);] ' input  font

to start processing font.mf. The single quotes are the best way of keeping the shell from misinterpreting the semicolons and from removing the \ characters, which are needed here to keep METAFONT from thinking that you want to produce a font called ``mode'' or ``mag''. Other \controlsequences, such as \batchmode (for silent operation) can also appear. The name ``font'' will be the ``jobname'', and is used in forming output file names. If METAFONT doesn't get a file name in the first line, the jobname is ``mfput''. The default `.mf' extension can be overridden by specifying an extension explicitly. There is no way to read a METAFONT input file with no filename extension.

A log of error messages goes into font.log where font is the jobname. The output files are font.tfm and font.<number>gf where <number> depends on the resolution and magnification of the font. The ``\mode'' in this example is shown generically as <printengine>, a symbolic term for which the name of an actual printengine or the name ``localfont'' (see below) must be substituted. If the ``\mode'' is not specified or is not valid for your site, METAFONT will default to ``proof'' mode which produces large character images for use in font design and refinement. Proof mode can immediately be recognized by the appearance of the suffix .2602gf after the jobname. Examples of proof mode output can be found in The Computer Modern Fonts, (Volume E of Computers and Typesetting ), by Donald Knuth. The system of magsteps is identical to the system used by TeX , with values normally in the range 0.5, 1.0, 2.0, 3.0, 4.0 and 5.0. A listing of gf numbers for 118-dpi, 240-dpi and 300-dpi fonts is shown below.

MAGSTEP118 dpi240 dpi300 dpi
mag=magstep(0)118240300
mag=magstep(0.5)129263329
mag=magstep(1)142288360
mag=magstep(2)170346432
mag=magstep(3)204415518
mag=magstep(4)245498622
mag=magstep(5)294597746

Magnification can also be specified not as a magstep but as an arbitrary value, such as 1.315, to create special character sizes.

Before font production can begin, it is necessary to set up the appropriate `base' files. The minimum set of components for font production for a given print-engine is the `plain.mf' macro file and the local `mode_def' file. The macros in `plain.mf' can be studied in an appendix to the METAFONTbook; they were developed by Donald Knuth, and this file should never be altered except when it is officially upgraded. Mode_def specifications are tailored to each different print-engine. There is a regular discussion of them in the journal of the TeX Users Group, TUGboat, and models can be found in the files `waits.mf' and `U_Wash.mf' which come in the standard distribution of TeX for Unix systems. A good `mode_def' file (which we will here call `<SITE>-modes.mf') should also supply other features in the `gf' and `tfm' output from cmmf. With only `plain.mf' and `<SITE>-modes.mf' loaded it is possible to create fonts of simple characters, such as those used for the METAFONT logo, and those used for the LaTeX line and circle fonts, but the production of Computer Modern fonts requires that `cmbase.mf', be loaded as well. The best way to do this is to create a small ``driver'' file with the lines
input plain
input <SITE>-modes
input cmbase and name this file `cmplain.mf'. Then run inimf with the arguments ``cmplain dump'', and you will finish up with a file named cmplain.base. The `base' file is used by virmf. It needs to be given a base file name as the first thing it reads. A base file name is preceded by an &, which needs to be quoted or escaped with \ if given on the command line. One could set up a cshell alias with

           alias cmmf "virmf \&cmplain"
to allow regular use of cmmf, but a preferable way is to set up an executable script with the name cmmf which can ensure that `cmplain.base' is loaded whenever cmmf is called. In either case, the message on the screen will tell you that there is ``no format preloaded'', which is of course perfectly true; the format loading is achieved by the ``\&cmplain'' part of the alias. The log file will tell you that cmplain was loaded, and that too is true, because the log file is written after the loading of ``cmplain.base'' (or whatever base file you have specified). This mildly confusing conflict in messages can be avoided if you choose to preload ``cmmf'' using the ``undump'' program. Preloading gives you a fast startup, but only at the price of lost flexibility and of large storage requirements for the preloaded version. WARNING. Do not use a base with cmbase.mf preloaded when you make up the line and circle fonts for LaTeX. It causes subtle errors in the compiled font and makes the production of clean drawings in LaTeX picture mode virtually impossible.

There are some environment variables that can be used to set up directory paths to search when METAFONT opens a file for input. For example, the csh command
setenv MFINPUTS .:/usr/me/mylib:/usr/lib/mf/inputs or the sh command sequence
MFINPUTS=.:/usr/me/mylib:/usr/lib/mf/inputs
export MFINPUTS
would cause all invocations of METAFONT and its derivatives to look for \input files first in the current directory, then in a hypothetical user's ``mylib'', and finally in the system library. Normally, the user will place the command sequence which sets up the MFINPUTS environment variable in the .cshrc or .profile file.

The e response to METAFONT's error-recovery mode invokes the GNU emacs editor at the erroneous line of the source file. There is an environment variable, MFEDITOR, that can be used to specify the editor. It should contain a string with "%s" indicating where the filename goes and "%d" indicating where the decimal linenumber (if any) goes. For example, an MFEDITOR string for the "vi" editor can be set by:


   
     setenv MFEDITOR "/usr/ucb/vi +%d %s"

(replacing the path name for the editor as appropriate on your system). The Environment section below lists the relevant environment variables, and their defaults.

A convenient file in the library is null.mf, containing nothing. When mf can't find the file it thinks you want to input, it keeps asking you for another file name; responding `null' gets you out of the loop if you don't want to input anything.

 

EXAMPLES

Most sites need at least two families of font resolution: one for printing and the other for previewing. If both write-white and write-black printers are used at the same site it may even be necessary to have two sets of fonts at the same resolution. When preloaded with a `mode-def' file such as U_Wash.mf, METAFONT has several modes, each associated with a given print engine or display device. In regular use the mode `localfont' is made equivalent to the mode for the print-engine most in use. There are also two styles of proof mode for character designers.

Generates full-page font proofs using gray-pixel fonts
Generates full-page font proofs using black-pixel fonts
Generates font at resolution suitable for printing

Once a METAFONT source is written, the following steps may be used to generate a GF file for proofing, TFM file for the width table, and raster font files for printing and previewing at each desired resolution.

       STEP 1. Compile font

Input: cmmf myfont

Output: myfont.2602gf, myfont.log
        STEP 2. Generate DVI-file

Input: gftodvi myfont.2602gf

Output: myfont.dvi, myfont.log
        STEP 3. Produce printable output (e. g. from a PostScript printer)

Input: dvi2ps myfont | lpr

Note: You need special black, gray and slant fonts for this.
        STEP 4. Generate generic format rastered font:

Input: cmmf ' \mode=localfont; \mag=magstep(1.0); ' input myfont

Output: myfont.360gf, myfont.tfm, myfont.log
Steps 1 through 3 are necessarily only if you are working on a new design. If all you need is a specific size and resolution of a well-known font, then only step 4 is needed.
 

ENVIRONMENT

The defaults for all environments are set at the time of compilation, by reference to a file called site.h. The values given below are preset in this file, and may be different at some sites.

MFINPUTS
Search path for \input and \openin files. It should be colon-separated, and start with ``.''. The entire path must be no longer than 700 characters long. Default: .:/usr/lib/mf/inputs
MFBASES
Search path for base files. Default: .:/usr/lib/mf/bases
MFPOOL
Search path for METAFONT strings. Default: .:/usr/lib/mf
MFEDITOR
Command template for switching to editor. Default: /usr/bin/emacs +%d %s

 

FONT UTILITIES

A number of utility programs are available (see section See Also). The following is a partial list of available utilities and their purpose. Consult your local METAFONT guru for details.

Takes a GF file and produces a more tightly packed PK font file
Unpacks a PK file into GF format
Produces proof sheets for fonts
Displays the contents of a GF file in mnemonics and images
Mnemonically displays the contents of a PK file
Formats a source file (font.mf) as shown in Computer Modern Typefaces

 

FILES

/usr/lib/mf
METAFONT's library area
/usr/lib/mf/mf.pool
Encoded text of METAFONT's messages
/usr/lib/mf/bases
METAFONT *.base files and short driver files for inimf
/usr/lib/mf/inputs/plain.mf
The ``standard'' macro package
/usr/lib/mf/inputs/`SITE-modes'.mf
The file of ``mode_def''s for your site's various printers
/usr/lib/mf/inputs/cmbase.mf
METAFONT macros for Computer Modern

 

SUGGESTED READING

Donald E. Knuth, The METAFONTbook (Volume C of Computers and Typesetting)
Donald E. Knuth, METAFONT the Program (Volume D of Computers and Typesetting)
Donald E. Knuth, Computer Modern Typefaces (Volume E of Computers and Typesetting)
TUGboat (the publication of the TeX Users Group)
 

COMMENTS

Warning: ``Type design can be hazardous to your other interests. Once you get hooked, you will develop intense feelings about letterforms; the medium will intrude on the messages that you read. And you will perpetually be thinking of improvements to the fonts that you see everywhere, especially those of your own design.''
 

BUGS

On January 4, 1986 the ``final'' bug in METAFONT was discovered and removed. If an error still lurks in the code, D. E. Knuth promises to pay a finders fee which doubles every year to the first person who finds it. Happy hunting.

The ``no format preloaded'' message could be considered an undesirable fossil, but it is not a bug.
 

AUTHORS

METAFONT was designed by Donald E. Knuth, who implemented it using his WEB system for Pascal programs. It was ported to Unix by Paul Richards at the University of Illinois at Urbana-Champlain. The version now offered with the Unix TeX distribution is that generated by the WEB to C system, written by Tomas Rokicki and Tim Morgan. This page written by Pierre MacKay, with help from the anonymous author of the page in the jTeX software distribution.
 

SEE ALSO

gftopk(1), gftype(1), pktogf(1), pktype(1)


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
ENVIRONMENT
FONT UTILITIES
FILES
SUGGESTED READING
COMMENTS
BUGS
AUTHORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 01:00:54 GMT, September 26, 2024