2

I must be missing something really simple and obvious, because I think I have done this many times before. A simple tryout file:

\documentclass[12pt]{article}

\usepackage[no-math]{fontspec}

\setmainfont{Lato}

\begin{document}

\Huge
this should be Lato --- and it is.

\fontfamily{Lato}\fontsize{30}{45}\selectfont
verbatim, this should be Lato, but instead is 'LMRoman17-Regular'.

\fontfamily{Ubuntu}\fontsize{30}{45}\selectfont
verbatim this should be Ubuntu font, but also is LMRoman17-Regular.

\bigskip
\bigskip
\bigskip

\scriptsize

poppler pdffonts:

\begin{verbatim}
UOTJVU+Lato-Regular                  CID TrueType      Identity-H       yes yes yes      4  0
KYEUXJ+LMRoman17-Regular             CID Type 0C       Identity-H       yes yes yes      5  0
\end{verbatim}
\end{document}

LuaLaTeX picks up the \setmainfont on Lato perfectly, but the hand-set fonts do not work. (Lato and Ubuntu are installed in macOS' Font book.)

The output is:

Output

2 Answers 2

4

You can use \newfontfamily:

\documentclass[12pt]{article}
\usepackage[no-math]{fontspec}

\setmainfont{Lato}
\newfontfamily\latofont{Lato}
\newfontfamily\ubuntufont[Ligatures=TeX]{Ubuntu}

\begin{document}

\Huge
this should be Lato --- and it is.

\latofont\fontsize{20}{30}\selectfont
verbatim, this should be Lato --- and it is.

\ubuntufont\fontsize{15}{22}\selectfont
verbatim this should be Ubuntu font --- and it is.
\end{document}

enter image description here

4

fontspec uses internal NFSS fontfamily names—you could look them up in the log, but they can change so are not really suitable to call the font. If you want to use \fontfamily you should setup a public name with the NFSSFamily option. Alternatively use \rmfamily or \fontspec to select the font.

\documentclass[12pt]{article}

\usepackage[no-math]{fontspec}

\setmainfont{Lato}[NFSSFamily=Lato]

\begin{document}

\Huge
this should be Lato --- and it is.

\ttfamily just something else

\fontfamily{Lato}\fontsize{30}{45}\selectfont
This is LaTo

\ttfamily just something else

\rmfamily\fontsize{30}{45}\selectfont This is Lato

\ttfamily just something else


\fontspec{Lato}\fontsize{30}{45}\selectfont This is Lato

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .