LaTeX font commands

Font Attributes

Under the new font selection system (NFSS) employed by LaTeX2e, a font has five attributes: encoding, family, series, shape, and size. LaTeX typesets using a particular encoding vector and a particular font metric scaled to a particular size depending upon the values of these attributes. We will explain just what encoding vectors and mapping schemes are and how to set them up shortly; for the moment, let us concentrate on how to specify the font attribute set to be used by LaTeX.

The commands to change font attributes are illustrated by the following example:


This series of commands set the current font to medium weight italic garamond 12pt type with 15pt leading in the T1 encoding scheme, and the \selectfont command causes LaTeX to look in its mapping scheme for a metric corresponding to these attributes. It is not possible to give an exhaustive set of the possible values of each attribute, as new possibilities can be introduced as new families of fonts are added.

Default Font Attributes

The visual appearence of a document is determined largely by which font attribute set is used for the body text, and which are requested by \section{}, \emph{}, \texttt{}, and other such commands. In LaTeX2e, all such commands set font attributes to the values stored in certain variables and the user may change the look of a document by changing the values of these variables. These variables and their default values are listed below:
variablevalueactivated by
\encodingdefaultOT1\normalfont, \textnormal{}
\familydefault\rmdefault\normalfont, \textnormal{}
\rmdefaultcmr\rmfamily, \textrm{}
\ttdefaultcmtt\ttfamily, \texttt{}
\sfdefaultcmss\sffamily, \textsf{}
\seriesdefaultm\normalfont, \textnormal{}
\mddefaultm\mdseries, \textmd{}
\bfdefaultbx\bfseries, \textbf{}
\shapedefaultn\normalfont, \textnormal{}
\updefaultn\upshape, \textup{}
\itdefaultit\itshape, \textit{}
\scdefaultsc\scshape, \textsc{}
\sldefaultsl\slshape, \textsl{}
For example, the \normalfont command (essentially) executes the command sequence:
The values of these attribute variables may be changed using \renewcommand, for example \renewcommand{\familydefault}{\sfdefault} causes the entire document to be set in the default sans serif font. Changes to these defaults should be made in the document preamble or in a package.

Encoding Vectors

An encoding vector is a set of instructions to LaTeX detailing how particular symbols are to be constructed. For example, the T1 encoding vector file T1enc.def contains the following commands, among many others:
which declare that a T1 encoding vector exists, that, when this encoding vector is in effect, the \'{x} command should superimpose character 1 (accent acute) over the character x, that \ae should produce character 230 (the æ ligature), and that \"a should produce character 228 (the umlaut ä). Notice that an encoding vector implicitly associates a number with each character. The correspondence between characters and numbers used by TeX need not correspond with the correspondence defined by your platform or in your font; don't worry about that, yet.

When a user requests a new encoding ENC, LaTeX looks for the file ENCenc.def, where it expects the encoding vector to be defined. You can read more about encoding vectors in the LaTeX companion, but initially you will likely want to use the standard T1 vector; the file T1enc.def should be a part of any LaTeX2e distribution, but for your convience we have also provided a link.

Obviously, for a particular character to be accessable in TeX, it must appear in the encoding vector. The authors of the T1 standard chose to include a wide variety of symbols and characters which are used to typeset many languages; they may not, however, have included every character defined in your particular font: yen and copyright symbols, for example, are commonly included in postscript fonts, but do not appear in the T1 encoding. Conversely, the T1 encoding may include characters not present in your particular font: most postscript fonts, for example, do not include the ff ligature, which occupies position 27 in the T1 encoding. The absence from your font of a character defined in T1 is not usually a problem; as long as you do not use that character, no difficulties will arise (if you do use a character in your document which is undefined in your font, it will simply appear as a blank space when viewed or printed). Conversely, the absence from the T1 encoding of characters which do exist in your font is a problem, inasmuch as you want to employ these characters. In that case you must define an encoding which includes all the characters you want. The encoding defined in LY1enc.def, used by Y&Y TeX systems, allows access to all the characters in a standard Adobe roman font.

Mapping schemes

Once a the relevent encoding vector is defined, you will want to set up a scheme which maps font attribute sets to font metrics. For example, the file T1garamond.fd contains the commands
  \DeclareFontShape{T1}{garamond}{m}{n}{ <-> garrm }{}
  \DeclareFontShape{T1}{garamond}{m}{it}{ <-> garit }{}
which declare the existence of the garamond family with T1 encoding, and say that, when a T1 garamond medium normal font is requested, LaTeX should use the garrm.tfm metric scaled to the appropriate size, while the italic-shape font request used in our earlier example should call up the garit.tfm metric file. When a user requests an unknown font family FAMILY with encoding ENC, LaTeX look for the file ENCFAMILY.fd, where it expects to find a mapping scheme defined. You can read in more detail about font family decleration commands in the LaTeX Companion.

To prepare a font family in which the typical LaTeX document can be typeset, you will need to map at least the medium-normal (m-n), medium-italic (m-it), and boldextended-normal (bx-n) series-shape combinations to extant font metrics, in order to set the body text, emphasized text, and section headings, respectively. Some other fonts that documents might request include: medium-smallcaps (m-sc) and medium-slanted (m-sl).

Family style files

Most of the time, when you prepare a font family for use with LaTeX, you will want to prepare a short file containing commands like
Call it garamond.sty and place it in a directory searched by TeX so that users can call call it up simply by issuing the command \usepackage{garamond} in the document prologue, and have the entire document set in garamond without further ado.

When setting up such a style file, you might also want to include declarations of accompanying \sffamily and \ttfamily fonts which are visually compatible with your \rmdefault font.

Back to the table of contents, or... ...on to the chapter on obtaining TeX font metrics