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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to