[Tex/LaTex] xdvipdfmx pdf_ref_obj() error with fontawesome

fontawesomexetex

The following MWE:

\documentclass{article}
\usepackage{fontawesome}
\begin{document}
Text Text \faMobilePhone\ Text Text
\end{document}

when compiled with:

  • pdflatex and lualatex, works like a charm,
  • xelatex, is subject to the error:

    xdvipdfmx:fatal: pdf_ref_obj(): passed invalid object.

    (and cannot create any PDF file).

Do you know what's going on?

Update

As requested by egreg, here is the console output of 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/lmroman10-regular.otf@9.96pt<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/FontAwesome.pfb@9.96pt<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.

If I'm right, it points out that xetex or xdvipdfmx find the wrong type1 font (as guessed by Ulrike Fischer) but I'm still puzzled: what can I do against that? BTW:

$ 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

Best Answer

You can try

\newfontfamily{\FA}{[FontAwesome.otf]}

after loading the fontawesome package (a simple modification of the comment by Ulrike Fischer). In general, directories for type1 fonts should be removed from search paths for fontconfig. Type1 fonts are almost unusable as native fonts in XeTeX, except for very simple encoding.

Related Question