Skip to content
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

Emojis are not being displayed #1768

Closed
LukasKlement opened this issue Nov 29, 2022 · 8 comments
Closed

Emojis are not being displayed #1768

LukasKlement opened this issue Nov 29, 2022 · 8 comments

Comments

@LukasKlement
Copy link

WeasyPrint v57.1

Example code:

<!DOCTYPE html>
<html lang="{{language}}">
<head>
  <title>Emoji test</title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>
  <p>🍷Pecorino, Terre di Chieti IGT</p>
</body>
</html>

Expected: PDF shows wine glass emoji
Actual: PDF shows white space where the emoji should be

@liZe
Copy link
Member

liZe commented Nov 29, 2022

Hi!

It works for me.

emoji.pdf

Could you please share the generated PDF where the emoji is missing? If it’s also possible to include emojis that work, it could be useful.

@LukasKlement
Copy link
Author

Here's the PDF when rendered on my side:
rendered_template.pdf

Here's another template with 3 emojis, the wine and two different smiling emojis - only one works:
rendered_template_one_emoji.pdf

@liZe
Copy link
Member

liZe commented Dec 1, 2022

It looks like there’s no emoji font installed (or at least found) on your system. The only emoji that works is one of the few included in DejaVu. Do you have a font like Noto-Emoji installed?

@LukasKlement
Copy link
Author

Well spotted, thanks! That was it indeed.

Having installed Noto-Emoji Color, I encounter another issue with some emojis (namely with the string 🍷🍷🍷✅):

Message: 'Relative URI reference without a base URI: <%s %s="%s">'
Arguments: ('use', '{http://www.w3.org/1999/xlink}href', '#u1F3C3.6')

Removing the emoji string above from a document makes it render again.

@liZe
Copy link
Member

liZe commented Dec 2, 2022

It works here with Noto-Emoji: emoji.pdf

Your error happens when an relative URL is used without a base URL, and I have no idea how you could have that with emojis. Maybe you tried to install a SVG-based emoji font (such as Twemoji) that includes a use tag that doesn’t work for some reason? That seems really unlikely, but that’s the only situation that could cause this problem I’ve found.

@LukasKlement
Copy link
Author

Thanks Guillaume, it appears your guess is on point. I had downloaded the Noto Color Emoji font from Google fonts (https://fonts.google.com/noto/specimen/Noto+Color+Emoji) which caused the issue. Using the color font from the Github repo I did not encounter the issue: https://github.com/googlefonts/noto-emoji

@liZe liZe reopened this Dec 2, 2022
@liZe
Copy link
Member

liZe commented Dec 2, 2022

I can actually reproduce the bug with Noto from Google fonts, it looks like it uses SVG images with use tags 😱.

@liZe
Copy link
Member

liZe commented Dec 2, 2022

Allowing relative links when drawing emojis fixes the problem: emoji.pdf

But some of Noto’s glyphs are broken: they are HUGE (~15MB) and include A LOT of use tags. It’s probably a bug in the font… These glyphs require a lot of time and of memory to get rendered, and will likely make WeasyPrint eat all the RAM before crashing on "normal" computers.

So… Let’s consider this bug as closed with the fix, and let’s hope that Noto will be fixed soon. If anyone is interested in reporting a bug to Google, don’t hesitate to do so!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants