以下 MWE:
\documentclass{article}
\usepackage{fontawesome}
\begin{document}
Text Text \faMobilePhone\ Text Text
\end{document}
编译时:
pdflatex
并且lualatex
,效果很好,xelatex
,会出现以下错误:xdvipdfmx:fatal: pdf_ref_obj():传递了无效对象。
(并且无法创建任何 PDF 文件)。
你知道发生什么事了吗?
更新
根据 egreg 的要求,以下是控制台输出xelatex -output-driver="xdvipdfmx -vv" test.tex
:
<FONTMAP:/home/bitouze/.texlive2016/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:/home/bitouze/.texlive2016/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:/usr/local/texlive/2016/texmf-dist/fonts/map/dvipdfmx/ckx.map>No dvi filename specified, reading standard input.
stdin -> test.pdf
DVI Comment: XeTeX output 2016.10.14:1020
<AGL:texglyphlist.txt><AGL:pdfglyphlist.txt><AGL:glyphlist.txt>[1</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/[email protected]<NATIVE-FONTMAP:/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0>
fontmap: /usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0 -> /usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf(Identity-H)
pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf".
(CID:LMRoman10-Regular)
pdf_font>> Type0 font "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0,0>.
></usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/[email protected]<NATIVE-FONTMAP:/usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb/0/H/65536/0/0>
fontmap: /usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb/0/H/65536/0/0 -> /usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb(Identity-H)
pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb".
(CID:FontAwesome)
pdf_font>> Type0 font "/usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb/0/H/65536/0/0,1>.
>]
otf_cmap>> Creating ToUnicode CMap for "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf"...
(CID:/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf[VESFSG+LMRoman10-Regular][CIDFontType0][6 glyphs][1055 bytes])(CID:/usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb[QZYGOD+FontAwesome][CIDFontType0]
xdvipdfmx:warning: Invalid CMap
xdvipdfmx:fatal: pdf_ref_obj(): passed invalid object.
如果我是对的,它会指出xetex
或xdvipdfmx
找到错误的type1
字体(正如 Ulrike Fischer 猜测的那样)但我仍然感到困惑:我该怎么办?顺便说一句:
$ fc-list | grep 'fontawesome'
/usr/local/texlive/2016/texmf-dist/fonts/type1/public/fontawesome/FontAwesome.pfb: FontAwesome:style=Regular
/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/fontawesome/FontAwesome.otf: FontAwesome:style=Regular
答案1
你可以试试
\newfontfamily{\FA}{[FontAwesome.otf]}
加载 fontawesome 包后(对 Ulrike Fischer 的评论进行了简单修改)。一般来说,应该从 fontconfig 的搜索路径中删除 type1 字体的目录。除了非常简单的编码外,Type1 字体几乎不能用作 XeTeX 中的原生字体。
答案2
另一个解决方案是拒绝type1 字体。
添加此<glob>
行以/etc/fonts/fonts.conf
使其像这样(注意正确的父标签):
<fontconfig>
<selectfont>
<rejectfont>
<glob>/usr/share/texlive/texmf-dist/fonts/type1/*</glob>
</rejectfont>
</selectfont>
</fontconfig>
注意力:文件中的注释fonts.conf
说你应该使用local.conf
这个文件来代替它。但我的系统上没有这个文件。