Consider the following file:
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Numbers={Lining,Proportional},Ligatures=Common]{EB Garamond}
\newfontface\garamondoldstylenumbers[Numbers={OldStyle,Proportional},Ligatures=Common]{EB Garamond}
\begin{document}
EB Garamond 123
\typeout{1st use of \addfontfeatures}
{\addfontfeatures{Numbers={OldStyle,Proportional}}EB Garamond 123\par}
\typeout{2nd use of \addfontfeatures}
{\addfontfeatures{Numbers={OldStyle,Proportional}}EB Garamond 123\par}
\typeout{1st use of \garamondoldstylenumbers}
{\garamondoldstylenumbers EB Garamond 123\par}
\typeout{2nd use of \garamondoldstylenumbers}
{\garamondoldstylenumbers EB Garamond 123\par}
\end{document}
If this is compiled under either XeLaTeX or LuaLaTeX, examining the log file shows messages along the lines of
.................................................
. Font family 'EBGaramond(2)' created for font 'EB Garamond' with options
. [Numbers={Lining,Proportional},Ligatures=Common,Numbers={OldStyle,Proportional}].
.
. This font family consists of the following shapes:
.
etc. after both uses of \addfontfeatures
, but not after using \garamondoldstylenumbers
. (Naturally, similar messages occurs in when \setmainfont
and \newfontface
are processed in the preamble.)
There will be some performance hit from parsing the options to \addfontfeatures
. But is there a performance hit beyond this, because fontspec
seems to be defining the font anew each time?
The only relevant thing I can find in the fontspec manual says "For cases when a specific font with a specific feature set is going to be re-used many times in a document, it is inefficient to keep calling \fontspec
for every use. While the \fontspec
command does not define a new font instance after the first call, the feature options must still be parsed and processed." I would assume that \addfontfeatures
uses the \fontspec
command, but I don't know the details of the implementation.
(I will be typesetting a long document that will require frequent use of both the italic and swashed italic of a commercial font: I have used old style numbers and EB Garamond in the example because it is freely available. Naturally, I would normally define a macro for \addfontfeatures{...}
.)