max-heller / mdbook-pandoc

A mdbook backend powered by Pandoc.
Apache License 2.0
111 stars 9 forks source link

Which font to generate emojis under Ubuntu 22? #119

Open hadrien-toma opened 3 days ago

hadrien-toma commented 3 days ago

Hello, thanks for the great work done here, relying on pandoc is a motivation I truly valuate :ok_hand:!

I try to render a markdown table containing emoji with the following configuration but doesn't rich too, maybe someone has any keys?

I am on Ubuntu 22.04 and I use MdBook 0.4.42 and Pandoc 3.5. Here is the content of my book.toml related to mdbook-pandoc:

[output.pandoc.profile.pdf]
output-file = "output.pdf"
to = "latex"
pdf-engine = "lualatex"
file-scope = true
number-sections = true
standalone = true
table-of-contents = true

[output.pandoc.profile.pdf.variables]
mainfont = "Ubuntu"

Using this setup I get the following result and without the mainfont line I see nothing instead of the emojis (worth noting the emojis are correctly rendered in epub and `html\ outputs): image

max-heller commented 20 hours ago

You'll want to add additional fallback fonts that support emojis. For example, see this config from the test suite:

https://github.com/max-heller/mdbook-pandoc/blob/24b1beb60adb69297e6f69fdcd1542297d9dfebe/src/lib.rs#L516-L535

In particular, something like the following with your preferred fonts substituted in should do the trick:

[profile.pdf]
pdf-engine = "lualatex" 

[profile.pdf.variables]
mainfont = "Noto Serif" 
sansfont = "Noto Sans" 
monofont = "Noto Sans Mono" 
mainfontfallback = [
  "NotoColorEmoji:mode=harf", 
] 
monofontfallback = [
  "NotoColorEmoji:mode=harf", 
] 

See the mainfontfallback, sansfontfallback, monofontfallback section of the Pandoc manual.