[
https://issues.apache.org/jira/browse/PDFBOX-6279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127085#comment-18127085
]
Tilman Hausherr edited comment on PDFBOX-6279 at 10/14/26 12:41 PM:
--------------------------------------------------------------------
I ran your patch against the trunk (I didn't notice that it was against 3.0)
and it doesn't build, because {{ScriptFeature.getReplacementForGlyphs()}}
returns a list of integers. We could of course change this so that the sequence
is used as the key, but this wouldn't help because you're checking for a single
cid. Or only inserting items in the map if the list has a single element:
{code:java}
List<Integer> replacementForGlyphs =
feature.getReplacementForGlyphs(sourceGids);
if (replacementForGlyphs.size() == 1)
{
textByGid.putIfAbsent(replacementForGlyphs.get(0), text);
}
{code}
(I just tested that, the test passes)
was (Author: tilman):
I ran your patch against the trunk (I didn't notice that it was against 3.0)
and it doesn't build, because {{ScriptFeature.getReplacementForGlyphs()}}
returns a list of integers. We could of course change this so that the sequence
is used as the key, but this wouldn't help because you're checking for a single
cid. Or only inserting items in the map if the list has a single element.
> 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
> Priority: Minor
> Fix For: 3.0.9 PDFBox, 4.0.0
>
> 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]