Xetex:使用 OTF 字体(MacPorts)

Xetex:使用 OTF 字体(MacPorts)

我在 LaTeX 文档中使用自己的 OTF 字体时遇到问题。我了解到我应该使用 MacPorts (package )编译xelatex我在 Mac 上安装的文档texlive-xetex

我的最小文档如下所示:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
    Lorem ipsum
\end{document} 

通过编译xelatex test.tex我得到以下错误:

This is XeTeX, Version 3.1415926-2.4-0.9998 (TeX Live 2012/MacPorts 2012_5)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo
aded.
(/opt/local/share/texmf-texlive-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/opt/local/share/texmf-texlive-dist/tex/latex/base/size10.clo))
(/opt/local/share/texmf-texlive-dist/tex/latex/fontspec/fontspec.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/expl3.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3names.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3bootstrap.sty))
(/opt/local/share/texmf-texlive-dist/tex/latex/etex-pkg/etex.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/graphics/color.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/latexconfig/color.cfg)
(/opt/local/share/texmf-texlive-dist/tex/xelatex/xetex-def/xetex.def))
(/opt/local/share/texmf-texlive-dist/tex/latex/graphics/graphics.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/graphics/trig.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/latexconfig/graphics.cfg))
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3basics.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3expan.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3tl.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3seq.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3int.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3quark.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3prg.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3clist.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3token.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3prop.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3msg.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3file.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3skip.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3keys.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3fp.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3box.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3coffins.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3color.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3luatex.sty))
(/opt/local/share/texmf-texlive-dist/tex/latex/l3packages/xparse/xparse.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/fontspec/fontspec-patches.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/base/fixltx2e.sty)
*************************************************
* LaTeX warning: "xparse/redefine-command"
* 
* Redefining document command \oldstylenums with arg. spec. 'm' on line 107.
*************************************************
) (/opt/local/share/texmf-texlive-dist/tex/latex/fontspec/fontspec-xetex.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/base/fontenc.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/euenc/eu1enc.def)
(/opt/local/share/texmf-texlive-dist/tex/latex/euenc/eu1lmr.fd)kpathsea: Invalid fontname `[lmroman10-regular]', contains '['

! Font EU1/lmr/m/n/10=[lmroman10-regular]:mapping=tex-text at 10.0pt not loadab
le: Metric (TFM) file or installed font not found.
<to be read again> 
                   relax 
l.100 \fontencoding\encodingdefault\selectfont

\setmainfont[Path=/Absolute/Path/To/My/OTF/Font/]{file.otf}我做错了什么?我也尝试在序言中指定字体的完整路径。

虽然我更喜欢使用pdftex而不是 ,xelatex因为我读到它xelatex有一些缺点,而且我不想在我使用的每台计算机上都安装它。有没有使用 OTF 字体的好解决方案pdftex

答案1

我究竟做错了什么?

您提供的最小工作示例是将 OpenType 字体与 LaTeX 结合使用的正确方法。但是,您可能缺少 TeX Live 的某些部分。

解决方案可以是以下之一:

  • 安装麦金塔电脑
  • 安装以下 MacPorts 包texlive-basictexlive-fonts-extratexlive-fonts-recommended

我推荐第一个选项,但第二个选项也应该可行(如果您确实想通过 MacPorts 来执行此操作)。

有没有使用 OTF 字体的好的解决方案pdftex

除非你想把它们转换成 Type 1 字体,否则恐怕不行。幸运的是,有很多人可以帮你转换。你可以在以下网站找到很多可用于 pdfLaTeX 的字体:LaTeX 字体目录

相关内容