LaTeX font selection scheme
While processing the source document, the LaTeX typesetting system doesn’t have much knowledge about the font it is using. It just calculates the positions of the characters, without needing to know shapes. The most crucial information it requires are the characters’ black boxes, which are defined by their widths, heights, and depths. These dimensions are stored in a separate external file known as a TeX font metric (.tfm) file for each font.
The character chapes come into play later. If a LaTeX system produces a .dvi file, a driver program combines character placement data from the .dvi file with information about character shapes from the .pk file or from outline descriptions (such as PostScript) to produce the character image on the output medium. However, other LaTeX systems like PDF TeX or VTEX bypass the production of a .dvi file and instead directly generate PDF or PostScript output. In that case, the character shapes are embedded when the corresponding formatter produces the final output.
LaTeX font selection scheme
LaTeX separates logical typography from low-level font files through the New Font Selection Scheme (NFSS). Instead of hardcoding specific font filenames into a document, LaTeX describes every typeface using five independent attributes—encoding, family, series, shape, and size—and maps those combinations to external font metrics (.tfm files) and glyph outlines at compile time. Within Aspose.TeX for Java, the Object TeX engine implements this standard selection architecture natively in Java, allowing you to switch typefaces, configure custom font packages, and resolve encodings without requiring an external TeX distribution.
How NFSS resolves fonts
When typesetting text or mathematics, LaTeX evaluates the current attribute state in two stages:
High-level logical commands (such as
\textrm,\textbf,\textit, or\large) modify one font attribute at a time while preserving the others—for instance, switching from medium weight to bold without altering the active font family or point size.Low-level selection tables map the resulting five-attribute tuple to a physical external font via Font Definition (
.fd) files, loading the corresponding .tfm metric data into memory whenever\selectfontis triggered.
Core Topics Covered in This Chapter
The guides in this section progress from high-level text formatting commands to low-level NFSS internals, custom font installation, and character encoding models:
Fundamentals and attributes
Input and output — Explains how LaTeX processes source character encodings and maps internal glyph indices to output font encodings during compilation.
Font characteristics — Defines the five orthogonal NFSS font attributes (encoding, family, series, shape, and size) and how they interact to identify a specific typeface.
Standard document typography
LaTeX text fonts — Covers the high-level commands and declarations used to switch families (
\textrm, \textsf, \texttt), series (\textbf, \textmd), shapes (\textit, \textsc, \textsl), and relative sizes in document prose.Standard LaTeX fonts — Details the default Computer Modern typeface families, standard font packages, and size-scaling conventions available out of the box.
Low-level control and customization
Low-level interface — Introduces direct NFSS primitives (
\fontencoding, \fontfamily, \fontseries, \fontshape, \fontsize, \selectfont) for programmatic font switching inside macros and packages.How to set up new fonts — Walks through registering external typefaces, writing Font Definition (
.fd) files, and making custom fonts available to LaTeX documents.Model for character encodings — Describes LaTeX’s encoding architecture (
OT1, T1, TS1, and math encodings) and how glyph substitution and accent construction work across different font encodings.