25

I've recently started to learn LaTeX, and have just come across the distinction between font commands and declarations. As a learner it seems unnecessarily complex that whereas the commands follow a regular text- pattern, the declarations distinguish between -family/-series/-shape.

My question is: What motivated the distinction between -family, -series and -shape in font declarations? In the answers of another question (\bfseries is to \textbf as WHAT is to \textsf), there is considerable explanation of what the different font elements mean in LaTeX and how they fit together, but my question is why they were designed like that in the first place.

29

That particular terminology was introduced by Rainer Schöpf and Frank Mittelbach in the New Font Selection Scheme, which was originally a variant version of LaTeX 2.09 but then formed the core of the LaTeX2e release of LaTeX.

It does however correspond fairly closely to natural language terminology with fonts and also to classifications used by later systems such as CSS for styling fonts on the web where you have font-family: Times Roman, font-weight: bold, font-style: italic.

In the primitive TeX font loader each font is a distinct entity so there is no connection between computer modern roman and computer modern bold, so you can not ask for the bold version of the current font.

The NFSS classifies fonts according to family, series (weight) etc so if you use \itshape it just changes the shape to it and then tries to select a font with all the other properties unchanged.

The declarations are the lower level form, and each is named to tell you which "axis" it changes, so \itshape changes the shape axis to it etc. the \text... command forms that take an argument change one or more of the font axes and do some work on inserting automatic italic correction, and we dropped the axis part of the names in those cases, just to keep the names shorter.

The original LaTeX2.09/NFSS version introduced the terminology of the axes in internal font declarations but instead of having user level commands \bfseries and \textbf it re-defined the existing "two letter" commands such as \bf to mean bold version of current font, rather than always switch to the same bold font whatever the context. This caused some compatibility issues and confusion and when NFSS was re-done to produce LaTeX2e the current command set was introduced with \bfseries meaning bold version of current font and \bf not being defined by default, but defined in the standard classes as (more or less) \normalfont\bfseries to give a backward compatible definition that always selected the bold version of the default document font.

24

In the olden times (before NFSS), LaTeX had the commands \it, \sl, \bf and \tt, which were not “orthogonal” to each other. So

Normal {\it italic {\bf boldface {\sl slanted}}}

would have printed “boldface” in upright type and “slanted” in slanted type and medium weight.

In order to get boldface italic you had to define your own command, using a rather low level interface: as low as requiring several \font declarations. Keep also in mind that fonts were saved in the format, so you had to create an entirely new latexwhatever format if you wanted to use the “whatever” font family, based on a completely rewritten lfonts.tex file.

The situation was unacceptable when the AMS started the project to port AMS-TeX to LaTeX. An entirely new and more flexible font selection scheme was needed; Frank Mittelbach and Rainer Schöpf were in charge of the port and devised the “new font selection scheme” (version 1) that was immensely more powerful than the old font loader.

Instead of code such as

% ten point
 \font\tenrm  = cmr10    % roman
 \font\tenmi  = cmmi10   % math italic
    \skewchar\tenmi ='177  %  for placement of accents
%\font\tenmib = cmmib10   % bold math italic
 \font\tensy  = cmsy10   % math symbols
    \skewchar\tensy ='60 %   for placement of math accents
%\font\tensyb = cmbsy10  % bold symbols
 \font\tenit  = cmti10   % text italic
 \font\tensl  = cmsl10   % slanted
 \font\tenbf  = cmbx10   % extended bold
%\font\tenbfs = cmbxsl10 % extended bold slanted
 \font\tentt  = cmtt10   % typewriter
    \hyphenchar\tentt = -1         %  suppress hyphenation in \tt font
%\font\tentti = cmitt10  % italic typewriter
%\font\tentts = cmsltt10 % slanted typewriter
 \font\tensf  = cmss10   % sans serif
%\font\tensfi = cmssi10  % italic sans serif
%\font\tensfb = cmssbx10 % bold sans serif
%\font\tensc  = cmcsc10  % small caps
 \font\tenly  = lasy10  % LaTeX symbols
%\font\tenlyb = lasyb10 % bold LaTeX symbols
%\font\tenuit = cmu10    % unslanted italic

where fonts for a specific size were defined, they grouped fonts into classes; for each class one defined the various sizes. Some entries are commented because there was a (rather primitive) mechanism to load fonts on demand, but they had to be predefined (if not preloaded) anyway in the format.

Instead of having to define

\fivrm \sixrm \sevrm \egtrm \ninrm \tenrm
\elvrm \twlvrm \frtnrm \svtnrm \twtyrm \twfvrm

for the upright font in medium size, they decided the names would be

\cmr/m/n/5 \cmr/m/n/6 \cmr/m/n/7 \cmr/m/n/8 \cmr/m/n/9 \cmr/m/n/10
\cmr/m/n/11 \cmr/m/n/12 \cmr/m/n/14 \cmr/m/n/17 \cmr/m/n/20 \cmr/m/n/25

(with a slash in the name, which requires some trick) so the names encoded various features of the font. Most importantly, the family: the format still had the basic fonts preloaded, but it became possible to load entirely new font families on demand.

The idea of family, series and shape came of course from how the X window system for Unix classified fonts.

This scheme allowed to make font selection commands orthogonal to each other, so

Normal {\itshape italic {\bfseries boldface {\slshape slanted}}}

would print “boldface” in boldface italic (if the font is available) and “slanted” in boldface slanted (again, if the font is available). I use “available” in the sense of corresponding to an external font file and being defined in the macro files.

Version 2 of NFSS introduced the concept of font encoding, so the normal font is now known to the system as \OT1/cmr/m/n/10.

Encoding the features in the name allows for finer selections: the boldface font is called \OT1/cmr/bx/n/10, so, in order to select it from the current font, it's sufficient to disassemble the name and changing m to bx, which is what eventually \bfseries does, essentially calling \fontseries{bx}\selectfont.

A declaration for getting boldface italic could be defined by

\DeclareRobustCommand{\bfitfont}{\fontseries{bx}\fontshape{it}\selectfont}

The scheme also introduced \DeclareTextFontCommand, so we have something like

\DeclareTextFontCommand{\textbf}{\bfseries}

and you could define \textbfit with

\DeclareTextFontCommand{\textbfit}{\bfseries\itshape}

called as \textbfit{word}.

The other important aspect of NFSS is the possibility to define font families in a separate .fd file, where each available class of fonts (grouped by features) for a given family is defined by selecting the external font files for the various sizes.

Such a scheme is so flexible that fontspec hooked to it: when you say \setmainfont{FONT}, the contents of what would be an .fd file is created on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.