pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1836285 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
Date Thu, 19 Jul 2018 17:53:29 GMT
Author: tilman
Date: Thu Jul 19 17:53:29 2018
New Revision: 1836285

URL: http://svn.apache.org/viewvc?rev=1836285&view=rev
Log:
PDFBOX-4268: ignore barcode font if we aren't searching for one

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java?rev=1836285&r1=1836284&r2=1836285&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
Thu Jul 19 17:53:29 2018
@@ -560,6 +560,14 @@ final class FontMapperImpl implements Fo
                 PDPanoseClassification panose = fontDescriptor.getPanose().getPanose();
                 if (panose.getFamilyKind() == info.getPanose().getFamilyKind())
                 {
+                    if (panose.getFamilyKind() == 0 && 
+                        (info.getPostScriptName().toLowerCase().contains("barcode") ||
+                         info.getPostScriptName().startsWith("Code")) && 
+                        !probablyBarcodeFont(fontDescriptor))
+                    {
+                        // PDFBOX-4268: ignore barcode font if we aren't searching for one.
+                        continue;
+                    }
                     // serifs
                     if (panose.getSerifStyle() == info.getPanose().getSerifStyle())
                     {
@@ -624,6 +632,22 @@ final class FontMapperImpl implements Fo
         return queue;
     }
 
+    private boolean probablyBarcodeFont(PDFontDescriptor fontDescriptor)
+    {
+        String ff = fontDescriptor.getFontFamily();
+        if (ff == null)
+        {
+            ff = "";
+        }
+        String fn = fontDescriptor.getFontName();
+        if (fn == null)
+        {
+            fn = "";
+        }
+        return ff.startsWith("Code") || ff.toLowerCase().contains("barcode") ||
+               fn.startsWith("Code") || fn.toLowerCase().contains("barcode");
+    }
+
     /**
      * Returns true if the character set described by CIDSystemInfo is present in the given
font.
      * Only applies to Adobe-GB1, Adobe-CNS1, Adobe-Japan1, Adobe-Korea1, as per the PDF
spec.



Mime
View raw message