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.