1 --- xpdf/Catalog.cc.orig 2010-05-18 11:22:18.000000000 -0700
2 +++ xpdf/Catalog.cc 2010-05-18 11:22:18.000000000 -0700
5 error(-1, "Kids object (page %d) is wrong type (%s)",
6 start+1, kids.getTypeName());
10 for (i = 0; i < kids.arrayGetLength(); ++i) {
11 kids.arrayGetNF(i, &kidRef);
12 --- xpdf/CharCodeToUnicode.cc.orig 2010-05-18 11:22:18.000000000 -0700
13 +++ xpdf/CharCodeToUnicode.cc 2010-05-18 11:22:18.000000000 -0700
17 char tok1[256], tok2[256], tok3[256];
18 - int nDigits, n1, n2, n3;
19 + int maxCode, n1, n2, n3;
21 CharCode code1, code2;
25 - nDigits = nBits / 4;
26 + maxCode = (nBits == 8) ? 0xff : (nBits == 16) ? 0xffff : 0xffffffff;
27 pst = new PSTokenizer(getCharFunc, data);
28 pst->getToken(tok1, sizeof(tok1), &n1);
29 while (pst->getToken(tok2, sizeof(tok2), &n2)) {
31 error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
34 - if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
35 + if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
36 tok2[0] == '<' && tok2[n2 - 1] == '>')) {
37 - error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
38 + error(-1, "Illegal entry in bfchar block in ToUnicode CMap.");
41 tok1[n1 - 1] = tok2[n2 - 1] = '\0';
43 error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
46 + if (code1 > maxCode) {
47 + error(-1, "Invalid entry in bfchar block in ToUnicode CMap");
49 addMapping(code1, tok2 + 1, n2 - 2, 0);
51 pst->getToken(tok1, sizeof(tok1), &n1);
53 error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
56 - if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
57 - n2 == 2 + nDigits && tok2[0] == '<' && tok2[n2 - 1] == '>')) {
58 + if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
59 + tok2[0] == '<' && tok2[n2 - 1] == '>')) {
60 error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
64 error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
67 + if (code1 > maxCode || code2 > maxCode) {
68 + error(-1, "Invalid entry in bfrange block in ToUnicode CMap");
71 if (!strcmp(tok3, "[")) {
73 while (pst->getToken(tok1, sizeof(tok1), &n1) &&
74 --- xpdf/CoreOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
75 +++ xpdf/CoreOutputDev.cc 2010-05-18 11:22:18.000000000 -0700
78 void CoreOutputDev::clear() {
81 + startPage(0, NULL, 0,0,0,0);
83 --- xpdf/Decrypt.cc.orig 2010-05-18 11:22:18.000000000 -0700
84 +++ xpdf/Decrypt.cc 2010-05-18 11:22:18.000000000 -0700
89 + if(!n || n>16) n=16;
90 for (i = 15; i >= n; --i) {
91 s->buf[i] = s->buf[i-n];
93 --- xpdf/Gfx.cc.orig 2010-05-18 11:22:18.000000000 -0700
94 +++ xpdf/Gfx.cc 2010-05-18 11:22:18.000000000 -0700
99 - out->startPage(pageNum, state);
101 + out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
103 + out->startPage(pageNum, state, 0,0,0,0);
105 out->setDefaultCTM(state->getCTM());
106 out->updateAll(state);
107 for (i = 0; i < 6; ++i) {
109 abortCheckCbkData = abortCheckCbkDataA;
114 state->moveTo(cropBox->x1, cropBox->y1);
115 state->lineTo(cropBox->x2, cropBox->y1);
123 Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
124 @@ -3182,8 +3188,11 @@
125 u, (int)(sizeof(u) / sizeof(Unicode)), &uLen,
126 &dx, &dy, &originX, &originY);
127 dx = dx * state->getFontSize() + state->getCharSpace();
128 - if (n == 1 && *p == ' ') {
129 - dx += state->getWordSpace();
130 + if (n == 1 && (*p == ' ' || *p == 0)) {
131 + double w=state->getWordSpace();
133 + w=state->getFontSize()/3; // workaround for zero word space
136 dx *= state->getHorizScaling();
137 dy *= state->getFontSize();
138 @@ -3476,11 +3485,13 @@
141 if (!obj1.isNull()) {
142 - colorSpace = GfxColorSpace::parse(&obj1);
143 + colorSpace = GfxColorSpace::parse(&obj1, csMode);
144 } else if (csMode == streamCSDeviceGray) {
145 colorSpace = new GfxDeviceGrayColorSpace();
146 } else if (csMode == streamCSDeviceRGB) {
147 colorSpace = new GfxDeviceRGBColorSpace();
148 + } else if (csMode == streamCSDeviceRGBX) {
149 + colorSpace = new GfxDeviceRGBXColorSpace();
150 } else if (csMode == streamCSDeviceCMYK) {
151 colorSpace = new GfxDeviceCMYKColorSpace();
153 @@ -3824,6 +3835,7 @@
154 out->beginTransparencyGroup(state, bbox, blendingColorSpace,
155 isolated, knockout, softMask);
157 + GfxState*old_state = state;
159 // set new base matrix
160 for (i = 0; i < 6; ++i) {
161 @@ -3835,6 +3847,9 @@
162 display(str, gFalse);
164 if (softMask || transpGroup) {
165 + // restore graphics state
166 + while(state != old_state)
168 out->endTransparencyGroup(state);
171 --- xpdf/GfxFont.cc.orig 2010-05-18 11:22:18.000000000 -0700
172 +++ xpdf/GfxFont.cc 2010-05-18 11:22:18.000000000 -0700
177 +CharCodeToUnicode* Gfx8BitFont::getCTU() {
181 CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
184 @@ -1411,6 +1415,10 @@
188 +CharCodeToUnicode* GfxCIDFont::getCTU() {
192 int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
193 Unicode *u, int uSize, int *uLen,
194 double *dx, double *dy, double *ox, double *oy) {
195 --- xpdf/GfxFont.h.orig 2010-05-18 11:22:18.000000000 -0700
196 +++ xpdf/GfxFont.h 2010-05-18 11:22:18.000000000 -0700
198 virtual int getNextChar(char *s, int len, CharCode *code,
199 Unicode *u, int uSize, int *uLen,
200 double *dx, double *dy, double *ox, double *oy) = 0;
201 + virtual CharCodeToUnicode* getCTU() = 0;
206 virtual int getNextChar(char *s, int len, CharCode *code,
207 Unicode *u, int uSize, int *uLen,
208 double *dx, double *dy, double *ox, double *oy);
209 + virtual CharCodeToUnicode* getCTU();
211 // Return the encoding.
212 char **getEncoding() { return enc; }
214 CharCodeToUnicode *getToUnicode();
216 // Return the character name associated with <code>.
217 - char *getCharName(int code) { return enc[code]; }
218 + char *getCharName(int code) { return code>=256?0:enc[code]; }
220 // Returns true if the PDF font specified an encoding.
221 GBool getHasEncoding() { return hasEncoding; }
223 virtual int getNextChar(char *s, int len, CharCode *code,
224 Unicode *u, int uSize, int *uLen,
225 double *dx, double *dy, double *ox, double *oy);
226 + virtual CharCodeToUnicode* getCTU();
228 // Return the writing mode (0=horizontal, 1=vertical).
229 virtual int getWMode();
230 --- xpdf/GfxState.cc.orig 2010-05-18 11:22:18.000000000 -0700
231 +++ xpdf/GfxState.cc 2010-05-18 11:22:18.000000000 -0700
235 #include "GfxState.h"
238 //------------------------------------------------------------------------
241 GfxColorSpace::~GfxColorSpace() {
244 -GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
245 +GfxColorSpace *GfxColorSpace::parse(Object *csObj, StreamColorSpaceMode csMode) {
250 if (csObj->isName("DeviceGray") || csObj->isName("G")) {
251 cs = new GfxDeviceGrayColorSpace();
252 } else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) {
253 - cs = new GfxDeviceRGBColorSpace();
254 + if(csMode == streamCSDeviceRGBX)
255 + cs = new GfxDeviceRGBXColorSpace();
257 + cs = new GfxDeviceRGBColorSpace();
258 } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) {
259 cs = new GfxDeviceCMYKColorSpace();
260 } else if (csObj->isName("Pattern")) {
262 if (obj1.isName("DeviceGray") || obj1.isName("G")) {
263 cs = new GfxDeviceGrayColorSpace();
264 } else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) {
265 - cs = new GfxDeviceRGBColorSpace();
266 + if(csMode == streamCSDeviceRGBX)
267 + cs = new GfxDeviceRGBColorSpace();
269 + cs = new GfxDeviceRGBColorSpace();
270 } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) {
271 cs = new GfxDeviceCMYKColorSpace();
272 } else if (obj1.isName("CalGray")) {
276 //------------------------------------------------------------------------
277 +// GfxDeviceRGBXColorSpace
278 +//------------------------------------------------------------------------
280 +GfxDeviceRGBXColorSpace::GfxDeviceRGBXColorSpace() {
283 +GfxColorSpace *GfxDeviceRGBXColorSpace::copy() {
284 + return new GfxDeviceRGBXColorSpace();
287 +//------------------------------------------------------------------------
288 // GfxCalRGBColorSpace
289 //------------------------------------------------------------------------
292 - 0.11 * color->c[2] + 0.5));
295 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
296 + unsigned char r,g,b;
297 + float c = color->c[0];
298 + float m = color->c[1];
299 + float y = color->c[2];
300 + float k = color->c[3];
301 + convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
307 void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
308 double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
310 @@ -3187,6 +3217,7 @@
311 GfxIndexedColorSpace *indexedCS;
312 GfxSeparationColorSpace *sepCS;
313 int maxPixel, indexHigh;
314 + int maxPixelForAlloc;
318 @@ -3199,6 +3230,7 @@
319 // bits per component and color space
321 maxPixel = (1 << bits) - 1;
322 + maxPixelForAlloc = (1 << (bits>8?bits:8));
323 colorSpace = colorSpaceA;
326 @@ -3253,7 +3285,7 @@
327 lookup2 = indexedCS->getLookup();
328 colorSpace2->getDefaultRanges(x, y, indexHigh);
329 for (k = 0; k < nComps2; ++k) {
330 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
331 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
332 sizeof(GfxColorComp));
333 for (i = 0; i <= maxPixel; ++i) {
334 j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
335 @@ -3272,7 +3304,7 @@
336 nComps2 = colorSpace2->getNComps();
337 sepFunc = sepCS->getFunc();
338 for (k = 0; k < nComps2; ++k) {
339 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
340 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
341 sizeof(GfxColorComp));
342 for (i = 0; i <= maxPixel; ++i) {
343 x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
344 @@ -3282,7 +3314,7 @@
347 for (k = 0; k < nComps; ++k) {
348 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
349 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
350 sizeof(GfxColorComp));
351 for (i = 0; i <= maxPixel; ++i) {
352 lookup[k][i] = dblToCol(decodeLow[k] +
353 @@ -3754,7 +3786,10 @@
356 void GfxState::setPath(GfxPath *pathA) {
364 --- xpdf/GfxState.h.orig 2010-05-18 11:22:18.000000000 -0700
365 +++ xpdf/GfxState.h 2010-05-18 11:22:18.000000000 -0700
367 virtual GfxColorSpaceMode getMode() = 0;
369 // Construct a color space. Returns NULL if unsuccessful.
370 - static GfxColorSpace *parse(Object *csObj);
371 + static GfxColorSpace *parse(Object *csObj, StreamColorSpaceMode csMode = streamCSNone);
373 // Convert to gray, RGB, or CMYK.
374 virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
378 //------------------------------------------------------------------------
379 +// GfxDeviceRGBXColorSpace
380 +//------------------------------------------------------------------------
382 +class GfxDeviceRGBXColorSpace: public GfxDeviceRGBColorSpace {
385 + GfxDeviceRGBXColorSpace();
386 + virtual GfxColorSpace *copy();
387 + virtual int getNComps() { return 4; }
391 +//------------------------------------------------------------------------
392 // GfxCalRGBColorSpace
393 //------------------------------------------------------------------------
395 --- xpdf/GlobalParams.cc.orig 2010-05-18 11:22:18.000000000 -0700
396 +++ xpdf/GlobalParams.cc 2010-05-18 11:22:18.000000000 -0700
403 + char* cfgFileName = fileName->getCString();
404 + char* pos1 = strrchr(cfgFileName, '/');
405 + char* pos2 = strrchr(cfgFileName, '\\');
406 + char* p = pos1>pos2?pos1:pos2;
407 + int pos = p ? p-cfgFileName : -1;
408 + GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
412 + path->append('\\');
415 + path->append('\\');
421 + this->path = new GString();
425 while (getLine(buf, sizeof(buf) - 1, f)) {
426 parseLine(buf, fileName, line);
427 @@ -1114,6 +1137,42 @@
428 deleteGList(tokens, GString);
431 +static char is_absolute(char*filename)
433 + int l = strlen(filename);
434 + if(filename[0] == '/' || filename[0] == '\\')
436 + if(l>2 && filename[1]==':' && (filename[2]=='\\' || filename[2]=='/'))
441 +static GString* qualify_filename(GString*path, GString*filename)
443 + GString*fullpath = 0;
444 + char*prefix = "/usr/local/share/xpdf/";
446 + if (!is_absolute(filename->getCString())) {
447 + /* relative path */
448 + fullpath = path->copy();
449 + fullpath->append(filename);
450 + } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
451 + /* xpdf default path */
452 + char*s = strchr(filename->getCString()+strlen(prefix), '/');
454 + fullpath = path->copy();
455 + fullpath->append(s+1);
457 + fullpath = filename->copy();
460 + /* absolute path */
461 + fullpath = filename->copy();
463 + //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
467 void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
470 @@ -1128,10 +1187,10 @@
471 fileName->getCString(), line);
474 - name = (GString *)tokens->get(1);
475 + name = qualify_filename(this->path, (GString *)tokens->get(1));
476 if (!(f = fopen(name->getCString(), "r"))) {
477 - error(-1, "Couldn't open 'nameToUnicode' file '%s'",
478 - name->getCString());
479 + error(-1, "Couldn't open 'nameToUnicode' file '%s' using path '%s'",
480 + name->getCString(), path->getCString());
484 @@ -1160,10 +1219,12 @@
486 collection = (GString *)tokens->get(1);
487 name = (GString *)tokens->get(2);
489 if ((old = (GString *)cidToUnicodes->remove(collection))) {
492 - cidToUnicodes->add(collection->copy(), name->copy());
494 + cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
497 void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
498 @@ -1180,7 +1241,8 @@
499 if ((old = (GString *)unicodeToUnicodes->remove(font))) {
502 - unicodeToUnicodes->add(font->copy(), file->copy());
504 + unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
507 void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
508 @@ -1197,7 +1259,8 @@
509 if ((old = (GString *)unicodeMaps->remove(encodingName))) {
512 - unicodeMaps->add(encodingName->copy(), name->copy());
514 + unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
517 void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
518 @@ -1215,23 +1278,30 @@
520 cMapDirs->add(collection->copy(), list);
522 - list->append(dir->copy());
524 + list->append(qualify_filename(this->path, dir));
527 void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
531 if (tokens->getLength() != 2) {
532 error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
533 fileName->getCString(), line);
536 - toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
538 + dir = (GString *)tokens->get(1);
540 + toUnicodeDirs->append(qualify_filename(this->path, dir));
543 void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
544 DisplayFontParamKind kind,
545 GString *fileName, int line) {
546 DisplayFontParam *param, *old;
549 if (tokens->getLength() < 2) {
551 @@ -1243,13 +1313,15 @@
552 if (tokens->getLength() != 3) {
555 - param->t1.fileName = ((GString *)tokens->get(2))->copy();
556 + file = (GString *)tokens->get(2);
557 + param->t1.fileName = qualify_filename(this->path, file);
560 if (tokens->getLength() != 3) {
563 - param->tt.fileName = ((GString *)tokens->get(2))->copy();
564 + file = (GString *)tokens->get(2);
565 + param->tt.fileName = qualify_filename(this->path, file);
569 --- xpdf/GlobalParams.h.orig 2010-05-18 11:22:18.000000000 -0700
570 +++ xpdf/GlobalParams.h 2010-05-18 11:22:18.000000000 -0700
573 GlobalParams(char *cfgFileName);
576 + virtual ~GlobalParams();
578 void setBaseDir(char *dir);
579 void setupBaseFonts(char *dir);
581 FILE *getUnicodeMapFile(GString *encodingName);
582 FILE *findCMapFile(GString *collection, GString *cMapName);
583 FILE *findToUnicodeFile(GString *name);
584 - DisplayFontParam *getDisplayFont(GString *fontName);
585 - DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
586 + virtual DisplayFontParam *getDisplayFont(GString *fontName);
587 + virtual DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
588 GString *getPSFile();
589 int getPSPaperWidth();
590 int getPSPaperHeight();
594 void createDefaultKeyBindings();
595 - void parseFile(GString *fileName, FILE *f);
596 +public: void parseFile(GString *fileName, FILE *f); private:
597 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
598 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
599 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
601 GBool loadPlugin(char *type, char *name);
604 + //----- config file base path
608 //----- static tables
610 NameToCharCode * // mapping from char name to
611 --- xpdf/JBIG2Stream.cc.orig 2010-05-18 11:22:18.000000000 -0700
612 +++ xpdf/JBIG2Stream.cc 2010-05-18 11:22:18.000000000 -0700
613 @@ -1514,11 +1514,14 @@
616 // compute symbol code length
618 - i = (numInputSyms + numNewSyms) >> 1;
624 + while (i < numInputSyms + numNewSyms) {
628 + if (huff && symCodeLen == 0) {
632 // get the input symbol bitmaps
633 @@ -1921,6 +1924,9 @@
637 + if (huff && symCodeLen == 0) {
641 // get the symbol bitmaps
642 syms = (JBIG2Bitmap **)gmallocn(numSyms, sizeof(JBIG2Bitmap *));
643 --- xpdf/JPXStream.cc.orig 2010-05-18 11:22:18.000000000 -0700
644 +++ xpdf/JPXStream.cc 2010-05-18 11:22:18.000000000 -0700
646 GBool haveBPC, haveCSMode;
648 csPrec = 0; // make gcc happy
649 + Guint num_components = 0;
650 haveBPC = haveCSMode = gFalse;
652 if (str->lookChar() == 0xff) {
655 if (readULong(&dummy) &&
657 - readUWord(&dummy) &&
658 + readUWord(&num_components) &&
666 + if(*csMode == streamCSDeviceRGB && num_components == 4) {
667 + *csMode = streamCSDeviceRGBX;
672 --- xpdf/Lexer.cc.orig 2010-05-18 11:22:18.000000000 -0700
673 +++ xpdf/Lexer.cc 2010-05-18 11:22:18.000000000 -0700
675 curStr.streamReset();
678 +static int illegalChars = 0;
681 if (!curStr.isNone()) {
687 + error(0, "Illegal characters in hex string (%d)", illegalChars);
691 int Lexer::getChar() {
693 } else if (c2 >= 'a' && c2 <= 'f') {
696 - error(getPos(), "Illegal digit in hex char in name");
698 + //error(getPos(), "Illegal digit in hex char in name");
704 else if (c >= 'a' && c <= 'f')
707 - error(getPos(), "Illegal character <%02x> in hex string", c);
710 + //error(getPos(), "Illegal character <%02x> in hex string", c);
713 if (n == tokBufSize) {
717 obj->initCmd(tokBuf);
719 - error(getPos(), "Illegal character '>'");
721 + //error(getPos(), "Illegal character '>'");
729 - error(getPos(), "Illegal character '%c'", c);
730 + //error(getPos(), "Illegal character '%c'", c);
743 --- xpdf/Link.cc.orig 2010-05-18 11:22:18.000000000 -0700
744 +++ xpdf/Link.cc 2010-05-18 11:22:18.000000000 -0700
752 - error(-1, "Illegal annotation destination");
753 + error(-1, "Illegal annotation destination %d", destObj->getType());
764 - error(-1, "Illegal annotation destination");
765 + error(-1, "Illegal annotation destination %d", destObj->getType());
769 --- xpdf/OutputDev.h.orig 2010-05-18 11:22:18.000000000 -0700
770 +++ xpdf/OutputDev.h 2010-05-18 11:22:18.000000000 -0700
774 #include "CharTypes.h"
783 - virtual void startPage(int pageNum, GfxState *state) {}
784 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
787 virtual void endPage() {}
788 --- xpdf/SplashFTFont.cc.orig 2010-05-18 11:22:18.000000000 -0700
789 +++ xpdf/SplashFTFont.cc 2010-05-18 11:22:18.000000000 -0700
793 face = fontFileA->face;
795 if (FT_New_Size(face, &sizeObj)) {
799 if (FT_Set_Pixel_Sizes(face, 0, (int)size)) {
803 + this->ascender = face->ascender;
804 + this->descender = face->descender;
806 // if the textMat values are too small, FreeType's fixed point
807 // arithmetic doesn't work so well
808 textScale = splashSqrt(textMat[2]*textMat[2] + textMat[3]*textMat[3]) / size;
813 +int SplashFTFont::getNumChars()
815 + SplashFTFontFile* ff = (SplashFTFontFile *)fontFile;
816 + return ff->face->num_glyphs;
819 SplashPath *SplashFTFont::getGlyphPath(int c) {
820 static FT_Outline_Funcs outlineFuncs = {
821 #if FREETYPE_MINOR <= 1
826 + this->last_advance = -1;
828 ff = (SplashFTFontFile *)fontFile;
829 ff->face->size = sizeObj;
830 FT_Set_Transform(ff->face, &textMatrix, NULL);
831 @@ -262,17 +275,24 @@
832 // skip the TrueType notdef glyph
835 - if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) {
837 + if ((error=FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP|FT_LOAD_NO_HINTING))) {
838 + fprintf(stderr, "Truetype wasn't able to load glyph %d, error %d\n", gid, error);
841 if (FT_Get_Glyph(slot, &glyph)) {
844 + this->last_advance = glyph->advance.x/65536.0;
846 path.path = new SplashPath();
847 path.textScale = textScale;
848 path.needClose = gFalse;
849 - FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
850 + error = FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
851 &outlineFuncs, &path);
853 + fprintf(stderr, "Truetype wasn't able to read glyph %d, error %d\n", gid, error);
855 if (path.needClose) {
858 --- xpdf/SplashFTFont.h.orig 2010-05-18 11:22:18.000000000 -0700
859 +++ xpdf/SplashFTFont.h 2010-05-18 11:22:18.000000000 -0700
861 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
862 SplashGlyphBitmap *bitmap);
864 + // return the number of characters in this font
865 + virtual int getNumChars();
867 // Return the path for a glyph.
868 virtual SplashPath *getGlyphPath(int c);
870 --- xpdf/SplashFTFontEngine.cc.orig 2010-05-18 11:22:18.000000000 -0700
871 +++ xpdf/SplashFTFontEngine.cc 2010-05-18 11:22:18.000000000 -0700
882 --- xpdf/SplashFont.cc.orig 2010-05-18 11:22:18.000000000 -0700
883 +++ xpdf/SplashFont.cc 2010-05-18 11:22:18.000000000 -0700
887 xMin = yMin = xMax = yMax = 0;
894 void SplashFont::initCache() {
895 --- xpdf/SplashFont.h.orig 2010-05-18 11:22:18.000000000 -0700
896 +++ xpdf/SplashFont.h 2010-05-18 11:22:18.000000000 -0700
898 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
899 SplashGlyphBitmap *bitmap) = 0;
901 + // return the number of characters in this font
902 + virtual int getNumChars() = 0;
904 // Return the path for a glyph.
905 virtual SplashPath *getGlyphPath(int c) = 0;
908 void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
909 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
913 + double last_advance; //set after getGlyphPath()
916 SplashFontFile *fontFile;
917 --- xpdf/SplashFontFile.cc.orig 2010-05-18 11:22:18.000000000 -0700
918 +++ xpdf/SplashFontFile.cc 2010-05-18 11:22:18.000000000 -0700
924 -# include <unistd.h>
928 #include "SplashFontFile.h"
929 #include "SplashFontFileID.h"
930 --- xpdf/SplashOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
931 +++ xpdf/SplashOutputDev.cc 2010-05-18 11:22:18.000000000 -0700
939 #include "GlobalParams.h"
944 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
945 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
949 @@ -2646,9 +2647,9 @@
951 softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
952 1, splashModeMono8, gFalse);
953 - memset(softMask->getDataPtr(), 0,
954 - softMask->getRowSize() * softMask->getHeight());
955 + memset(softMask->getDataPtr(), 0x00, softMask->getRowSize()*softMask->getHeight());
956 p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;
957 + if (tx<softMask->getWidth() && ty<softMask->getHeight())
958 for (y = 0; y < tBitmap->getHeight(); ++y) {
959 for (x = 0; x < tBitmap->getWidth(); ++x) {
960 tBitmap->getPixel(x, y, color);
961 --- xpdf/SplashOutputDev.h.orig 2010-05-18 11:22:18.000000000 -0700
962 +++ xpdf/SplashOutputDev.h 2010-05-18 11:22:18.000000000 -0700
964 //----- initialization and control
967 - virtual void startPage(int pageNum, GfxState *state);
968 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
971 virtual void endPage();
973 virtual void setVectorAntialias(GBool vaa);
976 + void doUpdateFont(GfxState *state);
978 + SplashPath *convertPath(GfxState *state, GfxPath *path);
981 void setupScreenParams(double hDPI, double vDPI);
984 SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
986 - SplashPath *convertPath(GfxState *state, GfxPath *path);
987 - void doUpdateFont(GfxState *state);
988 void drawType3Glyph(T3FontCache *t3Font,
989 T3FontCacheTag *tag, Guchar *data);
990 static GBool imageMaskSrc(void *data, SplashColorPtr line);
991 --- xpdf/SplashScreen.cc.orig 2010-05-18 11:22:18.000000000 -0700
992 +++ xpdf/SplashScreen.cc 2010-05-18 11:22:18.000000000 -0700
994 int SplashScreen::test(int x, int y, Guchar value) {
999 if (value < minVal) {
1002 --- xpdf/SplashXPathScanner.cc.orig 2010-05-18 11:22:18.000000000 -0700
1003 +++ xpdf/SplashXPathScanner.cc 2010-05-18 11:22:18.000000000 -0700
1004 @@ -394,10 +394,10 @@
1008 - for (; xx + 7 <= xx0; xx += 8) {
1009 + for (; xx + 7 < xx0; xx += 8) {
1014 *p &= 0xff >> (xx0 & 7);
1017 @@ -417,10 +417,10 @@
1021 - for (; xx + 7 <= xx0; xx += 8) {
1022 + for (; xx + 7 < xx0; xx += 8) {
1027 *p &= 0xff >> (xx0 & 7);
1030 --- xpdf/Stream.cc.orig 2010-05-18 11:22:18.000000000 -0700
1031 +++ xpdf/Stream.cc 2010-05-18 11:22:18.000000000 -0700
1037 +extern "C" int unlink(char *filename);
1041 --- xpdf/Stream.h.orig 2010-05-18 11:22:18.000000000 -0700
1042 +++ xpdf/Stream.h 2010-05-18 11:22:18.000000000 -0700
1047 - streamCSDeviceCMYK
1048 + streamCSDeviceCMYK,
1049 + streamCSDeviceRGBX
1052 //------------------------------------------------------------------------
1053 --- xpdf/TextOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
1054 +++ xpdf/TextOutputDev.cc 2010-05-18 11:22:18.000000000 -0700
1055 @@ -3877,7 +3877,7 @@
1059 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
1060 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
1061 text->startPage(state);
1064 --- xpdf/TextOutputDev.h.orig 2010-05-18 11:22:18.000000000 -0700
1065 +++ xpdf/TextOutputDev.h 2010-05-18 11:22:18.000000000 -0700
1067 friend class TextFlow;
1068 friend class TextWordList;
1069 friend class TextPage;
1070 + friend class XMLOutputDev;
1073 //------------------------------------------------------------------------
1075 //----- initialization and control
1078 - virtual void startPage(int pageNum, GfxState *state);
1079 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
1082 virtual void endPage();
1083 --- xpdf/gfile.cc.orig 2010-05-18 11:22:18.000000000 -0700
1084 +++ xpdf/gfile.cc 2010-05-18 11:22:18.000000000 -0700
1085 @@ -439,6 +439,52 @@
1089 +static char* getTempDir()
1092 + char*dir = getenv("TMP");
1093 + if(!dir) dir = getenv("TEMP");
1094 + if(!dir) dir = getenv("tmp");
1095 + if(!dir) dir = getenv("temp");
1096 + if(!dir) dir = "C:\\";
1098 + char* dir = "/tmp/";
1103 +char* mktmpname(char*ptr) {
1104 + static char tmpbuf[128];
1105 + char*dir = getTempDir();
1106 + int l = strlen(dir);
1110 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
1118 + // used to be mktemp. This does remove the warnings, but
1119 + // It's not exactly an improvement.
1120 +#ifdef HAVE_LRAND48
1121 + sprintf(ptr, "%s%s%08x%08x",dir,sep,(unsigned int)lrand48(),(unsigned int)lrand48());
1124 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
1126 + static int count = 1;
1127 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
1135 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
1137 //---------- Win32 ----------
1140 t = (int)time(NULL);
1141 for (i = 0; i < 1000; ++i) {
1142 - sprintf(buf, "%d", t + i);
1143 + sprintf(buf, "%08x-%08x", t + i, GetCurrentThreadId());
1144 s2 = s->copy()->append(buf);
1148 if (!(f2 = fopen(s2->getCString(), "r"))) {
1149 if (!(f2 = fopen(s2->getCString(), mode))) {
1161 + fprintf(stderr, "Couldn't create temporary file\n");
1164 #elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS)
1166 // with this file name after the tmpnam call and before the fopen
1167 // call. I will happily accept fixes to this function for non-Unix
1169 - if (!(s = tmpnam(NULL))) {
1170 + if (!(s = mktmpname(NULL))) {
1173 *name = new GString(s);
1175 (*name)->append("/XXXXXX")->append(ext);
1176 fd = mkstemps((*name)->getCString(), strlen(ext));
1178 - if (!(s = tmpnam(NULL))) {
1179 + if (!(s = mktmpname(NULL))) {
1182 *name = new GString(s);
1184 (*name)->append("/XXXXXX");
1185 fd = mkstemp((*name)->getCString());
1186 #else // HAVE_MKSTEMP
1187 - if (!(s = tmpnam(NULL))) {
1188 + if (!(s = mktmpname(NULL))) {
1191 *name = new GString(s);
1192 --- xpdf/gfile.h.orig 2010-05-18 11:22:18.000000000 -0700
1193 +++ xpdf/gfile.h 2010-05-18 11:22:18.000000000 -0700
1195 // Get current directory.
1196 extern GString *getCurrentDir();
1198 +/* create a temporary filename */
1199 +char* mktmpname(char*ptr);
1201 // Append a file name to a path string. <path> may be an empty
1202 // string, denoting the current directory). Returns <path>.
1203 extern GString *appendToPath(GString *path, char *fileName);