Repository navigation
Emojis in PDF - #3853
Emojis in PDF#3853
Conversation
Render emojis stored in the SBIX table
Should they be rasterized at all unless the output format is png? |
|
You can try passing u16::MAX and see whether this fixes it. If not, then it's probably just the font being very pixelated... |
elegaanz
left a comment
There was a problem hiding this comment.
Small self-review, mostly questions I had while working on this
I used to have a harcoded |
|
I just checked, and it seems like at least for this font, EDIT: The documentation for
So looks like it really just stands for the bitmap resolution... |
And other small improvements
A bug in Poppler based PDF readers prevents them from displaying color fonts without that change.
Taking twice the font size makes them render nicely up to 200% zoom level, and doesn't make the PDF file much bigger.
Also change the algorithm used for that in PDF, to be consistent between the two formats.
This was buggy for fonts other than Apple Color Emoji This reverts commit f780ed2.
This only worked with Apple Color Emoji. For now we prefer to have this font a bit broken, than all other ones. This reverts commit b55f864.
And two other small TODOs
|
Yes the selection really depends on the reader you are using, Firefox and Chrome render it correctly for instance. There seem to be no good solution here unfortunately. |
That was breaking the last glyph of Type3 fonts.
It appears that it also depends on the compiler you are using. Here is a small example with Typst: And here is an example from LuaLaTeX: Both are viewed in Okular. Interestingly, in Firefox it also only selects half of the colored char and the next space is the second half of the same character. In other words, the visual whitespace between chars is not selected at all, it selects as a part of emoji. Very weird. Another weirdness, is that the LuaLaTeX's output of green hearts isn't selectable/copyable at all! I assume because browser's built-in PDF reader isn't supposed to be fully compatible with the spec, it just has to be able to show the output, and all the quirks aren't considered. I just tried copying the LuaLaTeX's version to Typst: It also selects the whitespace as if it was half of the heart. So it technically selects So in the end both compilers create different selectable or sometimes unselectable emojis, so I don't know if or how Typst's implementation can make the visual selectability better/prettier. |
Problem with a emoji in PDF was resolved: typst/typst#3853







So far, this only renders emojis stored in the SBIX table. The code may be dirty sometimes. I mainly open this PR so that we can start reviewing and discussing what was done so far before I go deeper.
Things that don't work in the current SBIX implementation :
the baseline seems wrong (but I have some ideas of what could fix it)According to this page the font bounding box lowest point should probably be used, but in practice it seems too close to 0 to do anything useful. I decided to use the descender size instead, which looks nice with Apple Color Emoji. It will probably need some testing with other fonts to make sure this is a viable solution.the resolution is not that great. I feel like if you zoom on the PDF file, even a little, you start to see pixels. I don't know if I'm a not passing the correct resolution/font size tottf-parseror if their resolution selection algorithm is bad.rendering doesn't work with Poppler based viewersThe file I am using for testing, if you want to test this branch
Will fix #144