You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2023/04/30 13:33:31 UTC

svn commit: r1909509 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForBengali.java

Author: tilman
Date: Sun Apr 30 13:33:30 2023
New Revision: 1909509

URL: http://svn.apache.org/viewvc?rev=1909509&view=rev
Log:
PDFBOX-5592: return early if glyph list is empty to avoid weird stuff

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForBengali.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForBengali.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForBengali.java?rev=1909509&r1=1909508&r2=1909509&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForBengali.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForBengali.java Sun Apr 30 13:33:30 2023
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -81,11 +82,11 @@ public class GsubWorkerForBengali implem
         {
             if (!gsubData.isFeatureSupported(feature))
             {
-                LOG.debug("the feature " + feature + " was not found");
+                LOG.info("the feature " + feature + " was not found");
                 continue;
             }
 
-            LOG.debug("applying the feature " + feature);
+            LOG.info("applying the feature " + feature);
 
             ScriptFeature scriptFeature = gsubData.getFeature(feature);
 
@@ -145,9 +146,16 @@ public class GsubWorkerForBengali implem
     private List<Integer> applyGsubFeature(ScriptFeature scriptFeature,
             List<Integer> originalGlyphs)
     {
+        Set<List<Integer>> allGlyphIdsForSubstitution = scriptFeature.getAllGlyphIdsForSubstitution();
+        if (allGlyphIdsForSubstitution.isEmpty())
+        {
+            // not stopping here results in really weird output, the regex goes wild
+            LOG.debug("getAllGlyphIdsForSubstitution() for " + scriptFeature.getName() + " is empty");
+            return originalGlyphs;
+        }
 
         GlyphArraySplitter glyphArraySplitter = new GlyphArraySplitterRegexImpl(
-                scriptFeature.getAllGlyphIdsForSubstitution());
+                allGlyphIdsForSubstitution);
 
         List<List<Integer>> tokens = glyphArraySplitter.split(originalGlyphs);
 
@@ -167,7 +175,7 @@ public class GsubWorkerForBengali implem
             }
         });
 
-        LOG.debug("originalGlyphs: " + originalGlyphs + ", gsubProcessedGlyphs: "
+        LOG.info("originalGlyphs: " + originalGlyphs + ", gsubProcessedGlyphs: "
                 + gsubProcessedGlyphs);
 
         return gsubProcessedGlyphs;