Repository navigation
Print emoji in PDF exports as pictures (DSK-247) - #636
Merged
Merged
Conversation
jsPDF can't draw a character outside the BMP with any font, so emoji were left out of PDFs, with a notice. The founder chose pictures: each emoji is now drawn as the browser draws it, in colour, one em square on the text's baseline. It isn't selectable or searchable. - Every emoji takes the same width, 1.2 em, so a layout (the export's, Paper Mode's, a test's) wraps the same on every machine. Only drawing needs the pictures; the export makes them first, through OffscreenCanvas, and FallbackDoc draws from the map, one copy of each picture per file. - Text that may hold emoji is split by grapheme cluster, so a family, a flag or a keycap stays one character, in layout and at line breaks. - A symbol a font has, such as (c), stays text. Where there's no canvas (tests), emoji keep their space and are reported, as before. Assisted-by: Opus 5.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The last part of DSK-247. CJK text has printed since #631; emoji were still left out, with a notice. jsPDF can't draw a character outside the BMP with any font, and most emoji live there. The founder chose pictures.
OffscreenCanvas(src/utils/pdfExport/emoji.ts).FallbackDocthen draws from the map, with one copy of each picture per file (alias).Intl.Segmenter), so a family, a flag or a keycap stays one character, in layout and at line breaks.breakOversizedWordsplits by cluster too. For other text, that's the same as before.Verification
emoji.test.ts(6): clusters, which clusters are pictures, gathering, no canvas;fallbackDoc.test.ts, 5 new: pictures on the baseline with joiners kept whole; the fixed width; a missing picture keeps its space and is reported; © stays text; nothing drawn while measuring;lineBreaks.test.ts: a family emoji is never split.PDF_DUMP_DIR.tscis clean; the suite passes 5,629 tests in 518 files. The OSS leak grep is clean.Closes the issue: CJK shipped in #631, and this adds emoji. Complex scripts (Arabic, Hebrew, Indic) are a follow-up in the backlog.
Assisted-by: Opus 5.5