-
-
Notifications
You must be signed in to change notification settings - Fork 992
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
Emoji do not render in PDFs #144
Comments
looks like a font issue. I get expected result: https://github.com/typst/typst/files/11058297/emoji.pdf 18.2 KB. I am using Segoe UI Emoji font. |
Hum, that's quite interesting: #set text(font: (
"Segoe UI Emoji"
))
Segoe Emoji here → #emoji.face.grin #emoji.amphora ← ?
#set text(font: (
"Noto Color Emoji"
))
Noto Emoji here → #emoji.face.grin #emoji.amphora ← ? Here is the file |
System: Arch Linux, cargo 1.68.0, typst a253b47 Testing Apple Color Emoji font `typst --fonts` outputicomoon Apple Color Emoji Arial Bahnschrift C059 Calibri Cambria Cambria Math Candara Cantarell Comic Sans MS Consolas Constantia Corbel Courier New D050000L FontAwesome Franklin Gothic FreeMono FreeSans FreeSerif Gabriola Georgia Impact Ink Free JetBrains Mono JetBrains Mono NL JetBrainsMono Nerd Font JetBrainsMono Nerd Font Mono JetBrainsMonoNL Nerd Font JetBrainsMonoNL Nerd Font Mono Liberation Mono Liberation Sans Liberation Serif Lucida Console Lucida Sans Unicode Marlett Microsoft Sans Serif Nimbus Mono PS Nimbus Roman Nimbus Sans Noto Color Emoji Noto Fangsong KSS Rotated Noto Fangsong KSS Vertical Noto Looped Thai Noto Music Noto Naskh Arabic Noto Naskh Arabic UI Noto Nastaliq Urdu Noto Rashi Hebrew Noto Sans Noto Sans Adlam Noto Sans Adlam Unjoined Noto Sans Anatolian Hieroglyphs Noto Sans Arabic Noto Sans Armenian Noto Sans Avestan Noto Sans Balinese Noto Sans Bamum Noto Sans Bassa Vah Noto Sans Batak Noto Sans Bengali Noto Sans Bengali UI Noto Sans Bhaiksuki Noto Sans Brahmi Noto Sans Buginese Noto Sans Buhid Noto Sans Canadian Aboriginal Noto Sans Carian Noto Sans Caucasian Albanian Noto Sans Chakma Noto Sans Cham Noto Sans Cherokee Noto Sans Chorasmian Noto Sans CJK HK Noto Sans CJK JP Noto Sans CJK KR Noto Sans CJK SC Noto Sans CJK TC Noto Sans Coptic Noto Sans Cuneiform Noto Sans Cypriot Noto Sans Cypro Minoan Noto Sans Deseret Noto Sans Devanagari Noto Sans Devanagari UI Noto Sans Duployan Noto Sans Egyptian Hieroglyphs Noto Sans Elbasan Noto Sans Elymaic Noto Sans Ethiopic Noto Sans Georgian Noto Sans Glagolitic Noto Sans Gothic Noto Sans Grantha Noto Sans Gujarati Noto Sans Gujarati UI Noto Sans Gunjala Gondi Noto Sans Gurmukhi Noto Sans Gurmukhi UI Noto Sans Hanifi Rohingya Noto Sans Hanunoo Noto Sans Hatran Noto Sans Hebrew Noto Sans Imperial Aramaic Noto Sans Indic Siyaq Numbers Noto Sans Inscriptional Pahlavi Noto Sans Inscriptional Parthian Noto Sans Javanese Noto Sans Kaithi Noto Sans Kannada Noto Sans Kannada UI Noto Sans Kayah Li Noto Sans Kharoshthi Noto Sans Khmer Noto Sans Khojki Noto Sans Khudawadi Noto Sans Lao Noto Sans Lao Looped Noto Sans Lepcha Noto Sans Limbu Noto Sans Linear A Noto Sans Linear B Noto Sans Lisu Noto Sans Lycian Noto Sans Lydian Noto Sans Mahajani Noto Sans Malayalam Noto Sans Malayalam UI Noto Sans Mandaic Noto Sans Manichaean Noto Sans Marchen Noto Sans Masaram Gondi Noto Sans Math Noto Sans Mayan Numerals Noto Sans Medefaidrin Noto Sans Meetei Mayek Noto Sans Mende Kikakui Noto Sans Meroitic Noto Sans Miao Noto Sans Modi Noto Sans Mongolian Noto Sans Mono Noto Sans Mono CJK HK Noto Sans Mono CJK JP Noto Sans Mono CJK KR Noto Sans Mono CJK SC Noto Sans Mono CJK TC Noto Sans Mro Noto Sans Multani Noto Sans Myanmar Noto Sans Nabataean Noto Sans Nandinagari Noto Sans New Tai Lue Noto Sans Newa Noto Sans NKo Noto Sans Nushu Noto Sans Ogham Noto Sans Ol Chiki Noto Sans Old Noto Sans Old Hungarian Noto Sans Old North Arabian Noto Sans Old Permic Noto Sans Old Persian Noto Sans Old Sogdian Noto Sans Old South Arabian Noto Sans Old Turkic Noto Sans Oriya Noto Sans Osage Noto Sans Osmanya Noto Sans Pahawh Hmong Noto Sans Palmyrene Noto Sans Pau Cin Hau Noto Sans Phags-Pa Noto Sans Phoenician Noto Sans Psalter Pahlavi Noto Sans Rejang Noto Sans Runic Noto Sans Samaritan Noto Sans Saurashtra Noto Sans Sharada Noto Sans Shavian Noto Sans Siddham Noto Sans SignWriting Noto Sans Sinhala Noto Sans Sinhala UI Noto Sans Sogdian Noto Sans Sora Sompeng Noto Sans Soyombo Noto Sans Sundanese Noto Sans Syloti Nagri Noto Sans Symbols Noto Sans Symbols 2 Noto Sans Syriac Noto Sans Syriac Eastern Noto Sans Syriac Western Noto Sans Tagalog Noto Sans Tagbanwa Noto Sans Tai Le Noto Sans Tai Tham Noto Sans Tai Viet Noto Sans Takri Noto Sans Tamil Noto Sans Tamil Supplement Noto Sans Tamil UI Noto Sans Tangsa Noto Sans Telugu Noto Sans Telugu UI Noto Sans Test Noto Sans Thaana Noto Sans Thai Noto Sans Thai Looped Noto Sans Tifinagh Noto Sans Tifinagh Adrar Noto Sans Tifinagh Agraw Imazighen Noto Sans Tifinagh Ahaggar Noto Sans Tifinagh Air Noto Sans Tifinagh APT Noto Sans Tifinagh Azawagh Noto Sans Tifinagh Ghat Noto Sans Tifinagh Hawad Noto Sans Tifinagh Rhissa Ixa Noto Sans Tifinagh SIL Noto Sans Tifinagh Tawellemmet Noto Sans Tirhuta Noto Sans Ugaritic Noto Sans Vai Noto Sans Vithkuqi Noto Sans Wancho Noto Sans Warang Citi Noto Sans Yi Noto Sans Zanabazar Square Noto Serif Noto Serif Ahom Noto Serif Armenian Noto Serif Balinese Noto Serif Bengali Noto Serif CJK HK Noto Serif CJK JP Noto Serif CJK KR Noto Serif CJK SC Noto Serif CJK TC Noto Serif Devanagari Noto Serif Display Noto Serif Dives Akuru Noto Serif Dogra Noto Serif Ethiopic Noto Serif Georgian Noto Serif Grantha Noto Serif Gujarati Noto Serif Gurmukhi Noto Serif Hebrew Noto Serif Kannada Noto Serif Khitan Small Script Noto Serif Khmer Noto Serif Khojki Noto Serif Lao Noto Serif Makasar Noto Serif Malayalam Noto Serif Myanmar Noto Serif NP Hmong Noto Serif Old Uyghur Noto Serif Oriya Noto Serif Sinhala Noto Serif Tamil Noto Serif Tangut Noto Serif Telugu Noto Serif Test Noto Serif Thai Noto Serif Tibetan Noto Serif Toto Noto Serif Vithkuqi Noto Serif Yezidi Noto Traditional Nushu octicons P052 Palatino Linotype Pomodoro Segoe Fluent Icons Segoe MDL2 Assets Segoe Print Segoe Script Segoe UI Segoe UI Emoji Segoe UI Historic Segoe UI Symbol Segoe UI Variable Sitka Text Source Code Pro Source Code Variable Standard Symbols PS Sylfaen Symbol Tahoma Times New Roman Trebuchet MS URW Bookman URW Gothic Verdana Webdings Wingdings Z003input.typ
|
@MarioD8 please wrap that code in a details element https://developer.mozilla.org/docs/Web/HTML/Element/details you are making it difficult to scroll for anyone that visits this page |
Emoji fonts aren't correctly exported at the moment. There may also be unrelated font issues at play here. |
Any way for us to provide verbose logs? I'm running into what I think is this issue on my Mac.
|
With the help of new bing, I found a relevant answer: https://community.adobe.com/t5/acrobat-discussions/emoji-in-adobe-pdf/m-p/10148090#M121259. According to this answer, the reason for the emoji display problem may be that the PDF specification does not support SVG format fonts. The answer also points out two ways to solve this problem(if the reason is correct):
I hope this information is helpful to everyone! |
Is there an already planned fix for this, or is the fix still unclear? For me emojis have been "working" minimally with Twitter Color Emoji: only a grayscale outline is exported in PDFs. |
The planned fix is to export them as XObjects with |
Glad to hear this, thanks 😃 |
I'm not sure why there is no visual progress on this issue, so I wanted to share something that could help solve the problem quicker. About half a year ago LibreOffice's latest version was 7.4 which didn't support emoji characters in PDF files. But I've read that in v7.5 it should be fixed. https://wiki.documentfoundation.org/ReleaseNotes/7.5#Filters:
I recently upgraded my LO suite and sure enough, the bug is gone, finally! But I don't really use LO Writer (typesetting systems FTW). Still, if that project resolved the same issue that this project has, then the solution is out there. Here is a simple example (using v7.6.0.3): emoji.zip
Okular says that emoji has a type "Type 3", so Type 3 is fine. Although I don't know if it's bad or not, because the emoji is copying fine into the clipboard (and different font types is still a heavy/new topic for me). |
Mostly because we just didn't have time to implement this yet. Thanks for the resources about how LibreOffice does it. This might come in handy. |
FWIW, I have done both approaches before, XObjects in luaotfload (for luatex) and Type 3 in LibreOffice. XObjects work fine, but text copying was a proplem with CDBT table (old Noto Color Emoji) as these fonts have no outline glyphs and |
Thanks, that's good information! |
As a workaround, I wrote a package svg-emoji to replace emoji with an SVG glyps directly. For now, it only offers Noto support. |
As discussed on Discord, here is some background on color fonts and Typst's PDF font handling and then the steps required to fix this issue. A bit of background on color fontsOpenType supports multiple formats for encoding emoji fonts. The data for each of these is stored in OpenType tables within the font. We can query this data with ttf-parser. The following color formats exist:
The inner workings of these OpenType tables is mostly abstracted away by ttf-parser, but it's still important to know how they work conceptually. How Typst writes text and fonts into PDFsWithin The CIDs reference a font configured via the So, this is how it works for normal fonts. The problem now is that PDF viewers completely ignore the color tables in emoji fonts and fall back to normal outlines (if available). To get emojis to show up, we have two different options:
Based on the conversation above and what other tools do, Type 3 seem like the better approach. Relevant details can be found in the PDF 1.7 specification section 9.5.6. "Type 3 fonts". Implementing it in TypstHere's a rough outline of the steps involved in implementing emoji handling for PDF in Typst:
|
Damn, all I wanted was a little 🐿️, turns out it's Specs War Infinity Edition |
@elegaanz thanks a lot for this crucial feature! |
Not sure if I'm missing something, but this still doesn't work for me. A file containing simply:
Produces the text with a gap where the emoji should be. Do I need to specify a special font? I'm just using whatever the default is when I run Any help would be appreciated! |
I'm not sure compiler has an emoji font, so if you don't have one installed locally, then this probably is the issue. Another one is that you didn't compile the latest version as it only would work correctly in the next 0.12 version. |
Thanks for that! I had version 0.11.1 installed and upgrading to the git head ( Edit: It appears that the VS Code extension, Typst LSP, uses a bundled version of the Typst compiler, so upgrading the Typst CLI doesn't fix the automatic build on save output. |
I can confirm that upgrading to the git head (brew install --HEAD typst) fixed the problem for me as well ... hello emoji! Thank you @Andrew15-5 and @davystrong. Perfect timing for a project that I am working on. |
Note that you can now download the v0.12.0-rc1 or wait for a bit and use an upcoming v0.12.0. |
The only way it works for me on current Linux (with Typst v0.12.0) in the VSCode Preview is font "Noto Emoji". The emojis are black-white and do not look as good as the original emoji images. Color Emoji fonts that I tested were not working. Is there any other font confirmed to be working on Linux in the VSCode Preview? |
@krisutofu This is a problem with the VS Code extension's preview. It uses its own rendering mechanism, which does not seem to support emojis so far. If you export the PDF, it should be all good. |
Amazing, it works in the exported PDF. Thank you so much. Typst for the win. |
Hi,
I've just cloned the repo and compiled it. After compiling that document, I've a blank page (using Evince) or some tofu (using Firefox):
#emoji.face.grin
The generated PDF is 10MB big, with the Noto Color Emoji font embedded. When changing the zoom level, Evince writes
some font thing failed
to stderr.System: Ubuntu 22.04, cargo 1.68.0, typst 045a109
The text was updated successfully, but these errors were encountered: