[poppler] poppler/PSOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Dec 30 14:49:26 PST 2008


 poppler/PSOutputDev.cc |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

New commits:
commit 5fb7ec7e6af4cfb2b256a5b9b9752e68330b4aec
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Dec 30 23:46:59 2008 +0100

    If Length2 is zero just write until we find EOF of the stream
    
    Fixes exporting to PS of the two pdf i have that have fonts with Length2 set to 0

diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index ada2b4c..9477762 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -37,6 +37,7 @@
 #include <stdarg.h>
 #include <signal.h>
 #include <math.h>
+#include <limits.h>
 #include "goo/GooString.h"
 #include "goo/GooList.h"
 #include "poppler-config.h"
@@ -1879,6 +1880,7 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
   int c;
   int start[4];
   GBool binMode;
+  GBool writePadding = gTrue;
   int i;
 
   // check if font is already embedded
@@ -1950,6 +1952,17 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
       binMode = gTrue;
   }
 
+  if (length2 == 0)
+  {
+    // length2 == 0 is an error
+    // trying to solve it by just piping all
+    // the stream data
+    error(-1, "Font has length2 as 0, trying to overcome the problem reading the stream until the end");
+    length2 = INT_MAX;
+    writePadding = gFalse;
+  }
+
+
   // convert binary data to ASCII
   if (binMode) {
     for (i = 0; i < 4; ++i) {
@@ -1988,12 +2001,15 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
     }
   }
 
-  // write padding and "cleartomark"
-  for (i = 0; i < 8; ++i) {
-    writePS("00000000000000000000000000000000"
-	    "00000000000000000000000000000000\n");
+  if (writePadding)
+  {
+    // write padding and "cleartomark"
+    for (i = 0; i < 8; ++i) {
+      writePS("00000000000000000000000000000000"
+	      "00000000000000000000000000000000\n");
+    }
+    writePS("cleartomark\n");
   }
-  writePS("cleartomark\n");
 
   // ending comment
   writePS("%%EndResource\n");


More information about the poppler mailing list