Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4304

Glyph Substitution Table lookup Cache doesn't clear by disabling a feature.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0.11
    • None
    • FontBox
    • None

    Description

      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...

      Attachments

        1. FDK_aban.ttf
          31 kB
          Ali Safe

        Issue Links

          Activity

            People

              Unassigned Unassigned
              fh4 Ali Safe
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: