75a61b
--- poppler-0.26.5/poppler/PSOutputDev.cc
75a61b
+++ poppler-0.26.5/poppler/PSOutputDev.cc
75a61b
@@ -2069,7 +2069,7 @@ void PSOutputDev::setupEmbeddedType1Font
75a61b
   static const char hexChar[17] = "0123456789abcdef";
75a61b
   Object refObj, strObj, obj1, obj2, obj3;
75a61b
   Dict *dict;
75a61b
-  int length1, length2, length3;
75a61b
+  long length1, length2, length3;
75a61b
   int c;
75a61b
   int start[4];
75a61b
   GBool binMode;
75a61b
@@ -2119,8 +2119,18 @@ void PSOutputDev::setupEmbeddedType1Font
75a61b
   embFontList->append(psName->getCString());
75a61b
   embFontList->append("\n");
75a61b
 
75a61b
-  // copy ASCII portion of font
75a61b
   strObj.streamReset();
75a61b
+  if (strObj.streamGetChar() == 0x80 &&
75a61b
+      strObj.streamGetChar() == 1) {
75a61b
+    // PFB format
75a61b
+    length1 = strObj.streamGetChar() |
75a61b
+             (strObj.streamGetChar() << 8) |
75a61b
+             (strObj.streamGetChar() << 16) |
75a61b
+             (strObj.streamGetChar() << 24);
75a61b
+  } else {
75a61b
+    strObj.streamReset();
75a61b
+  }
75a61b
+  // copy ASCII portion of font
75a61b
   for (i = 0; i < length1 && (c = strObj.streamGetChar()) != EOF; ++i) {
75a61b
     writePSChar(c);
75a61b
   }
75a61b
@@ -2153,9 +2163,18 @@ void PSOutputDev::setupEmbeddedType1Font
75a61b
 
75a61b
   // convert binary data to ASCII
75a61b
   if (binMode) {
75a61b
-    for (i = 0; i < 4; ++i) {
75a61b
-      writePSChar(hexChar[(start[i] >> 4) & 0x0f]);
75a61b
-      writePSChar(hexChar[start[i] & 0x0f]);
75a61b
+    if (start[0] == 0x80 &&
75a61b
+        start[1] == 2) {
75a61b
+      length2 = start[2] |
75a61b
+               (start[3] << 8) |
75a61b
+               (strObj.streamGetChar() << 16) |
75a61b
+               (strObj.streamGetChar() << 24);
75a61b
+      i = 0;
75a61b
+    } else {
75a61b
+      for (i = 0; i < 4; ++i) {
75a61b
+        writePSChar(hexChar[(start[i] >> 4) & 0x0f]);
75a61b
+        writePSChar(hexChar[start[i] & 0x0f]);
75a61b
+      }
75a61b
     }
75a61b
 #if 0 // this causes trouble for various PostScript printers
75a61b
     // if Length2 is incorrect (too small), font data gets chopped, so
75a61b
@@ -2193,8 +2212,32 @@ void PSOutputDev::setupEmbeddedType1Font
75a61b
   {
75a61b
     if (length3 > 0) {
75a61b
       // write fixed-content portion
75a61b
-      while ((c = strObj.streamGetChar()) != EOF) {
75a61b
-	writePSChar(c);
75a61b
+      c = strObj.streamGetChar();
75a61b
+      if (c == 0x80) {
75a61b
+        c = strObj.streamGetChar();
75a61b
+        if (c == 1) {
75a61b
+          length3 = strObj.streamGetChar() |
75a61b
+                   (strObj.streamGetChar() << 8) |
75a61b
+                   (strObj.streamGetChar() << 16) |
75a61b
+                   (strObj.streamGetChar() << 24);
75a61b
+
75a61b
+          i = 0;
75a61b
+          while (i < length3) {
75a61b
+            if ((c = strObj.streamGetChar()) == EOF) {
75a61b
+              break;
75a61b
+            }
75a61b
+            writePSChar(c);
75a61b
+            ++i;
75a61b
+          }
75a61b
+        }
75a61b
+      } else {
75a61b
+        if (c != EOF) {
75a61b
+          writePSChar(c);
75a61b
+
75a61b
+          while ((c = strObj.streamGetChar()) != EOF) {
75a61b
+	    writePSChar(c);
75a61b
+	  }
75a61b
+        }
75a61b
       }
75a61b
     } else {
75a61b
       // write padding and "cleartomark"