Fabrice Calafat created PDFBOX-6279:
---------------------------------------

             Summary: Missing ToUnicode entries for glyphs produced by GSUB 
substitutions
                 Key: PDFBOX-6279
                 URL: https://issues.apache.org/jira/browse/PDFBOX-6279
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 3.0.8 PDFBox
            Reporter: Fabrice Calafat
         Attachments: CormorantInfant-Medium.ttf

When text is written with showText() and the font has GSUB ligatures, the 
ligature glyph has no cmap entry, so PDCIDFontType2Embedder writes no ToUnicode 
entry for it. Copy-paste and text extraction then lose those letters.

For example, with a script font that has "er" and "nd" ligatures, "Registered" 
is extracted as "Registed" and "Brandenstein" as "Braenstein". The rendering is 
correct.

The same happens with Devanagari conjuncts and with letters followed by a 
combining accent.

*Solution:*
  When a glyph has no cmap entry, use the GSUB table to find the glyphs it 
replaces and write their text in the ToUnicode map.

*Testing:*
  Unit tests added using Lohit-Devanagari.ttf and the IPA Gothic font 
(ipag.ttf) that is already downloaded for the tests. I've also attached 
CormorantInfant-Medium.ttf (OFL, cut down to ASCII), which has Latin ligatures 
("Th", "ft", "gg") with no cmap entry, if you want a Latin ligature test.

*Related:*
  PDFBOX-5599 (comment about "ti" not being extracted correctly with Calibri)
  PDFBOX-5875 (same idea, on the text extraction side)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to