TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As the title of this question suggested. Is there any practical difference between

\setmainfont{font name}


\newfontfamily\familyname{font name}

I had a look into the source of font spec. I believe the above two are practically the same. However, I am still not quite familiar with the latex3 syntax, so I may miss something.

share|improve this question
up vote 8 down vote accepted

Usually \rmdefault should expand to a string representing the font name; with your definition it expands to \familyname, whose expansion is not a string: for example, with \newfontfamily\familyname{Hoefler Text}, the expansion of \familyname is \protect\familyname  (with a space at the end, as usual with "robusted" commands. The expansion of \familyname  is

\fontencoding {EU1}\fontfamily {HoeflerText(0)}\selectfont

The expansion of \rmdefault after \setmainfont{Hoefler Text} is


So they are quite different.

Also using \rmfamily instead of \rmdefault does not give equivalent results: first of all, \rmfamily should be a robust command; its expansion results in \protect\rmfamily  and then in


So, again, also \DeclareRobustCommand{\rmfamily}{\familyname} won't work the same.

share|improve this answer
Many thanks for the answer. But, what if I use \def\rmfamily\familyname? I modified the question. – Yan Zhou Aug 30 '11 at 19:54
See updated answer – egreg Aug 30 '11 at 20:01
Thanks for the quick update -:) – Yan Zhou Aug 30 '11 at 20:03
N.B. if you do want to get access to the NFSS family defined when fontspec loads a new font family, you can use the \fontspec_set_family:Nnn command. – Will Robertson Aug 31 '11 at 1:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.