9.5 Standard LaTeX font support

This section opens with a short introduction to the standard text fonts distributed together with LaTEX, which are Computer Modern, European Computer Modern, and Latin Modern, as well as a brief introduction to the legacy and the modern support packages for core PostScript fonts (Chapter 10 shows samples of them and many other font families now available in LaTEX).

9.5.1 Computer Modern, Latin Modern - The LaTeX standard fonts

Along with TEX, Donald Knuth developed a family of fonts called Computer Modern; see Table 9.5. Until the early 1990s, essentially only these fonts were usable with TEX and, consequently, with LaTEX. Each of them contains 128 glyphs (TEX was working

Original TEX font encoding with 7 bits originally), which does not leave room for including accented characters as individual glyphs. Thus, using these fonts means that accented characters have to be produced with the primitive of TEX, which in turn means that automatic hyphenation of words with accented characters is impossible. While this restriction is acceptable for English documents that contain few foreign words, it is a major obstacle for other languages.

Not surprisingly, these deficiencies were of great concern to the TEX users in Europe and eventually led to a reimplementation of TEX in 1989 to support 8-bit characters internally and externally. At the TEX Users conference in Cork (1990), a standard 8-bit encoding for text fonts (T1) was developed that contains many diacritical characters (see Table 9.22 on page 763) and allows typesetting in more than 30 languages based on the Latin alphabet. At the University of Bochum (under the direction of Norbert Schwarz) the Computer Modern font families were then reimplemented, and additional characters were designed, so that the resulting fonts completely conform to this encoding scheme. The first implementation of these fonts was released under the name “DC fonts”. Since then Jörg Knappen has finalized them, and they are now distributed as “European Computer Modern Fonts”, often shortened to “EC fonts”.

Both Computer Modern and the EC fonts are considered standard in LaTEX and must be available at any installation. Although originally developed with METAFONT, there are free Type 1 PostScript replacements as well. For Computer Modern these were produced by Blue Sky Research; Y&Y added the LaTEX, AMS, and Euler fonts. The EC fonts were converted in 2001 from METAFONT sources to Type 1 PostScript by Vladimir Volovich. His implementation is called the CM-Super fonts package and, besides the EC fonts, it covers EC Concrete, EC Bright, and LH fonts (Cyrillic Computer Modern). In addition to the T1 encoding, the LaTEX standard encodings TS1, T2A, T2B, T2C, and X2 are supported by CM-Super. The CM-Super fonts were automatically converted to the Type 1 format, and although a sophisticated algorithm was used for this conversion, you cannot expect exactly the same quality as could be achieved by a manual conversion process.

Since the PostScript fonts have the same font metrics as their METAFONT counterparts, they need no support package in the LaTEX document. They are now provided by virtually all distributions and are automatically used by pdfTEX or the driver program (e.g., dvips) that converts the .dvi output to PostScript.

To avoid the generation of too many bit-mapped fonts, the standard .fd files for Computer Modern and European Computer Modern provided only a handful of welldefined font sizes. This is still the default even though with PostScript outline fonts it would be possible to typeset in arbitrary sizes without problems.1 Thus, if you ask for an intermediate size (via ), you get a warning, and the nearest available size is chosen instead. To lift this restriction you can make use of the package fix-cm or use the Latin Modern fonts instead as discussed below.

9.5.2 PSNFSS and TeX Gyre - Core PostScript fonts for LaTeX

The PostScript New Font Selection Scheme (PSNFSS) bundle, originally developed by Sebastian Rahtz (1955–2016), was the first major application using the LaTEX font selection scheme to provide support for common PostScript fonts, covering the “Base 35” fonts (which are built into any Level 2 PostScript printing device and the ghostscript interpreter) and the free Charter and Utopia fonts. After Sebastian’s death, Walter Schmidt (1960–2021) maintained PSNFSS, and today it is maintained by Keiran Harcombe, who has taken over all of Walter Schmidt’s packages.

These days it is, however, largely superseded by the development of the TEX Gyre fonts (by Bogusław Jackowski and Janusz Marian Nowacki (1951–2020)) that provide reimplementations of many of these fonts with an extended glyph set so that essentially all Latin-based languages are now supported. The Vietnamese glyphs in this collection have been added by Hàn Th´ê Thành. The basic Greek symbols are based on earlier work by Apostolos Syropoulos and Antonis Tsolomitis. Like the Latin Modern fonts, the TEX Gyre project was initiated and funded by several European TEX user groups.

9.5.3 A note on baselines and leading

Most document classes designed for use with Computer Modern set up a leading () of 10pt/12pt. This may appear to be too tight for several of the PostScript font families shown below, due to a larger x-height of the fonts. However, because this is a matter of document design and also depends on the chosen line width and other factors, the packages in the TEX Gyre or PSNFSS collection make no attempt to adjust the leading. For a given document class you can change the leading by a factor by issuing the declaration in the preamble. For example, would change the leading from, say, 12pt to approximately 12.4pt.

For best results, however, one needs to use a document class designed for the selected document fonts or, lacking such a class, to redefine the commands , , and so on (see page 665 for details). Also remember that changing the leading might result in a noticeable number of “Underfull ” warnings, if the is no longer an integral number of text lines (see page →II 763 for further details).

9.5.4 inputenc - Explicity selecting the input encoding

As mentioned earlier, the development of the inputenc package made it possible to use many accented characters, either via single keystrokes or by some other input method (e.g., by pressing ‘ and then a to get à) in your source instead of having to type ’a, ^e, and so forth.

To enable this, all you had to do was to load the package and specify the input encoding1 used by your computer as a package option. Once done, the document is processed correctly on any LaTEX installation even if the source file looks strange on some computers due to the encoding differences.

For example, the Russian text Русский язык (Russian language) written in the once popular koi8-r encoding would display in an editor program on a German computer (using the latin1 encoding) partially scrambled as

9.5.5 fontenc - Selecting font encodings

To be able to use a text font encoding with LaTEX, the encoding has to be loaded in the document class, in a package, or in the document preamble. More precisely, the definitions to access the glyphs in fonts with a certain encoding have to be loaded. The canonical way to do this with an 8-bit TEX engine; e.g., pdfTEX is via the fontenc package, which takes a comma-separated list of font encodings as a package option. The last of these encodings is automatically made the default document encoding. For example,

9.5.6 Additional text symbols not part of OT1 or T1 encodings

When the T1 font encoding was defined in Cork, it was decided that this encoding should omit many standard text symbols such as † and instead include as many composite glyphs as possible. The rationale was that characters that are subject to hyphenation have to be present in the same font, while one can fetch other symbols without much penalty from additional fonts. These extra symbols have, therefore, been collected in a companion encoding. In 1995, a first implementation of this encoding (TS1) was developed by Jörg Knappen [80, 81]. With the textcomp package, Sebastian Rahtz (1955–2016) provided a LaTEX interface to it.

Unfortunately, just as with the T1 encoding, the encoding design for TS1 was prepared based on glyph availability in the TEX world without considering that the majority of commercial fonts provide different sets of glyphs. As a result, the full implementation of this encoding is available for very few font families, among them EC, CM Bright, and Latin Modern fonts. For most PostScript fonts, implementations of the encoding also exist, but a larger number of the glyphs are missing and produce square blobs of ink or possibly just a gap in the typeset output.1 Table 9.9 on pages 696–697 shows the glyphs made available by TS1 and the commands to access them. Commands colored in blue indicate that the corresponding glyph is most likely not available in the font design when PostScript or OpenType fonts are used.

Since 2020 the symbols provided by the TS1 encoding are directly accessible from LaTEX without the need to load the textcomp package any longer. The package is still available so that older documents work without complaining about a missing package.

9.5.7 exscale - Scaling large Computer Modern math operators

Normally the font employed for large mathematical symbols is used in only one size. This setup is usually sufficient, because the font includes most of the characters in several different sizes and (LA)TEX is specially equipped to automatically choose the symbol that fits best. However, when a document requires a lot of mathematics in large sizes — such as in headings — the selected symbols may come out too small. In this case, you can use the package exscale, which provides for math extension fonts in different sizes.

The package is only meant for documents using Computer Modern math fonts or very closely related designs such as Latin Modern because it makes use of the large symbol font of Computer Modern in different design sizes. However, packages providing alternate math font setups often offer this functionality as a package option, usually also named exscale.

9.5.8 tracefnt - Tracing the font selection

The package tracefnt can be used to detect problems in the font selection system. It supports several options that allow you to customize the amount of information displayed by NFSS on the screen and in the transcript file.

errorshow This option suppresses all warnings and information messages on the terminal; they are written only to the transcript file. However, real errors are shown on the terminal. Because warnings about font substitutions and so on can mean that the final result is incorrect, you should carefully study the transcript file before printing an important publication.

warningshow When this option is specified, warnings and errors are shown on the terminal. This setting gives you the same amount of information as LaTEX 2ε does without the tracefnt package loaded.

infoshow This option is the default when you load the tracefnt package. Extra information, which is normally written only to the transcript file, is now also displayed on your terminal.

debugshow This option additionally shows information about changes to the text font and the restoration of such fonts at the end of a brace group or the end of an environment. Be careful when you turn on this option because it can produce very large transcript files.

In addition to these “standard tracing” options,1 the package tracefnt supports the following options:

pausing This option turns all warning messages into errors to help in the detection of problems in important publications.

loading This option shows the loading of external fonts. However, if the format or document class you use has already loaded some fonts, then these are not shown by this option.

9.5.9 nfssfont.tex - Displaying 8-bit font tables and samples

The LaTEX distribution comes with a file called nfssfont.tex that can be used to test new 8-bit fonts, produce font tables showing all characters, and perform similar font-related operations.2

This file is an adaption of the program testfont.tex, which was originally written by Donald Knuth. When you run this file through LaTEX, you are asked to enter the name of the font to test. You can answer either by giving the external font name without any extension — such as cmr10 (Computer Modern Roman 10pt) — if you know it or by giving an empty font name. In the latter case you are asked to provide an NFSS font specification, that is, an encoding name (default T1), a font family name (default cmr), a font series (default m), a font shape (default n), and a font size (default 10pt). The package then loads the external font corresponding to that classification.

Next, you are requested to enter a command. Probably the most important one is , which produces a font chart like the one on page 750. Also interesting is , which produces a longer text sample. To switch to a new test font, type ; to finish the test, type or . To learn about all the other possible tests (at the moment basically still tailored for the OT1 encoding), type . The default action is because this is what is usually wanted.