Skip to content

fix(pdf): extract Adobe small capitals as letters - #1200

Merged
andiwand merged 1 commit into
mainfrom
fix/pdf-small-cap-text
Oct 10, 2026
Merged

andiwand merged 1 commit into
mainfrom
fix/pdf-small-cap-text

Conversation

@andiwand

@andiwand andiwand commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #1187

Fonts with glyphs such as Asmall or oneoldstyle map them to Adobe's corporate-use code points (the Adobe Glyph List gives Asmall U+F761, oneoldstyle U+F731). The text layer then held private-use characters, so a search did not find the word and a copy gave unreadable characters.

Change

Adobe's code points U+F721 to U+F7FF mirror ASCII and Latin-1 at U+F700: Asmall U+F761 → a, Agravesmall U+F7E0 → à, zerooldstyle U+F730 → 0. resolve_text in the page extractor folds them back when it turns a shown string into text, as pdf.js does. This changes only the text, so the selection layer and text extraction get the letters. The visual layer draws glyphs, so the rendering stays the same. An author's /ActualText stays as written. Symbol fonts use U+F020 to U+F0FF, so they are not affected.

Verification

  • PdfPageExtractor.adobe_small_caps_extract_as_letters: /Differences to Asmall, Bsmall, oneoldstyle and a plain D gives ab1D. Without the change, the test fails with U+F761 U+F762 U+F731 D.
  • The PDF and html tests pass (471 tests).

Reference output

The private PDF whose title showed the problem changes. I will update the reference output after this PR and the #1188 PR have landed.

Fonts with glyphs such as `Asmall` or `oneoldstyle` map them to Adobe's
corporate-use code points U+F721 to U+F7FF, so the text layer held private-use
characters that no search found and no copy could read. These code points
mirror ASCII and Latin-1 at U+F700. Fold them back when a shown string is
resolved to text, as pdf.js does. The glyphs drawn stay the same.

Fixes #1187

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5yx1nDeVcNX3BxqK1WpJz
@andiwand
andiwand merged commit f854a41 into main Oct 10, 2026
23 checks passed
@andiwand
andiwand deleted the fix/pdf-small-cap-text branch October 10, 2026 09:45
andiwand added a commit that referenced this pull request Oct 10, 2026
The output now masks a JPEG image with its soft mask (#1201), and extracts
Adobe small capitals as letters (#1200).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5yx1nDeVcNX3BxqK1WpJz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pdf: map Adobe small-cap private-use code points to letters in the text layer

1 participant