How can I get a correct font identifier with
\the after it is overwritten? The MWE is below (Same result with all of Knuth TeX, pdfTeX, XeTeX, (e-)pTeX, (e-)upTeX and Aleph. Only LuaTeX behaves differently, which returns
\X for all tests.)
%#!plain TeX \font\X=ec-lmr10\X % set \X to the current font \font\Y=ec-lmr10 % same as current font \showthe\font % > \Y (most recently defined CS that selects the same font) \showthe\X % > \Y (same as above) \font\Y=cmbx10 \showthe\font % > \Y (!!!) \showthe\X % > \Y (!!!) \end
The TeXbook says
\the⟨font⟩ produces a font identifier that selects the specified font. For example, ‘
\the\font’ is a control sequence corresponding to the current font.
The free book TeX for the Impatient explains the behavior in more detail (as mentioned in This answer)
\the⟨font⟩, which expands to the most recently defined control sequence that selects the same font as the control sequence ⟨font⟩
However, both of them fails to explain the behavior as noted with
luaotfload.stywere loaded (which is the default in LuaLaTeX). The observed difference occurs because LuaTeX will load the same font multiple times by default.