Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.25k stars 968 forks source link

Many unicode characters, e.g. "emoji" are not supported by Source Sans Pro #202

Open n1trux opened 4 years ago

n1trux commented 4 years ago

Here's an example of a spec file for our internal ISMS which throws a lot of errors because unicode symbols are not supported:

$ pandoc CHECKLIST.md -o ~/tmp/checklist.pdf --from markdown --template eisvogel --listings --pdf-engine=xelatex
[WARNING] Missing character: There is no 🚧 (U+1F6A7) in font [SourceSansPro-Regular.otf]/OT:script=
[WARNING] Missing character: There is no 🛠 (U+1F6E0) in font [SourceSansPro-Regular.otf]/OT:script=
[WARNING] Missing character: There is no ️ (U+FE0F) in font [SourceSansPro-Regular.otf]/OT:script=
[WARNING] Missing character: There is no ✅ (U+2705) in font [SourceSansPro-Regular.otf]/OT:script=
[WARNING] Missing character: There is no 🔥 (U+1F525) in font [SourceSansPro-Regular.otf]/OT:script=
[WARNING] Missing character: There is no 👍 (U+1F44D) in font [SourceSansPro-Regular.otf]/OT:script=

I suggest using something like texlive-emoji (https://www.texlive.info/CTAN/macros/luatex/latex/emoji/emoji-doc.pdf) for full unicode symbol support.

jan-walther commented 9 months ago

I've found a workaround for this if you're willing to use lualatex:

header-includes:
 - |
  \directlua{luaotfload.add_fallback
     ("emojifallback",
      {
        "Twemoji Mozilla:mode=harf;script=DFLT;"
      }
     )}
---
`\renewcommand{\familydefault}{\sfdefault}`{=latex}
`\setmainfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}
`\setsansfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}
kierun commented 7 months ago

@jan-walther Do you have a working example .md file with this?

kierun commented 7 months ago
---
header-includes:
 - |
  \directlua{luaotfload.add_fallback
     ("emojifallback",
      {
        "Twemoji Mozilla:mode=harf;script=DFLT;"
      }
     )}
---
`\renewcommand{\familydefault}{\sfdefault}`{=latex}
`\setmainfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}
`\setsansfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}

🚀 🌑

This is the test file I have been using. I get this:

√ ; pandoc test.md -o test.pdf --from markdown --template eisvogel --listings --pdf-engine=lualatex
Error producing PDF.
!  ==> Fatal error occurred, no output PDF file produced!

✗ 43 ;
jan-walther commented 7 months ago

---

header-includes:

 - |

  \directlua{luaotfload.add_fallback

     ("emojifallback",

      {

        "Twemoji Mozilla:mode=harf;script=DFLT;"

      }

     )}

---

`\renewcommand{\familydefault}{\sfdefault}`{=latex}

`\setmainfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}

`\setsansfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}

🚀 🌑

This is the test file I have been using. I get this:


√ ; pandoc test.md -o test.pdf --from markdown --template eisvogel --listings --pdf-engine=lualatex

Error producing PDF.

!  ==> Fatal error occurred, no output PDF file produced!

✗ 43 ;

Hi, did you install the Mozilla Emoji font on your system? I've only tried it on Mac OS so far using this font: https://github.com/mozilla/twemoji-colr

kierun commented 7 months ago
Package                                    Arch       Version                                     Repository                  Size
Installing:
 texlive-twemoji-colr                      noarch     11:svn64854-69.fc39                         fedora                   1.4 MiB
 twitter-twemoji-fonts                     noarch     14.0.2-4.fc39                               fedora                   3.1 MiB

Installing those two solved it.

@jan-walther Thank you!

mpepping commented 6 months ago
---
header-includes:
 - |
  \directlua{luaotfload.add_fallback
     ("emojifallback",
      {
        "Twemoji Mozilla:mode=harf;script=DFLT;"
      }
     )}
---
`\renewcommand{\familydefault}{\sfdefault}`{=latex}
`\setmainfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}
`\setsansfont{sourcesanspro}[RawFeature={fallback=emojifallback}]`{=latex}

🚀 🌑

Had to add a line for Emoji support in mono-text blocks:

`\setmonofont{sourcecodepro}[RawFeature={fallback=emojifallback}]`{=latex}

.. Thanks, @jan-walther! Your solution works well!