Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Fonts in pdflatex have only up to 256 characters. –  egreg Nov 14 '12 at 22:04
    
@egreg Is that a "no way, you have to use (XeLa|Lua)Tex"? I guess using actual images or drawing them with TikZ (access via newunicodechar) would be a way out, if a tedious one. –  Raphael Nov 14 '12 at 22:09
1  
You could use otftotfm to create a font with the desired glyphs from DejaVu, but it would be very time consuming. Probably getting them as pictures (maybe PDF files built with standalone via XeLaTeX) and then using \newunicodechar to access them. –  egreg Nov 14 '12 at 22:13
add comment

1 Answer

up vote 10 down vote accepted

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}
share|improve this answer
1  
Sweet. Feels like playing Jenga with a sledgehammer, though. ;) –  Raphael Nov 14 '12 at 22:40
    
On second thought, this approach is mechanical enough to make a script of it. Take list of symbols, create a pdf for each of them and then create an sty defining all the newunicodechar mappings. One minor problem remains: included PDFs don't scale with the font size. Can this be added? –  Raphael Nov 16 '12 at 17:24
1  
@Raphael I've added a way to scale the symbol –  egreg Nov 16 '12 at 18:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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