Make text in PDF exports extractable - #295
Open
Mythie wants to merge 2 commits into
Open
Conversation
Glyphs substituted via OpenType features aren't reachable through the cmap, so SkPDF's /ToUnicode mapped them to <0000> and extraction dropped them.
`currentColor` was treated as an invalid color, discarding the setting.
Open
samizdatco
added a commit
that referenced
this pull request
Aug 27, 2026
- continue using Paragraph for text-shaping but switch to a TextBlob-based render path - includes each run's utf-8 text along with the glyphs so PDF text is now selectable - implements textDecoration drawing including gaps for descenders (and no longer draws underlines *on top* of the text like Paragraph.paint) - positions text exactly rather than snapping the baseline to the pixel grid - inspired by @Mythie's PR #295
samizdatco
added a commit
that referenced
this pull request
Aug 28, 2026
- continue using Paragraph for text-shaping but switch to a TextBlob-based render path - includes each run's utf-8 text along with the glyphs so PDF text is now selectable - implements textDecoration drawing including gaps for descenders (and no longer draws underlines *on top* of the text like Paragraph.paint) - positions text exactly rather than snapping the baseline to the pixel grid - inspired by @Mythie's PR #295
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.
Text drawn with
fillText()isn't copy/paste-able or searchable in exported PDFs when the shaper substitutes glyphs with no cmap entry (ligatures, stylistic sets):Paragraph::paintemits bare text blobs, so SkPDF builds/ToUnicodeby reverse-cmap lookup and maps substituted glyphs to<0000>.The fix draws the laid-out runs via
drawGlyphswith utf8 & cluster info attached, which SkPDF turns into correct mappings and/ActualTextspans.Rendered output is unchanged. For decorated text, the glyphs are drawn once by the new code path, then
Paragraph::paintis still called so skparagraph draws its underline/overline/strike-through lines. Its own glyph drawing is disabled (via a no-op blend mode) so the text isn't painted twice.The second commit fixes
textDecorationignoring any value without an explicit color (currentColorwas treated as invalid). Happy to drop this commit though since it isn't really relevant to what I'm trying to solve.Both commits add tests that fail on
main. Wrapped, RTL, and ligature text verified withpdftotext.