-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have emoji working in sphinx latexpdf xelatex
generated in titles and code
#12195
Comments
I posted on SO the corresponding question: https://stackoverflow.com/questions/78214882/have-emoji-working-in-sphinx-latexpdf-xelatex-generated-content-titles-and-code |
Just wondering, but does a plain LaTeX file with such emojis would do what you want? (like, what would the minimum LaTeX file which would work (independently of Sphinx)) |
I'm not Latex good enough, the minimal whould be to have B&W emoji in both \section and \begin{Verbatim} I guess. A cascading mechanism is probably the droid we are looking for ;) Like if you don't find the emoji in FreeSansBold.otf try to take it from Symbola |
Our solution for (color) emoji in the PDF output was to use LuaLaTeX and to define TwemojiMozilla as the fallback font. You can see the result there: https://club1.fr/docs/en/club1-en-latest.pdf The idea mainly came from this article: https://www.overleaf.com/learn/latex/Articles/An_overview_of_technologies_supporting_the_use_of_colour_emoji_fonts_in_LaTeX |
Maybe the method of numpy/numpy#23172 would work here. Something such as (check the file extension for Symbola, assuming it is otf here) latex_elements['preamble'] = r"""
\newfontfamily\FontForEmojis{Symbola}[Extension=.otf]
\catcode`🚀\active\protected\def🚀{{\FontForEmojis\string🚀}}
\catcode`🔨\active\protected\def🔨{{\FontForEmojis\string🔨}}
""" You have to do it for all used characters. A latex code doing a loop is possible. I am not Edit: in the above perhaps |
Sorry for noise here. On reading more closely the very instructive overleaf link provided by @n-peugnet, especially XeTeX and OpenType color fonts, I realized that the method I indicated would not work with
|
To keep this issue related to xelatex, I created a new one focus on LuaLaTeX: #12332, with all insight got from @n-peugnet and @jfbu. |
xelatex
generated in titles and code
B&W success using this set-up:
|
I changed the type of this ticket to question because it does not seem to be related to a bug in Sphinx LaTeX support, except if one considers support for color emojis should be built-in, on which topic I don't have myself any strong opinion! |
Describe the bug
with
latex_elements = {"preamble": r"\setmainfont{Symbola}"}
we have beautiful B&W emoji in xelatex generated PDF content but not on titles and not on code.How to Reproduce
Below a sphinx to illustrate emoji in latexpdf:
add some content:
Set latex_engine and article xelatex:
HTML emoji are ok
latexpdf with
xelatex
engine have no emoji:with
setmainfont
get get some emoji (B&W and only in content):The corresponding latex code expose that font for
section
does not know about emoji, neither font define forsphinxVerbatim
::The latex log file expose that in
code::
latex look for emoji inFreeMono.otf
and in title latex look for emoji inFreeSansBold.otf
:To see which one of my fonts has the
⣿
.On my unbuntu 22.04 the below fonts have the ⣿ character:
Beyond the
question, I wonder why
\setmainfont
can have bothSymbola
andFreeSerif
values in tex file, I expect to have only one mainfont, idealy to defineSymbola
as a fall back font in case characters are not found in theFreeSerif
"mainfont":Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: