You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Ali Safe (JIRA)" <ji...@apache.org> on 2018/08/29 13:53:00 UTC

[jira] [Created] (PDFBOX-4304) Glyph Substitution Table lookup Cache doesn't clear by disabling a feature.

Ali Safe created PDFBOX-4304:
--------------------------------

             Summary: 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
         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
(v7.6.3#76005)

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