2

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?

  • 1
    Without the actual font it is difficult to say. But you can try the method described here tex.stackexchange.com/a/37418/2388 – Ulrike Fischer Oct 24 '13 at 7:11
  • Now it's strange. The suggestion does work on Linux, but does not work on windows... I mean, in Linux I can see all the gliphs of Dingbats, in windows I have the error above. Probably a font problem, so. The font is in a *.pfb file. Moreover, I tried to adapt the suggested example to fontspec (using \newfontface\myfont{Dingbats} instead of \font\myfonts="Dingbats" but then I have an error on \stepcounter... (??) – Rmano Oct 24 '13 at 14:29
  • 1
    The code is meant for opentype or ttf-fonts. If your font is a .pfb you should better create a tfm-file and use it "in the standard" way and not with fontspec. – Ulrike Fischer Oct 24 '13 at 14:32
2
\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

  • Nice. Still stymied about why pifont doesn't work if you call it after fontspec, while my \myding (that should be the same) does. – Rmano Oct 24 '13 at 19:43
  • By the way... which is the TTF dingbat font? Wingding? Thanks. – Rmano Oct 24 '13 at 19:44
  • there are a lot ... For example: azfonts.net/download/zafdingn/ttf.html – user2478 Oct 24 '13 at 19:54
1

I found an answer. Most of merits should go to @Ulrike Fischer.

The problem is that I supposed that Type1 font could be treated the same way that opentype or ttf ones. The minimal snippet that works in latex, pdflatex (commenting out the fontspec, that is) and in xelatex is the following:

\documentclass{article}
\usepackage{fontspec} % comment for pdflatex or latex
\begin{document}
\newcommand{\myding}[1]{{\fontfamily{pzd}\fontencoding{U}%
  \fontseries{m}\fontshape{n}\selectfont\char#1}}

{char:  \myding{115}}

\end{document}

...and both compilers produced the same symbol (a black filled triangle, similar to U+25B2). Probably there is a better way to achieve this, but I'm quite happy with this...

  • no need for a new command, see my answer. – user2478 Oct 24 '13 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.