Joachim Breitner

TTF-Glyph in pdflatex output

Published 2007-08-25 in sections English, Digital World.

For a project of mine, I had the dire need of getting the Unicode character ⚰ (U+26B0 COFFIN) in a PDF file created with pdflatex. I could find no latex package that provides this or a similar character, so I had to do it myself.

There are some HOWTOs on how to use a TrueType font in pdflatex, but all of them thought that you are trying to use the font for your regular text, not just for the one strange glyph. So based on these, here is what I did:

  • Found a TrueType font containing the symbol. In my case, DejaVuSans.ttf, which is based on Bitstream Vera Sans.
  • Created the encoding file burial.enc. Note that almost all characters are unmapped, and just the 1 maps to our character.
  • Created the needed tfm file using the commands ttf2afm /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf -o burial.afm -e burial.enc; afm2tfm burial.afm -c burial.enc
  • Wrote a t1burial.fd file. Note the prepended “T1”, which reflects the character encoding (whatever that is).
  • Finally wrote a simple package (burial.sty) which provides the \burial command to show the glyph, by selecting the font and writing the character on position 1.
  • Now I add \usepackage{burial} to the preamble of my TeX file and use the \burial command wherever I need it.

All in all you need to keep the files burial.enc, burial.sty, burial.tfm and t1burial.fd in the directory of your TeX file. I did not check how to install the files globally.

If you think this is done horribly wrong, please feel free to tell me how it should be done instead.

Comments

Have something to say? You can post a comment by sending an e-Mail to me at <mail@joachim-breitner.de>, and I will include it here.