5

I'm trying to use both the lualatex or xelatex commands to produce my document:

xelatex -shell-escape -synctex=1 -interaction=nonstopmode -file-line-error -recorder "book.tex"

or

lualatex -shell-escape -synctex=1 -interaction=nonstopmode -file-line-error -recorder "book.tex"

I was under the impression that lualatex and xelatex support emojis "out of the box", however, I'm getting the following errors like these:

Missing character: There is no ✔ (U+2714) in font [lmmono10-regular]:!
Missing character: There is no  (U+1F680) in font [lmmono10-regular]:!
Missing character: There is no  (U+1F4C4) in font [lmmono10-regular]:!

Most of the emojis appear in code snippets I have in my document, which look like this:

\begin{codeInput}{bash}{terminal}{Output of running the Android release lane.}
[✔]  
+----------------------------------------+---------+------------------------+
|                               Used plugins                                |
+----------------------------------------+---------+------------------------+
| Plugin                                 | Version | Action                 |
+----------------------------------------+---------+------------------------+
| fastlane-plugin-increment_version_cod  | 0.4.3   | increment_version_code |
| e                                      |         |                        |
+----------------------------------------+---------+------------------------+

[08:45:45]: Driving the lane 'android release' [08:45:45]: ------------------------------------ [08:45:45]: --- Step: increment_version_code --- [08:45:45]: ------------------------------------ [08:45:45]: The increment_version_code plugin will use gradle file at (android/app/build.gradle)! [08:45:45]: -> line: ( versionCode 3 )! [08:45:45]: ☝️ Version code has been changed to 4 \end{codeInput}

Here, codeInput is a custom tcolorbox with minted that I've created.

The PDF is indeed generated, but the emojis in the code snippets are simply missing:

PDF generated code snippet

Does anyone know how to get the emojis in my minted code snippets to work? I would guess it has something to do with adding emoji support to that specific font lmmono10-regular? Or passing some flags to minted perhaps?

I currently don't explicitely call \setmainfont in my document, if that helps.

1 Answers1

5

As Ulrike and David guided, it was indeed due to not having a font that supported emojis. Since for now the emojis are only found in my code snippets in my document, I only needed to change my monospace font settings. I borrowed the \directlua method from Ulrike's earlier answer and ended up using the following:

\usepackage{fontspec}

\directlua{luaotfload.add_fallback ("emojifallback", { "AppleColorEmoji:mode=harf;" } )}

\setmonofont{Fira Code}[ RawFeature={fallback=emojifallback} ]

and make sure you compile your document using lualatex.

Emojis will work in your minted code snippets whether you write the source code directly in the LaTeX document or use minted's ability to import the code from a file.