[Tex/LaTex] Using Dingbats font in xelatex

fontsxetex

This must be a real-newbie-level question (which is kind of embarassing having used plain TeX to write my PhD thesis in 1992), but I am not be able to find an answer. Even if there are 5 millions similar questions here… so, my MWE is this:

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\dingbatsfont{Dingbats}
\newcommand\ding[1]{{\dingbatsfont\symbol{#1}}}

\begin{document}
\ding{115} % no output
{\dingbatsfont ❤} % error --- comment out to have a PDF file 
\end{document}

…and running it with xelatex gives an error on the second line:

** WARNING ** 1 glyph names (out of 1) missing Unicode mapping.
** WARNING ** ToUnicode CMap "TZCCMX+Dingbats-UTF16" removed.
** ERROR ** pdf_ref_obj(): passed invalid object.

whilst if I remove it, I have no error, but the \ding{115} gives nothing. The strange thing is that the PDF file generated (when I remove the second line) seems to have the font loaded:

(0)samsung-romano:~/education/LibroEje/tmp% pdffonts lalla.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
IPQPDZ+Dingbats-Identity-H           CID Type 0C       Identity-H       yes yes yes      5  0
WPNUQB+LMRoman10-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      7  0

…and the font is here and usable by LibreOffice:

LibreOffice font selector

I tried to substitute the 115 with the Unicode codepoint "2773 but then I have the error above again.

What am I doing (terribly) wrong?

Best Answer

\documentclass{article}
\usepackage{pifont}% load it first
\usepackage{fontspec}
\begin{document}

char: \ding{115}

\end{document}

There is also a TrueType dingbats font. For that one it makes sense to define an own \ding