macOS 上安装的字体上的 LuaLaTeX

macOS 上安装的字体上的 LuaLaTeX

我肯定漏掉了一些非常简单和明显的东西,因为我觉得我以前已经做过很多次了。一个简单的试用文件:

\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 完美地支持\setmainfontLato,但手动设置的字体不起作用。(Lato 和 Ubuntu 安装在 macOS 的字体簿中。)

输出为:

输出

答案1

您可以使用\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}

在此处输入图片描述

答案2

fontspec 使用内部 NFSS 字体系列名称 — 您可以在日志中查找它们,但它们可能会发生变化,因此不太适合调用字体。如果您想使用,\fontfamily则应使用选项设置公共名称NFSSFamily。或者使用\rmfamily\fontspec选择字体。

\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}

在此处输入图片描述

相关内容