pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tilman Hausherr (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-4304) Glyph Substitution Table lookup Cache doesn't clear by disabling a feature.
Date Tue, 04 Sep 2018 16:29:00 GMT

    [ https://issues.apache.org/jira/browse/PDFBOX-4304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603285#comment-16603285

Tilman Hausherr commented on PDFBOX-4304:

I think I've now understood the first part. You asking that the cache be reset when features
are disabled or enabled, that makes sense, as long as getUnsubstitution() isn't used "too

The "Beh" is 0x628 in your font, and gid 32. When resetting the cache, the output would be
35 and 34, is that correct? And would that alone be an improvement for you?

Or is the second part (that starts with "And also the cache lookup must be a mapping of three")
also a "must"? I haven't fully understood it. I suspect you mean that there should be some
very smart cache that caches for each combination of input glyph and enabled features.

What I also don't  understand is this "When I enable more than one features only the last
enabled feature will be affected" - from what I see in the code, the gid is passed through
each of the future and the final result is returned.

cc [~amake]

> Glyph Substitution Table lookup Cache doesn't clear by disabling a feature.
> ---------------------------------------------------------------------------
>                 Key: PDFBOX-4304
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4304
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 2.0.11
>            Reporter: Ali Safe
>            Priority: Major
>         Attachments: FDK_aban.ttf
> When I want to use GlyphSubstitutionTable to find the substituted gid for a specific
glyph that have 3 forms of substitutions, I found the same gid for each three forms.
> The font are a Persian font that have 3 substituted forms for some of it's glyphs. I
enabled the 'init', 'medi' and 'fina' features one by one and then disable them. But all of
these give me the same result.
> When I saw the GlyphSubstitutionTable class and getSubstitution(gid, scriptTags, enabledFeatures)
method in it, I saw a lookupCache that first check for gid only, and if the gid existed returns
the result, and if it's not in lookupCache do other parsing and calculations. I think every
time that some features are disabled or enabled, this cache must be cleared. And also the
cache lookup must be a mapping of three of the function input argument, because they are affect
the result of calculations. At least the lookupCache must be a mapping of gid and enabledFeatures.

> And when more than one feature are enabled, the lookup cache maps each gid to only one
substituted glyph, but in many languages there more than one substitutions form for some glyphs.
When I enable more than one features only the last enabled feature will be affected. 
> I used this code and attached the mentioned font file...
>                     // Persian Beh Letter with code 1576 in the font
>                     // Enable init feature
>                     ttf.enableGsubFeature("init");
>                     CmapLookup cMapLookupInit = ttf.getUnicodeCmapLookup();
>                     int glyphIdInit = cMapLookupInit.getGlyphId(1576);
>                     ttf.disableGsubFeature("init");
>                     // Enable medi feature
>                     ttf.enableGsubFeature("medi");
>                     CmapLookup cMapLookupMedi = ttf.getUnicodeCmapLookup();
>                     int glyphIdMedi = cMapLookupMedi.getGlyphId(1576);
>                     ttf.disableGsubFeature("medi");
>                     // Now the glypIdMedi and glyphIdInit have same values...

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org

View raw message