[Tex/LaTex] LuaLaTeX: use or don’t use classical font packages

fontslatin-modernluatexpackages

In the lualatex-doc I am reading under "switching from LaTeX to LuaLaTeX":

  1. Don’t load inputenc, just encode your source in UTF-8.
  2. Don’t load fontenc, but load fontspec.
  3. Don’t use any package that changes the fonts, but use fontspec’s commands instead.

Consider the following example:

% !Mode:: "TeX:UTF-8"
\documentclass[paper=a4]{scrartcl}
\usepackage{fontspec}
\usepackage{lmodern}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
Hellöö! ßßäü
\end{document}

It compiles perfectly fine and looks as desired with lualatex from TeXLive 2012. It is in agreement with points (1) and (2) from the list above. However, I am wondering:

  • Doesn't \usepackage{lmodern} violate point (3) from above?

If yes:

  • What would be the LuaLaTeX way of using lmodern?
  • Why does it work then? In which cases is this expected to break?

I just took lmodern as an example, the question applies to all such kinds of font packages.

Best Answer

Your example works as there exists suitable font definitions files for the "lmr" and the "lmss" families for the EU2 font encoding in the euenc package. (If you look in the log-file you will see that a eu2lmss.fd is loaded).

If you would replace lmodern by e.g. times it would no longer work. You would see in the log-file a warning:

LaTeX Font Info:    No file EU2phv.fd. on input line 14.

LaTeX Font Warning: Font shape `EU2/phv/m/n' undefined
(Font)              using `EU2/lmr/m/n' instead on input line 14.

And the document wouldn't use helvet but the fallback lmr.

To be able to use the helvet font you would have to switch the fontencoding to an encoding for which font definitions for helvet exists, e.g. T1-encoding. But with this encoding you will no longer be able to input non-ascii-chars directly:

\documentclass[paper=a4]{scrartcl}
\usepackage{fontspec}
\usepackage{times}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
¼½¾ Hellöö! ßßäü
% this gives helvet, but some chars are wrong:
\fontencoding{T1}\selectfont ¼½¾ Hellöö! ßßäü \ss
\end{document}
Related Question