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 2020/05/13 17:37:56 UTC

svn commit: r1877705 - /pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java

Author: tilman
Date: Wed May 13 17:37:56 2020
New Revision: 1877705

URL: http://svn.apache.org/viewvc?rev=1877705&view=rev
Log:
PDFBOX-4828: don't bother with improperly sorted tables as long as the contents aren't trash

Modified:
    pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java

Modified: pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java?rev=1877705&r1=1877704&r2=1877705&view=diff
==============================================================================
--- pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java (original)
+++ pdfbox/branches/issue45/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java Wed May 13 17:37:56 2020
@@ -176,9 +176,19 @@ public class GlyphSubstitutionTable exte
             {
                 // catch corrupt file
                 // https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2#flTbl
-                LOG.warn("FeatureRecord array not alphabetically sorted by FeatureTag: " +
-                           featureRecord.featureTag + " < " + prevFeatureTag);
-                return new FeatureRecord[0];
+                if (featureRecord.featureTag.matches("\\w{4}") && prevFeatureTag.matches("\\w{4}"))
+                {
+                    // ArialUni.ttf has many warnings but isn't corrupt, so we assume that only
+                    // strings with trash characters indicate real corruption
+                    LOG.debug("FeatureRecord array not alphabetically sorted by FeatureTag: " +
+                               featureRecord.featureTag + " < " + prevFeatureTag);
+                }
+                else
+                {
+                    LOG.warn("FeatureRecord array not alphabetically sorted by FeatureTag: " +
+                               featureRecord.featureTag + " < " + prevFeatureTag);
+                    return new FeatureRecord[0];
+                }                
             }
             featureOffsets[i] = data.readUnsignedShort();
             featureRecords[i] = featureRecord;