I use a setup with 3 files: the list of macros/symbols in UTF8 do-emoji.tex:
% Names below are arbitrary; a macro with this name will be defined.
% After editing the list in the next row, (re)run: xelatex emoji-from-list
\foreach [count=\P] \M/\C in {smilie/,ghost/,pumpkin/}
{\doEmoji{\C}{\M}{\P}}
(I think one should avoid whitespace in the list in the first row.) Then the rendering file emoji-from-list.tex:
\documentclass[multi=my,crop]{standalone}
\usepackage{pgffor}
\usepackage{fontspec}
\setmainfont{Symbola}
\begin{document}
\newcommand\doEmoji[3]{% character, macroname, page
\begin{my}#1\end{my}}
\include{do-emoji}
\end{document}
(process with xelatex emoji-from-list). Finally, the actual LaTeX file includes:
\newcommand\includeEmoji[1]{% With CM fonts and 1.28, it ascends to the top of the capitals, and descends to the bottom of comma.
\ensuremath{\vcenter{\hbox{\includegraphics[page=#1,height=1.28\fontcharht\font`A]{emoji-from-list}}}}}
{\newcommand\doEmoji[3]{% character, macroname, page
\expandafter\xdef\csname #2\endcsname{\noexpand\includeEmoji{#3}}%
\edef\next{\noexpand\includeEmoji{#3}}% % would need more expansion in the next row otherwise
\expandafter\expandafter\expandafter\Gnewunicodechar\expandafter\expandafter\expandafter{\expandafter#1\expandafter}%
\expandafter{\next}% % (#1=\C)
}% For a preamble common for several docs: do nothing if file is not present:
\IfFileExists{do-emoji.tex}{\input{do-emoji}}{}}
After this, either use a macro (named in do-emoji.tex), or just use the UTF-8 character. (If you do not need macro names, give the same fake name to all of the characters in the list.) It is easy to auto-generate the file do-emoji.tex.
NOTES:
I optimize for usage in math; so I use larger emoji than in other
answers, and they are \vcenter⸣ed.
Above, a macro \Gnewunicodechar is used. If you do not plan to
use these Unicode chars in your document, just remove the last two
lines inside the definition of \doEmoji above.
I do not know about utf8, but for utf8x, \Gnewunicodechar
may be defined as this:
\def\UNItoNUMz{% Actually, do not need hex in what follows!
\edef\OUT{\the\count0}%
}
\def\UNItoNUMcont#1#2{%
\multiply\count0 64\relax
\advance\count0 -"80\relax
\advance\count0 `#2\relax
#1}
\def\UNItoNUM#1{% No attempt is made to detect out-of-range bytes
\count0=#1% \ifnum#1<"C0\relax % In the range a0..bf would give false positives
\let\next=\UNItoNUMz
\else
\ifnum#1<"E0\relax \advance\count0 -"C0\relax \def\next{\UNItoNUMcont\UNItoNUMz} \else \ifnum#1<"F0\relax
\advance\count0 -"E0\relax
\def\next{\UNItoNUMcont{\UNItoNUMcont\UNItoNUMz}}
\else
\ifnum`#1<"F8\relax
\advance\count0 -"F0\relax
\def\next{\UNItoNUMcont{\UNItoNUMcont{\UNItoNUMcont\UNItoNUMz}}}
\fi
\fi
\fi
\fi
\next}
\newcommand\Gnewunicodechar[2]{{% (Since we need global for \foreach, localize changes anyway.) Specific for utf8x
\def\gdefUNI##1##2{%
\expandafter\let\csname uc@temp@a\endcsname\global\csname uni@declcharopt\endcsname{##1}{document}{##2}}%
\UNItoNUM#1% % (#1=\C; sets \OUT); This is for utf8x; in utf8, may need something else
\gdefUNI{\OUT}{#2}% % finish definition
}}
Update: I changed \include to (the most robust combination of) \input and \IfFileExists. The reason: \include may create a spurious pagebreak. One should also consider the variant in the first comment below.
pdflatexhave only up to 256 characters. – egreg Nov 14 '12 at 22:04newunicodechar) would be a way out, if a tedious one. – Raphael Nov 14 '12 at 22:09otftotfmto 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 withstandalonevia XeLaTeX) and then using\newunicodecharto access them. – egreg Nov 14 '12 at 22:13coloremojipackage, which will insert the images from Apple’s fonts. – Davislor Jul 25 '20 at 01:43