Repository navigation
Conversation
…tutions When showText() applies GSUB substitutions, ligature glyphs such as the "er" and "nd" of a script font, Devanagari conjuncts, and letters with a combining accent are drawn as one glyph that has no cmap entry. The embedder built the ToUnicode map from the cmap only, so these glyphs got no entry and text extraction dropped their letters: "Registered" came out as "Registed". The embedder now maps such a glyph to the text of the glyphs it replaces, read from the font's GSUB table. Only the features that the GSUB workers apply are read, and only substitutions that produce one glyph.
fcalafat
force-pushed
the
fix-ligature-tounicode
branch
from
October 20, 2026 12:53
dd7ba17 to
d8967d4
Compare
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.
When
showText()applies GSUB substitutions, a ligature glyph (like "er" or "nd" in a script font) has no cmap entry, soPDCIDFontType2Embedderwrites no ToUnicode entry for it and text extraction drops those letters: "Registered" is extracted as "Registed".Fix:
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java)ccmp,liga,clig,calt,locland the Indic ones). FiraCode'saaltlists the emptyexclam.spacerglyph as an alternate of "!", which added two "!" to the text extracted inGlyphLayoutLigaturesAndKerningTest.Testing:
Lohit-Devanagari.ttf, and Latin letters with a combining accent with the IPA Gothic font already downloaded for the tests. Both fail without the fix. (pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java)GlyphLayoutLigaturesAndKerningTestin pdfbox-layout-awt.