[Tex/LaTex] Unicode emoticons with pdflatex

fontspdftexunicode

Following this answer, I tried to use Unicode emoticons with pdflatex like so:

{\fontfamily{DejaVuSans-TLF}\selectfont ๐Ÿ˜Ž}

The font is selected but the emoticon does not show.

There are some TTF fonts which support the characters, such as Symbola, but apparently getting TTF fonts to work with pdflatex is a pain in the butt.

Is there a way out?

Best Answer

Prepare the following file

% smilie.tex
\documentclass[preview]{standalone}
\usepackage{fontspec}
\setmainfont{DejaVu Sans}
\begin{document}
๐Ÿ˜Ž
\end{document}

and compile it with XeLaTeX. Then you can use the glyph via the so built PDF file:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}
\usepackage{graphicx}
\newunicodechar{๐Ÿ˜Ž}{\includegraphics{smilie}}

\begin{document}
Here is a ๐Ÿ˜Ž.
\end{document}

enter image description here

Probably some tweaking with the borders in the standalone file is necessary.

You can get the height of an uppercase letter in the current font by saying

\includegraphics[height=\fontcharht\font`A]{smilie}
Related Question