You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like when you use an emoji inside a pre tag this causes a newline to be introduced. The snippets below are similar to what presenterm generates when exporting a presentation to PDF. Content here is a series of lines of a specific height and a page is capped at a height equal to the line height * number of lines in a page, as if it was a capture of a terminal output (which it is).
In this html, there's a first page with 2 lines without any emoji, then the second page is exactly the same as the first one except with an emoji. You can see in this second page that the second line is no longer the expected one but instead is a newline. The content in page 3 is shifted by one line and an extra page is added because of it. If you remove the emoji in page 2 it all works as expected; similarly if you remove the pre tag it also works, but I do want to preserve whitespaces so I need that white-space: pre.
I saw a couple of open issues around white-space: pre-wrap but I don't know if it's related as there shouldn't be any line wrapping here.
I think that it’s not a bug in WeasyPrint, but a "problem" with line-height that is actually quite common. Short answer: setting line-height is not enough to be sure about the line box height if you have multiple fonts in a line (the font for text, the font for emoji in your example). Here, your line box height is slightly more than 12px, and then the second line doesn’t fit. If you want to be sure, you can set height: 12px on .content-line.
It’s a bit hard to see the same problem in a browser, as there’s no pagination, but here’s a similar example with flex and without an emoji:
The result is "broken" in Firefox, the height of "page 2 emoji" is larger than 30px and "2/2" doesn’t fit:
This problem is hard to reproduce reliably, because it depends on the way browsers handle fonts metrics and rounding tricks, so you may get different renderings with different browsers, even on the same computer with the same fonts. But that’s not a bug.
It looks like when you use an emoji inside a
pre
tag this causes a newline to be introduced. The snippets below are similar to what presenterm generates when exporting a presentation to PDF. Content here is a series of lines of a specific height and a page is capped at a height equal to the line height * number of lines in a page, as if it was a capture of a terminal output (which it is).In this html, there's a first page with 2 lines without any emoji, then the second page is exactly the same as the first one except with an emoji. You can see in this second page that the second line is no longer the expected one but instead is a newline. The content in page 3 is shifted by one line and an extra page is added because of it. If you remove the emoji in page 2 it all works as expected; similarly if you remove the
pre
tag it also works, but I do want to preserve whitespaces so I need thatwhite-space: pre
.I saw a couple of open issues around
white-space: pre-wrap
but I don't know if it's related as there shouldn't be any line wrapping here.Run using:
input.html:
styles.css
Output file bug.pdf
The text was updated successfully, but these errors were encountered: