fontspec
offers the commands \setmainfont
, \setsansfont
and \setmonofont
to load a font and set it as the default roman, sans serif or monospaced font, respectively. It also offers the command \newfontfamily
, which loads a font and defines a command that activates it:
% loads the font family 'Latin Modern Roman' and defines the command `\latinmodernroman`,
% which activates it
\newfontfamily\latinmodernroman{Latin Modern Roman}
\latinmodernroman% activates the Latin Modern Roman font family
% loads the font family 'Latin Modern Roman' and *also* sets it as the roman family default
\setmainfont{Latin Modern Roman}
How would one go about decoupling loading and setting, i.e., first loading a font with \newfontfamily
and then setting it as family default?
\newfontfamily\latinmodernroman{Latin Modern Roman}
\def\rmdefault{ what? }
% My understanding is that it's 'lmr' for 'Latin Modern Roman'
% But how about arbitrary fonts? How to know their "LaTeX identifiers" when using fontspec?
I've been trying to understand fontspec.dtx, but I'm not familiar with the "expl" syntax.
\setmainfont
not only loaded a font, but also set it as the default and that there were no means for carrying out these steps separately, i.e., no way of doing so with a font loaded with\newfontfamily
. I also dislike globals (I feel likewise aboutpolyglossia
's\setdefaultlanguage
, for instance). So… there's actually no use case, aside from my 'idealism'. I feel a bit embarrassed, I hope this doesn't anger anybody.\setmainfont
is actually changing the default serif, which has already been changed at least once when fontspec was loaded.