Michael Aleythe created PDFBOX-6322:
---------------------------------------
Summary: Map AGL underscore ligature names (f_i, f_f_i, …) in
GlyphList.toUnicode()
Key: PDFBOX-6322
URL: https://issues.apache.org/jira/browse/PDFBOX-6322
Project: PDFBox
Issue Type: Improvement
Components: Text extraction
Affects Versions: 3.0.8 PDFBox, 2.0.37
Reporter: Michael Aleythe
Attachments: glyphlist-underscore-trunk.patch
Simple fonts without /ToUnicode whose /Differences name ligature glyphs in the
AGL underscore form (f_f, f_i, f_l,
f_f_i, f_f_l) lose these glyphs in text extraction: GlyphList.toUnicode()
returns null, PDFBox logs
"No Unicode mapping for f_i (31) in font ...", and every word with an
ff/fi/fl/ffi ligature is broken
("Schaffhauser" -> "Schahauser"; Tika writes U+FFFD there).
ISO 32000-1 9.10.2 only guarantees the glyph-name fallback for names from the
Adobe standard Latin character set,
so this is a best-effort improvement, like the existing uniXXXX/uXXXX and
suffix handling. The AGL specification
(https://github.com/adobe-type-tools/agl-specification, section 2) maps such a
name component by component, and its
section 6 recommends this naming for ligatures ("the 'o f f i' ligature should
be named 'o_f_f_i'").
poppler and pdf.js extract these words. Seen before in PDFBOX-3333
(MyriadPro-Bold, f_f_i) and on the mailing
lists (2015 HelveticaNeueLTStd f_i, 2019 Gotham f_f).
Real-world sample, already public: the attachment of TIKA-2054
(2482_2014_DAVIDE+CAMPARI-MILANO+SPA_SUSTY-AR.pdf,
23 pages, Adobe Illustrator CC / Adobe PDF library 10.01, MyriadPro without
/ToUnicode, names f_f f_i f_l f_f_i).
Tika 4.2.0 writes 250 U+FFFD for it. PDFTextStripper on trunk with the patch,
compared with trunk without it:
248 ligature words (49 distinct) come out whole, every one identical to
poppler's output, and no other word changes.
Same comparison on the TIKA-3035 attachment (HelveticaNeueLTStd-Roman f_i): 8
words repaired, all identical to
poppler. The five PDFBOX-3333 attachments (MyriadPro-Bold f_f_i): "Fuel E"
becomes "Fuel Effi"; the word stays
split over lines there because the text is rotated, as without the patch.
Discussed on dev@ (thread "GlyphList: support AGL underscore ligature names
(f_i, f_f_i, …)?", 2026-11-17).
The attached patch adds the underscore rule to GlyphList.toUnicode(): the name
is split at "_" and every component
is mapped with toUnicode() itself, so suffixes (f_f_i.alt) and uniXXXX
components work too. If any component is
empty or unknown, the result stays null (the AGL spec would map an unknown
component to an empty string; null keeps
today's behaviour for names PDFBox cannot resolve). GlyphListTest covers
ligatures, suffix/uni components,
unresolvable names and unchanged existing names. On trunk (c3f801a, 2026-11-17)
`mvn verify` over the whole reactor (13 modules):
2345 tests, 0 failures, 0 errors, 20 skipped; 0 Checkstyle violations.
GlyphList.java on 2.0 and 3.0 has the same gap; the patch applies to 3.0 and
uses only Java 6 APIs.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]