[poppler] poppler/PSOutputDev.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Fri Jul 3 11:14:58 PDT 2015
poppler/PSOutputDev.cc | 57 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 50 insertions(+), 7 deletions(-)
New commits:
commit df09c1a84dfe80d2e6cfde3308c79da5b2ea7428
Author: Marek Kasik <mkasik at redhat.com>
Date: Fri Jul 3 20:14:23 2015 +0200
Embed Type1 fonts to PostScript files correctly
Remove PFB headers from embedded Type1 fonts
before embedding them into a PostScript file.
Bug #19747
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 5dc89be..c701159 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -2122,7 +2122,7 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
static const char hexChar[17] = "0123456789abcdef";
Object refObj, strObj, obj1, obj2, obj3;
Dict *dict;
- int length1, length2, length3;
+ long length1, length2, length3;
int c;
int start[4];
GBool binMode;
@@ -2172,8 +2172,18 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
embFontList->append(psName->getCString());
embFontList->append("\n");
- // copy ASCII portion of font
strObj.streamReset();
+ if (strObj.streamGetChar() == 0x80 &&
+ strObj.streamGetChar() == 1) {
+ // PFB format
+ length1 = strObj.streamGetChar() |
+ (strObj.streamGetChar() << 8) |
+ (strObj.streamGetChar() << 16) |
+ (strObj.streamGetChar() << 24);
+ } else {
+ strObj.streamReset();
+ }
+ // copy ASCII portion of font
for (i = 0; i < length1 && (c = strObj.streamGetChar()) != EOF; ++i) {
writePSChar(c);
}
@@ -2206,9 +2216,18 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
// convert binary data to ASCII
if (binMode) {
- for (i = 0; i < 4; ++i) {
- writePSChar(hexChar[(start[i] >> 4) & 0x0f]);
- writePSChar(hexChar[start[i] & 0x0f]);
+ if (start[0] == 0x80 &&
+ start[1] == 2) {
+ length2 = start[2] |
+ (start[3] << 8) |
+ (strObj.streamGetChar() << 16) |
+ (strObj.streamGetChar() << 24);
+ i = 0;
+ } else {
+ for (i = 0; i < 4; ++i) {
+ writePSChar(hexChar[(start[i] >> 4) & 0x0f]);
+ writePSChar(hexChar[start[i] & 0x0f]);
+ }
}
#if 0 // this causes trouble for various PostScript printers
// if Length2 is incorrect (too small), font data gets chopped, so
@@ -2246,8 +2265,32 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
{
if (length3 > 0) {
// write fixed-content portion
- while ((c = strObj.streamGetChar()) != EOF) {
- writePSChar(c);
+ c = strObj.streamGetChar();
+ if (c == 0x80) {
+ c = strObj.streamGetChar();
+ if (c == 1) {
+ length3 = strObj.streamGetChar() |
+ (strObj.streamGetChar() << 8) |
+ (strObj.streamGetChar() << 16) |
+ (strObj.streamGetChar() << 24);
+
+ i = 0;
+ while (i < length3) {
+ if ((c = strObj.streamGetChar()) == EOF) {
+ break;
+ }
+ writePSChar(c);
+ ++i;
+ }
+ }
+ } else {
+ if (c != EOF) {
+ writePSChar(c);
+
+ while ((c = strObj.streamGetChar()) != EOF) {
+ writePSChar(c);
+ }
+ }
}
} else {
// write padding and "cleartomark"
More information about the poppler
mailing list