# Where can the default typeface of TEX be found? Is it possible to change it?

When a TEX document is compiled, the engine uses glyphs from a typeface that has to be somewhere. I expect that the path of the typeface would be written somewhere in the TEX engine. If that is, where is the typeface? Is it possible to change a setting of a TEX engine so that it would look for a different typeface as the default? If my expectation is wrong, how does getting the glyphs of the default typeface work?

Edit: The default typeface is the one that is used when there is no indication in the document of which typeface shall be used.

• if you use pdftex then it shows the full path to each font used at the end of the log. Dec 3 '21 at 17:50
• tex doesn't really have a default font it will load no font unless explicitly loaded. The latex format initialises that to computer modern for pdflatex and latin modern for lualatex and xelatex. Dec 3 '21 at 17:52
• @DavidCarlisle Should I change the question so it would be about the default LATEX font? Would it make more sense then? Dec 3 '21 at 18:02
• perhaps but the answer as I say is computer modern or latin modern, depending on the engine, but the default is pretty arbitrary fallback, you can add \usepackage{whatever} and change them all. Dec 3 '21 at 18:03
• I know how the typeface is called; I want to know where is the instruction specifying the default typeface or where is the file containing it. The default typeface is the one used without a specification of a typeface in the document, so using a package for a typeface would not change the default typeface; it would just make the engine use a different one. Dec 3 '21 at 18:11

Given a document

\documentclass{article}

\begin{document}
hello
\end{document}


That doesn't specify a font the font will be as specified by the document class, or if that doesn't specify a font family then the LaTeX default.

In this case article specifies a default size of 10pt but does not specify a font family so the format default is used.

In pdflatex or latex that is encoding OT1 the original 7-bit TeX encoding and family cmr (Computer Modern Roman). If you process the document the end of the log shows

/usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb


showing that the only font used is the Type1 (PostScript) version of cmr10.

If you process the same with lualatex then you get the format default encoding TU (Unicode) and format default of lmr (Latin Modern). The end of the log again shows the full path to each font used (just one on this case)

/usr/local/texlive/2021/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf


Showing the OpenType version of Latin Modern Roman 10

These OT1 (or TU) defaults are set in the format, specifically the file base/fonttext.ltx which has the lines

\ifx\Umathcode\@undefined
\fontencoding{OT1}
\def\rmsubstdefault{cmr}
\def\sfsubstdefault{cmss}
\def\ttsubstdefault{cmtt}
\else
\input {tuenc.def}
\fontencoding{TU}
\DeclareFontSubstitution{TU}{lmr}{m}{n}
\def\rmsubstdefault{lmr}
\def\sfsubstdefault{lmss}
\def\ttsubstdefault{lmtt}
\DeclareFontSubstitution{TU}{lmr}{m}{n}
\fi


Where the true branch is executed in pdflatex and latex and the false branch is executed in lualatex and xelatex.

In principle you could copy fonttext.ltx to fonttext.cfg modify it to use some different font set and then rebuild the format, the .cfg file if it exists will be used in preference to the .ltx file. But really you should never do this, it has no advantages over simply using the same commands to change the font in the document or in a custom document class, and it makes your "latex" format incompatible with every other latex installation. It sort of made sense when we added this in the early 1990s before widely available common distributions such as miktex and texlive were available, and different sites had different fonts available (and changing fonts in-document could take minutes rather than fractions of a second) but now it should be regarded as a obsolete feature that is never used.

It depends on which engine you're using.

For that exact reason, I tend to use xetex, which allows you to specify alternative text fonts and allow Unicode characters.

https://plain-xetex.neocities.org/fonts.html

TeX's defaults get into the esoteric pretty quickly; if you want to explore that, it may be better for an offline discussion.

• Welcome to TeX.SE! Dec 3 '21 at 17:56
• I wrote “a TEX engine” because I wanted to know if it's possible at all. The link in your answer is to a text describing how to use a typeface other than the default. (See the edit of my question.) I usually use LuaTEX. Dec 3 '21 at 17:57
• Well, sure. What you'd do is redefine all the font macros that TeX uses. It gets complicated in the case of the math fonts, though. Dec 3 '21 at 18:16