9.8 Setting up new fonts for NFSS
Setting up new fonts for use with LaTEX basically means filling the internal font selection tables with information necessary for later associating a font request in a document with the external .tfm file containing character information used by LaTEX. Thus, the tables are responsible for associating
9.8.1 Declaring new font families and font shape groups
The declarations discussed in this section are normally used only inside .fd files (font definition files), which should normally not be changed. With some caution, it is however possible to use them in the document preamble (or in packages) to adjust some font family behavior. How this can be done is explained in Section 9.8.2 on page 746.
Each family/encoding combination must be made known to LaTEX through the command .
9.8.2 Modifying font families and font shape groups
If you need a nonstandard font shape group declaration for a particular document, just place your private declaration in a package or the preamble of your document. It then overwrites any existing declaration for the font shape combination. Note, however, that the use of prevents a later loading of the corresponding .fd file (see Section 9.8.4). Also, your new declaration has no effect on fonts that are already loaded.
To get around both problems, you need to explicitly load the corresponding font definition files first by using . Then you can call to overwrite the loading information or set up some special substitutions, etc. For example, to prevent hyphenation in Latin Modern Proportional Typewriter, where it is by default enabled, you could write
9.8.3 Declaring new font encoding schemes
Font changes that involve alterations in the encoding scheme require taking certain precautions. For example, in the T1 encoding, most accented letters have their own glyphs, whereas in the traditional TEX text encoding (OT1), accented letters must be generated from accents and letters using the primitive. (It is desirable to use glyphs for accented letters rather than employing the primitive because, among other things, the former approach allows for correct hyphenation.) If the two approaches have to be mixed, perhaps because a font is available in only one of the encodings, the definition of a command such as ” must behave differently depending on the current font encoding.
For this reason, each encoding scheme has to be formally introduced to LaTEX with a command, which takes three arguments. The first argument is the name of the encoding under which you access it using the command. Table 9.18 on page 737 provides a list of standard encoding schemes and their internal NFSS names.
The second argument contains any code (such as definitions) to be executed every time LaTEX switches from one encoding to another using the command. The final argument contains code to be used whenever the font is accessed as a mathematical alphabet. Thus, these three arguments can be used to redefine commands that depend on the positions of characters in the encoding.
There should not be really any need for users (other than a handful for developers worldwide) to define new font encodings, so we do not provide further details here. If you are interested, refer to [113].
As we saw in Section 9.7.3 on font substitution, the default values for the family, series, and shape may need to differ across encodings. To support this, NFSS provides the command , which again takes the encoding as the first argument. The next three arguments are the default values (associated with this encoding) for family, series, and shape for use in the automatic substitution process, as explained in Section 9.7.3. It is important that these arguments form a valid font shape — in other words, that a declaration exists for them. Otherwise, an error message is issued when NFSS checks its internal tables at \begin{document}.
9.8.4 Internal file organization
Font families can be declared when a format file is generated, declared in the document preamble, or loaded on demand when a font change command in the document requests a combination that has not been used so far. The first option consumes internal memory in every LaTEX run, even if the font is not used. The second and third possibilities take a little more time during document formatting, because the font definitions have to be read during processing time. Nevertheless, it is preferable to use the latter solutions for most font shape groups, because it allows you to typeset a wide variety of documents with a single LaTEX format.
When the format is generated, LaTEX reads a file named fonttext.ltx that contains the standard set of font family definitions and some other declarations related to text fonts. With some restrictions,1 this set can be altered by providing a configuration file fontdef.cfg; see the documentation [110].
All other font family definitions should be declared in external files loaded on request: either package files or font definition (.fd) files. If you place font family definitions in a package file, you must explicitly load this package after the \documentclass command. There is also a third possibility: whenever NFSS gets a request for a font family foo in an encoding scheme BAR and it has no knowledge about this combination, it tries to load a file called barfoo.fd (all letters lowercase). If this file exists, it is supposed to contain font shape group definitions for the family foo in the encoding scheme BAR — that is, declarations of the form
9.8.5 Declaring new fonts and symbols for use in math
Setting up additional math fonts is also an activity that is not often needed; however, because there is the occasional need for it, this section provides you with the necessary information.
Specifying font sizes
For every text size, NFSS maintains three sizes that are used to typeset formulas (see also Section 11.7.1): the size in which to typeset most of the symbols (selected by or ); the size for first-order subscripts and superscripts (); and the size for higher-order subscripts and superscripts (). If you switch to a new text size, for which the corresponding math sizes are not yet known, NFSS tries to calculate them as fractions of the text size. Instead of letting NFSS do the calculation, you might want to specify the correct values yourself via . This declaration takes four arguments: the outer text size and the three math sizes for this text size. For example, the class file for The LATEX Companion contains settings like the following: