我有一个来自雇主的自定义 Latex 类,除了其他一些内容外,它还加载字体 Charter 和 Frontpage(类附带的字体)。它与 pdflatex 配合良好,基本上通过 renewcommand 加载字体(见下文)。我想使用 lualatex 和 polyglossia,并在日志文件中发现 polyglossia 实际上加载了 fontspec。如果加载了 fontspec,则默认情况下会替换 Charter 和 Frontpage。有没有办法让它工作?
(我也有这两种字体的 ttf 文件,可以用 fontspec 加载,但它们似乎不包含小写字母)
这是示例代码。如果您没有字体,您将无法执行它,但您可以看到我如何加载它们。
\documentclass{article}
\usepackage{fontspec}
\renewcommand*{\rmdefault}{5ch}
\renewcommand*{\sfdefault}{5fp}
%The loading order of these three lines makes no difference
\begin{document}
Charter\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}
{\sffamily
Frontpage\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}
}
\end{document}
以下是日志文件的相关部分
LaTeX Font Info: ... okay on input line 9. %this is \begin{document}
LaTeX Font Info: Try loading font information for EU2+5ch on input line 9.
LaTeX Font Info: No file EU25ch.fd. on input line 9.
LaTeX Font Warning: Font shape `EU2/5ch/m/n' undefined
(Font) using `EU2/lmr/m/n' instead on input line 9.
%snip--------
LaTeX Font Info: Encoding `OT1' has changed to `EU2' for symbol font
(Font) `operators' in the math version `normal' on input line 9.
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) OT1/cmr/m/n --> EU2/5ch/m/n on input line 9.
LaTeX Font Info: Encoding `OT1' has changed to `EU2' for symbol font
(Font) `operators' in the math version `bold' on input line 9.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) OT1/cmr/bx/n --> EU2/5ch/m/n on input line 9.
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) EU2/5ch/m/n --> EU2/5ch/m/n on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `normal'
(Font) OT1/cmr/m/it --> EU2/5ch/m/it on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathbf' in version `normal'
(Font) OT1/cmr/bx/n --> EU2/5ch/bx/n on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `normal'
(Font) OT1/cmss/m/n --> EU2/5fp/m/n on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `normal'
(Font) OT1/cmtt/m/n --> EU2/lmtt/m/n on input line 9.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) EU2/5ch/m/n --> EU2/5ch/bx/n on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `bold'
(Font) OT1/cmr/bx/it --> EU2/5ch/bx/it on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `bold'
(Font) OT1/cmss/bx/n --> EU2/5fp/bx/n on input line 9.
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `bold'
(Font) OT1/cmtt/m/n --> EU2/lmtt/bx/n on input line 9.
LaTeX Font Warning: Font shape `EU2/5ch/bx/n' undefined
(Font) using `EU2/5ch/m/n' instead on input line 12.
%and so on, font warning for every line
答案1
虽然可以将这些字体与 lualatex 一起使用(通过使用正确的字体编码而不是使用字体规范),但我不建议这样做。连字符会出错,并且您会遇到非 ASCII 字符(如变音符号)的问题。如果您想切换到 lualatex,请正确操作并使用开放类型字体。
如果你想尝试一下,可以这样做:
\documentclass{article}
%load polyglossia or fontspec here if needed
\usepackage[T1]{fontenc} %probably, or [OT1]
\renewcommand*{\rmdefault}{5ch}
\renewcommand*{\sfdefault}{5fp}
\begin{document}
%test non-ascii
äöü§ß Euro: €
Charter\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}
{\sffamily
Frontpage\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}
}
\end{document}
“测试非 ASCII” 看起来会更像这样,它显示了您将遇到的问题:
答案2
您的 tex 文件看起来有些奇怪。我包含字体的代码看起来总是与此不同。Dante 在其 ftp 上有一个很好的字体规范示例。 ftp://ftp.dante.de/tex-archive/macros/latex/contrib/fontspec/fontspec-example.tex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
\setmonofont{Inconsolata}[Scale=MatchLowercase]
\begin{document}
\pagestyle{empty}
\section*{The basics of the \textsf{fontspec} package}
The \textsf{fontspec} package enables automatic font selection
for \LaTeX{} documents typeset with Xe\TeX{} or Lua\TeX.
The basic command is
{\centering \verb|\fontspec{font display name}[font features]|.\par}
The default, sans serif, and typewriter fonts may be set with the
commands \verb|\setmainfont|, \verb|\setsansfont| and \verb|\setmonofont|,
respectively, as shown in the preamble. They take the
same syntax as the \verb|\fontspec| package. All expected font
shapes are available:
\begin{center}
{\itshape Italics and \scshape small caps\dots}\\
{\sffamily\bfseries Bold sans serif and \itshape bold italic sans serif\dots}
\end{center}
Text fonts in maths mode are also changed (e.g., notice the cosine function in
`$\cos(n\pi)=\pm 1$') but only if the roman and sans serif fonts are set in
the preamble; \verb|\setmainfont| will not affect these maths mode fonts when
called mid-document.
Maths symbols themselves are not affected.
Notice the font features used to load the default fonts in the preamble.
\verb|Ligatures=TeX| is automatically enabled for the roman and sans font,
allowing regular \TeX{} ligatures like \verb|``---''| for ``---''.
\verb|Scale=MatchLowercase| automatically scales the fonts to
the same x-height.
Please see the complete \textsf{fontspec} documentation for further
information.
\end{document}
您还应该看看fontspec
这里非常好的文档:https://www.ctan.org/pkg/fontspec
README 已经包含必要的命令。
再见,阿罗纳尔
PS:你的字体缓存是最新的吗?