2

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.

5
  • 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
  • 2
    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?
    – matj1
    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.
    – matj1
    Dec 3 '21 at 18:11
7

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\@fontenc@load@list{\@elt{T1,OT1}}
\def\rmsubstdefault{cmr}
\def\sfsubstdefault{cmss}
\def\ttsubstdefault{cmtt}
\LoadFontDefinitionFile{TS1}{cmr}
\else
\input {tuenc.def}
\fontencoding{TU}
\def\@fontenc@load@list{\@elt{TU}}
\DeclareFontSubstitution{TU}{lmr}{m}{n}
\LoadFontDefinitionFile{TU}{lmr}
\LoadFontDefinitionFile{TU}{lmss}
\LoadFontDefinitionFile{TU}{lmtt}
\def\rmsubstdefault{lmr}
\def\sfsubstdefault{lmss}
\def\ttsubstdefault{lmtt}
\LoadFontDefinitionFile{TS1}{lmr}
\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.

0

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.

3
  • 1
    Welcome to TeX.SE!
    – Mensch
    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.
    – matj1
    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.
    – mcglk
    Dec 3 '21 at 18:16

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.