2 ===================================================================
3 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Gfx.cc,v
4 retrieving revision 1.9
5 retrieving revision 1.10
7 --- Gfx.cc 3 Dec 2005 10:11:33 -0000 1.9
8 +++ Gfx.cc 3 Dec 2005 10:30:41 -0000 1.10
13 - out->startPage(pageNum, state);
15 + out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
17 + out->startPage(pageNum, state, 0,0,0,0);
19 out->setDefaultCTM(state->getCTM());
20 out->updateAll(state);
21 for (i = 0; i < 6; ++i) {
23 abortCheckCbkData = abortCheckCbkDataA;
29 state->moveTo(cropBox->x1, cropBox->y1);
30 state->lineTo(cropBox->x2, cropBox->y1);
31 state->lineTo(cropBox->x2, cropBox->y2);
41 Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
43 ===================================================================
44 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxFont.h,v
45 retrieving revision 1.6
46 retrieving revision 1.7
48 --- GfxFont.h 3 Dec 2005 10:11:33 -0000 1.6
49 +++ GfxFont.h 3 Dec 2005 10:30:41 -0000 1.7
51 CharCodeToUnicode *getToUnicode();
53 // Return the character name associated with <code>.
54 - char *getCharName(int code) { return enc[code]; }
55 + char *getCharName(int code) { return code>=256?0:enc[code]; }
57 // Returns true if the PDF font specified an encoding.
58 GBool getHasEncoding() { return hasEncoding; }
60 ===================================================================
61 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxState.cc,v
62 retrieving revision 1.10
63 retrieving revision 1.12
65 --- GfxState.cc 3 Dec 2005 10:11:33 -0000 1.10
66 +++ GfxState.cc 3 Dec 2005 12:41:32 -0000 1.12
73 //------------------------------------------------------------------------
76 - 0.11 * color->c[2] + 0.5));
79 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
80 + unsigned char r,g,b;
81 + float c = color->c[0];
82 + float m = color->c[1];
83 + float y = color->c[2];
84 + float k = color->c[3];
85 + convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
91 void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
92 double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
95 GfxIndexedColorSpace *indexedCS;
96 GfxSeparationColorSpace *sepCS;
97 int maxPixel, indexHigh;
98 + int maxPixelForAlloc;
102 @@ -3111,6 +3125,7 @@
103 // bits per component and color space
105 maxPixel = (1 << bits) - 1;
106 + maxPixelForAlloc = (1 << (bits>8?bits:8));
107 colorSpace = colorSpaceA;
110 @@ -3163,7 +3178,7 @@
111 lookup2 = indexedCS->getLookup();
112 colorSpace2->getDefaultRanges(x, y, indexHigh);
113 for (k = 0; k < nComps2; ++k) {
114 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
115 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
116 sizeof(GfxColorComp));
117 for (i = 0; i <= maxPixel; ++i) {
118 j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
119 @@ -3182,7 +3197,7 @@
120 nComps2 = colorSpace2->getNComps();
121 sepFunc = sepCS->getFunc();
122 for (k = 0; k < nComps2; ++k) {
123 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
124 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
125 sizeof(GfxColorComp));
126 for (i = 0; i <= maxPixel; ++i) {
127 x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
128 @@ -3192,7 +3207,7 @@
131 for (k = 0; k < nComps; ++k) {
132 - lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
133 + lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
134 sizeof(GfxColorComp));
135 for (i = 0; i <= maxPixel; ++i) {
136 lookup[k][i] = dblToCol(decodeLow[k] +
137 @@ -3754,7 +3769,10 @@
140 void GfxState::setPath(GfxPath *pathA) {
148 Index: GlobalParams.cc
149 ===================================================================
150 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.cc,v
151 retrieving revision 1.4
152 retrieving revision 1.7
154 --- GlobalParams.cc 3 Dec 2005 10:11:33 -0000 1.4
155 +++ GlobalParams.cc 18 Dec 2005 08:31:22 -0000 1.7
162 + char* cfgFileName = fileName->getCString();
163 + char* pos1 = strrchr(cfgFileName, '/');
164 + char* pos2 = strrchr(cfgFileName, '\\');
165 + char* p = pos1>pos2?pos1:pos2;
166 + int pos = p ? p-cfgFileName : -1;
167 + GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
171 + path->append('\\');
174 + path->append('\\');
180 + this->path = new GString();
184 while (getLine(buf, sizeof(buf) - 1, f)) {
186 @@ -1142,6 +1165,42 @@
187 deleteGList(tokens, GString);
190 +static char is_absolute(char*filename)
192 + int l = strlen(filename);
193 + if(filename[0] == '/' || filename[0] == '\\')
195 + if(l>2 && filename[1]==':' && (filename[2]=='\\' || filename[2]=='/'))
200 +static GString* qualify_filename(GString*path, GString*filename)
202 + GString*fullpath = 0;
203 + char*prefix = "/usr/local/share/xpdf/";
205 + if (!is_absolute(filename->getCString())) {
206 + /* relative path */
207 + fullpath = path->copy();
208 + fullpath->append(filename);
209 + } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
210 + /* xpdf default path */
211 + char*s = strchr(filename->getCString()+strlen(prefix), '/');
213 + fullpath = path->copy();
214 + fullpath->append(s+1);
216 + fullpath = filename->copy();
219 + /* absolute path */
220 + fullpath = filename->copy();
222 + //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
226 void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
229 @@ -1156,10 +1215,10 @@
230 fileName->getCString(), line);
233 - name = (GString *)tokens->get(1);
234 + name = qualify_filename(this->path, (GString *)tokens->get(1));
235 if (!(f = fopen(name->getCString(), "r"))) {
236 - error(-1, "Couldn't open 'nameToUnicode' file '%s'",
237 - name->getCString());
238 + error(-1, "Couldn't open 'nameToUnicode' file '%s' using path '%s'",
239 + name->getCString(), path->getCString());
243 @@ -705,10 +754,12 @@
245 collection = (GString *)tokens->get(1);
246 name = (GString *)tokens->get(2);
248 if ((old = (GString *)cidToUnicodes->remove(collection))) {
251 - cidToUnicodes->add(collection->copy(), name->copy());
253 + cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
256 void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
258 if ((old = (GString *)unicodeToUnicodes->remove(font))) {
261 - unicodeToUnicodes->add(font->copy(), file->copy());
263 + unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
266 void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
268 if ((old = (GString *)unicodeMaps->remove(encodingName))) {
271 - unicodeMaps->add(encodingName->copy(), name->copy());
273 + unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
276 void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
277 @@ -760,23 +813,30 @@
279 cMapDirs->add(collection->copy(), list);
281 - list->append(dir->copy());
283 + list->append(qualify_filename(this->path, dir));
286 void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
290 if (tokens->getLength() != 2) {
291 error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
292 fileName->getCString(), line);
295 - toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
297 + dir = (GString *)tokens->get(1);
299 + toUnicodeDirs->append(qualify_filename(this->path, dir));
302 void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
303 DisplayFontParamKind kind,
304 GString *fileName, int line) {
305 DisplayFontParam *param, *old;
308 if (tokens->getLength() < 2) {
310 @@ -788,13 +848,15 @@
311 if (tokens->getLength() != 3) {
314 - param->t1.fileName = ((GString *)tokens->get(2))->copy();
315 + file = (GString *)tokens->get(2);
316 + param->t1.fileName = qualify_filename(this->path, file);
319 if (tokens->getLength() != 3) {
322 - param->tt.fileName = ((GString *)tokens->get(2))->copy();
323 + file = (GString *)tokens->get(2);
324 + param->tt.fileName = qualify_filename(this->path, file);
329 ===================================================================
330 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
331 retrieving revision 1.4
332 retrieving revision 1.5
334 --- Lexer.cc 3 Dec 2005 10:11:33 -0000 1.4
335 +++ Lexer.cc 14 Mar 2006 12:43:23 -0000 1.5
337 curStr.streamReset();
340 +static int illegalChars = 0;
343 if (!curStr.isNone()) {
349 + error(0, "Illegal characters in hex string (%d)", illegalChars);
353 int Lexer::getChar() {
355 } else if (c2 >= 'a' && c2 <= 'f') {
358 - error(getPos(), "Illegal digit in hex char in name");
360 + //error(getPos(), "Illegal digit in hex char in name");
366 else if (c >= 'a' && c <= 'f')
369 - error(getPos(), "Illegal character <%02x> in hex string", c);
372 + //error(getPos(), "Illegal character <%02x> in hex string", c);
375 if (n == tokBufSize) {
379 obj->initCmd(tokBuf);
381 - error(getPos(), "Illegal character '>'");
383 + //error(getPos(), "Illegal character '>'");
391 - error(getPos(), "Illegal character '%c'", c);
392 + //error(getPos(), "Illegal character '%c'", c);
406 ===================================================================
407 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
408 retrieving revision 1.5
409 retrieving revision 1.6
411 --- Link.cc 3 Dec 2005 10:11:33 -0000 1.5
412 +++ Link.cc 26 Mar 2006 08:26:59 -0000 1.6
420 - error(-1, "Illegal annotation destination");
421 + error(-1, "Illegal annotation destination %d", destObj->getType());
432 - error(-1, "Illegal annotation destination");
433 + error(-1, "Illegal annotation destination %d", destObj->getType());
438 ===================================================================
439 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
440 retrieving revision 1.7
441 retrieving revision 1.9
443 --- OutputDev.h 3 Dec 2005 10:11:33 -0000 1.7
444 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000 1.9
446 virtual void setDefaultCTM(double *ctm);
449 - virtual void startPage(int pageNum, GfxState *state) {}
450 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
453 virtual void endPage() {}
455 ===================================================================
456 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
457 retrieving revision 1.7
458 retrieving revision 1.8
460 --- Stream.cc 3 Dec 2005 10:11:33 -0000 1.7
461 +++ Stream.cc 3 Dec 2005 10:30:41 -0000 1.8
467 +extern "C" int unlink(char *filename);
472 ===================================================================
473 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
474 retrieving revision 1.9
475 retrieving revision 1.10
477 --- gfile.h 3 Dec 2005 10:11:33 -0000 1.9
478 +++ gfile.h 3 Dec 2005 10:30:41 -0000 1.10
480 // Get current directory.
481 extern GString *getCurrentDir();
483 +/* create a temporary filename */
484 +char* mktmpname(char*ptr);
486 // Append a file name to a path string. <path> may be an empty
487 // string, denoting the current directory). Returns <path>.
488 extern GString *appendToPath(GString *path, char *fileName);
489 Index: GlobalParams.h
490 ===================================================================
491 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
492 retrieving revision 1.5
493 retrieving revision 1.6
495 --- GlobalParams.h 2006-10-10 19:54:29.000000000 +0200
496 +++ GlobalParams.h 2006-11-12 11:19:40.000000000 +0100
498 FILE *getUnicodeMapFile(GString *encodingName);
499 FILE *findCMapFile(GString *collection, GString *cMapName);
500 FILE *findToUnicodeFile(GString *name);
501 - DisplayFontParam *getDisplayFont(GString *fontName);
502 - DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
503 + virtual DisplayFontParam *getDisplayFont(GString *fontName);
504 + virtual DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
505 GString *getPSFile();
506 int getPSPaperWidth();
507 int getPSPaperHeight();
509 - void parseFile(GString *fileName, FILE *f);
510 +public: void parseFile(GString *fileName, FILE *f); private:
512 GBool loadPlugin(char *type, char *name);
515 + //----- config file base path
519 //----- static tables
521 NameToCharCode * // mapping from char name to
522 --- SplashOutputDev.h 2006-11-12 12:07:22.000000000 +0100
523 +++ SplashOutputDev.h 2006-11-12 12:08:48.000000000 +0100
525 //----- initialization and control
528 - virtual void startPage(int pageNum, GfxState *state);
529 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
532 virtual void endPage();
533 --- TextOutputDev.cc 2006-11-12 12:22:53.000000000 +0100
534 +++ TextOutputDev.cc 2006-11-12 12:25:03.000000000 +0100
535 @@ -3805,7 +3805,7 @@
539 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
540 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
541 text->startPage(state);
544 --- CoreOutputDev.cc 2006-11-12 12:21:59.000000000 +0100
545 +++ CoreOutputDev.cc 2006-11-12 12:23:29.000000000 +0100
548 void CoreOutputDev::clear() {
550 - startPage(0, NULL);
551 + startPage(0, NULL, 0,0,0,0);
553 --- SplashFTFontEngine.cc 2006-11-19 22:30:44.000000000 +0100
554 +++ SplashFTFontEngine.cc 2006-11-19 22:30:56.000000000 +0100
565 --- SplashOutputDev.cc 2007-09-09 12:29:45.000000000 +0200
566 +++ SplashOutputDev.cc 2007-09-09 12:30:02.000000000 +0200
574 #include "GlobalParams.h"
579 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
580 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
584 @@ -2646,9 +2647,9 @@
586 softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
587 1, splashModeMono8, gFalse);
588 - memset(softMask->getDataPtr(), 0,
589 - softMask->getRowSize() * softMask->getHeight());
590 + memset(softMask->getDataPtr(), 0x00, softMask->getRowSize()*softMask->getHeight());
591 p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;
592 + if (tx<softMask->getWidth() && ty<softMask->getHeight())
593 for (y = 0; y < tBitmap->getHeight(); ++y) {
594 for (x = 0; x < tBitmap->getWidth(); ++x) {
595 tBitmap->getPixel(x, y, color);
596 --- SplashFontFile.cc 2007-09-09 12:33:00.000000000 +0200
597 +++ SplashFontFile.cc 2007-09-09 12:33:07.000000000 +0200
603 -# include <unistd.h>
607 #include "SplashFontFile.h"
608 #include "SplashFontFileID.h"
609 --- xpdf/SplashFont.h.orig 2008-09-09 21:31:01.000000000 +0200
610 +++ xpdf/SplashFont.h 2008-10-05 17:36:44.000000000 +0200
612 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
613 SplashGlyphBitmap *bitmap) = 0;
615 + // return the number of characters in this font
616 + virtual int getNumChars() = 0;
618 // Return the path for a glyph.
619 virtual SplashPath *getGlyphPath(int c) = 0;
622 void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
623 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
627 + double last_advance; //set after getGlyphPath()
630 SplashFontFile *fontFile;
631 --- orig/GfxFont.h 2007-07-28 00:11:06.000000000 +0200
632 +++ GfxFont.h 2007-09-09 18:31:31.000000000 +0200
634 virtual int getNextChar(char *s, int len, CharCode *code,
635 Unicode *u, int uSize, int *uLen,
636 double *dx, double *dy, double *ox, double *oy) = 0;
637 + virtual CharCodeToUnicode* getCTU() = 0;
642 virtual int getNextChar(char *s, int len, CharCode *code,
643 Unicode *u, int uSize, int *uLen,
644 double *dx, double *dy, double *ox, double *oy);
645 + virtual CharCodeToUnicode* getCTU();
647 // Return the encoding.
648 char **getEncoding() { return enc; }
650 virtual int getNextChar(char *s, int len, CharCode *code,
651 Unicode *u, int uSize, int *uLen,
652 double *dx, double *dy, double *ox, double *oy);
653 + virtual CharCodeToUnicode* getCTU();
655 // Return the writing mode (0=horizontal, 1=vertical).
656 virtual int getWMode();
657 --- orig/GfxFont.cc 2007-07-28 00:11:06.000000000 +0200
658 +++ GfxFont.cc 2007-09-09 18:33:37.000000000 +0200
663 +CharCodeToUnicode* Gfx8BitFont::getCTU() {
667 CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
670 @@ -1417,6 +1421,10 @@
674 +CharCodeToUnicode* GfxCIDFont::getCTU() {
678 int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
679 Unicode *u, int uSize, int *uLen,
680 double *dx, double *dy, double *ox, double *oy) {
681 --- OutputDev.h Sat Jul 28 00:11:08 2007
682 +++ OutputDev.h Sun Sep 9 13:50:40 2007
686 #include "CharTypes.h"
691 --- SplashOutputDev.h 2007-10-20 13:17:02.000000000 +0200
692 +++ SplashOutputDev.h 2007-10-20 13:17:23.000000000 +0200
694 virtual void setVectorAntialias(GBool vaa);
697 + void doUpdateFont(GfxState *state);
700 void setupScreenParams(double hDPI, double vDPI);
702 SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
704 SplashPath *convertPath(GfxState *state, GfxPath *path);
705 - void doUpdateFont(GfxState *state);
706 void drawType3Glyph(T3FontCache *t3Font,
707 T3FontCacheTag *tag, Guchar *data);
708 static GBool imageMaskSrc(void *data, SplashColorPtr line);
709 --- xpdf/GlobalParams.h 2007-10-20 13:18:03.000000000 +0200
710 +++ xpdf/GlobalParams.h 2007-10-20 13:25:52.000000000 +0200
713 GlobalParams(char *cfgFileName);
716 + virtual ~GlobalParams();
718 void setBaseDir(char *dir);
719 void setupBaseFonts(char *dir);
720 --- xpdf/SplashOutputDev.h.orig 2007-10-21 17:43:29.000000000 +0200
721 +++ xpdf/SplashOutputDev.h 2007-11-19 10:07:27.000000000 +0100
725 void doUpdateFont(GfxState *state);
727 + SplashPath *convertPath(GfxState *state, GfxPath *path);
730 void setupScreenParams(double hDPI, double vDPI);
733 SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
735 - SplashPath *convertPath(GfxState *state, GfxPath *path);
736 void drawType3Glyph(T3FontCache *t3Font,
737 T3FontCacheTag *tag, Guchar *data);
738 static GBool imageMaskSrc(void *data, SplashColorPtr line);
739 --- xpdf/SplashFont.cc.orig 2008-09-09 21:31:01.000000000 +0200
740 +++ xpdf/SplashFont.cc 2008-10-05 17:37:08.000000000 +0200
744 xMin = yMin = xMax = yMax = 0;
751 void SplashFont::initCache() {
752 --- xpdf/SplashFTFont.cc.orig 2009-03-08 17:19:08.000000000 +0100
753 +++ xpdf/SplashFTFont.cc 2009-03-15 19:18:11.000000000 +0100
757 face = fontFileA->face;
759 if (FT_New_Size(face, &sizeObj)) {
763 if (FT_Set_Pixel_Sizes(face, 0, (int)size)) {
767 + this->ascender = face->ascender;
768 + this->descender = face->descender;
770 // if the textMat values are too small, FreeType's fixed point
771 // arithmetic doesn't work so well
772 textScale = splashSqrt(textMat[2]*textMat[2] + textMat[3]*textMat[3]) / size;
777 +int SplashFTFont::getNumChars()
779 + SplashFTFontFile* ff = (SplashFTFontFile *)fontFile;
780 + return ff->face->num_glyphs;
783 SplashPath *SplashFTFont::getGlyphPath(int c) {
784 static FT_Outline_Funcs outlineFuncs = {
785 #if FREETYPE_MINOR <= 1
790 + this->last_advance = -1;
792 ff = (SplashFTFontFile *)fontFile;
793 ff->face->size = sizeObj;
794 FT_Set_Transform(ff->face, &textMatrix, NULL);
795 @@ -262,17 +275,24 @@
796 // skip the TrueType notdef glyph
799 - if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) {
801 + if ((error=FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP|FT_LOAD_NO_HINTING))) {
802 + fprintf(stderr, "Truetype wasn't able to load glyph %d, error %d\n", gid, error);
805 if (FT_Get_Glyph(slot, &glyph)) {
808 + this->last_advance = glyph->advance.x/65536.0;
810 path.path = new SplashPath();
811 path.textScale = textScale;
812 path.needClose = gFalse;
813 - FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
814 + error = FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
815 &outlineFuncs, &path);
817 + fprintf(stderr, "Truetype wasn't able to read glyph %d, error %d\n", gid, error);
819 if (path.needClose) {
822 --- xpdf/SplashFTFont.h.orig 2008-09-09 21:31:01.000000000 +0200
823 +++ xpdf/SplashFTFont.h 2008-10-04 17:39:57.000000000 +0200
825 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
826 SplashGlyphBitmap *bitmap);
828 + // return the number of characters in this font
829 + virtual int getNumChars();
831 // Return the path for a glyph.
832 virtual SplashPath *getGlyphPath(int c);
834 --- xpdf/SplashScreen.cc.orig 2008-10-06 17:59:44.000000000 +0200
835 +++ xpdf/SplashScreen.cc 2008-10-06 18:20:09.000000000 +0200
837 int SplashScreen::test(int x, int y, Guchar value) {
842 if (value < minVal) {
845 --- xpdf/gfile.cc.orig 2007-02-27 23:05:51.000000000 +0100
846 +++ xpdf/gfile.cc 2008-10-12 15:15:22.000000000 +0200
851 +static char* getTempDir()
854 + char*dir = getenv("TMP");
855 + if(!dir) dir = getenv("TEMP");
856 + if(!dir) dir = getenv("tmp");
857 + if(!dir) dir = getenv("temp");
858 + if(!dir) dir = "C:\\";
860 + char* dir = "/tmp/";
865 +char* mktmpname(char*ptr) {
866 + static char tmpbuf[128];
867 + char*dir = getTempDir();
868 + int l = strlen(dir);
872 + if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
880 + // used to be mktemp. This does remove the warnings, but
881 + // It's not exactly an improvement.
883 + sprintf(ptr, "%s%s%08x%08x",dir,sep,(unsigned int)lrand48(),(unsigned int)lrand48());
886 + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
888 + static int count = 1;
889 + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
897 GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
899 //---------- Win32 ----------
903 for (i = 0; i < 1000; ++i) {
904 - sprintf(buf, "%d", t + i);
905 + sprintf(buf, "%08x-%08x", t + i, GetCurrentThreadId());
906 s2 = s->copy()->append(buf);
910 if (!(f2 = fopen(s2->getCString(), "r"))) {
911 if (!(f2 = fopen(s2->getCString(), mode))) {
923 + fprintf(stderr, "Couldn't create temporary file\n");
926 #elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS)
928 // with this file name after the tmpnam call and before the fopen
929 // call. I will happily accept fixes to this function for non-Unix
931 - if (!(s = tmpnam(NULL))) {
932 + if (!(s = mktmpname(NULL))) {
935 *name = new GString(s);
937 (*name)->append("/XXXXXX")->append(ext);
938 fd = mkstemps((*name)->getCString(), strlen(ext));
940 - if (!(s = tmpnam(NULL))) {
941 + if (!(s = mktmpname(NULL))) {
944 *name = new GString(s);
946 (*name)->append("/XXXXXX");
947 fd = mkstemp((*name)->getCString());
948 #else // HAVE_MKSTEMP
949 - if (!(s = tmpnam(NULL))) {
950 + if (!(s = mktmpname(NULL))) {
953 *name = new GString(s);
954 --- xpdf/Gfx.cc.orig 2009-03-08 17:10:40.000000000 +0100
955 +++ xpdf/Gfx.cc 2009-03-08 17:18:23.000000000 +0100
956 @@ -3188,8 +3188,11 @@
957 u, (int)(sizeof(u) / sizeof(Unicode)), &uLen,
958 &dx, &dy, &originX, &originY);
959 dx = dx * state->getFontSize() + state->getCharSpace();
960 - if (n == 1 && *p == ' ') {
961 - dx += state->getWordSpace();
962 + if (n == 1 && (*p == ' ' || *p == 0)) {
963 + double w=state->getWordSpace();
965 + w=state->getFontSize()/3; // workaround for zero word space
968 dx *= state->getHorizScaling();
969 dy *= state->getFontSize();
970 @@ -3824,6 +3833,7 @@
971 out->beginTransparencyGroup(state, bbox, blendingColorSpace,
972 isolated, knockout, softMask);
974 + GfxState*old_state = state;
976 // set new base matrix
977 for (i = 0; i < 6; ++i) {
978 @@ -3835,6 +3845,9 @@
979 display(str, gFalse);
981 if (softMask || transpGroup) {
982 + // restore graphics state
983 + while(state != old_state)
985 out->endTransparencyGroup(state);
988 --- TextOutputDev.h.orig 2009-10-07 17:00:29.000000000 -0700
989 +++ TextOutputDev.h 2009-10-07 17:01:50.000000000 -0700
991 friend class TextFlow;
992 friend class TextWordList;
993 friend class TextPage;
994 + friend class XMLOutputDev;
997 //------------------------------------------------------------------------
999 //----- initialization and control
1002 - virtual void startPage(int pageNum, GfxState *state);
1003 + virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
1006 virtual void endPage();
1007 --- xpdf/JBIG2Stream.cc.orig 2010-01-08 17:17:18.000000000 -0800
1008 +++ xpdf/JBIG2Stream.cc 2010-01-21 15:28:26.000000000 -0800
1009 @@ -1514,11 +1514,14 @@
1012 // compute symbol code length
1014 - i = (numInputSyms + numNewSyms) >> 1;
1020 + while (i < numInputSyms + numNewSyms) {
1024 + if (huff && symCodeLen == 0) {
1028 // get the input symbol bitmaps
1029 @@ -1921,6 +1924,9 @@
1033 + if (huff && symCodeLen == 0) {
1037 // get the symbol bitmaps
1038 syms = (JBIG2Bitmap **)gmallocn(numSyms, sizeof(JBIG2Bitmap *));
1039 --- xpdf/SplashXPathScanner.cc.orig 2010-01-21 16:00:38.000000000 -0800
1040 +++ xpdf/SplashXPathScanner.cc 2010-01-21 16:10:31.000000000 -0800
1041 @@ -394,10 +394,10 @@
1045 - for (; xx + 7 <= xx0; xx += 8) {
1046 + for (; xx + 7 < xx0; xx += 8) {
1051 *p &= 0xff >> (xx0 & 7);
1054 @@ -417,10 +417,10 @@
1058 - for (; xx + 7 <= xx0; xx += 8) {
1059 + for (; xx + 7 < xx0; xx += 8) {
1064 *p &= 0xff >> (xx0 & 7);
1067 --- xpdf/CharCodeToUnicode.cc.orig 2010-01-25 12:43:00.000000000 -0800
1068 +++ xpdf/CharCodeToUnicode.cc 2010-01-28 14:14:53.000000000 -0800
1069 @@ -208,13 +208,13 @@
1072 char tok1[256], tok2[256], tok3[256];
1073 - int nDigits, n1, n2, n3;
1074 + int maxCode, n1, n2, n3;
1076 CharCode code1, code2;
1080 - nDigits = nBits / 4;
1081 + maxCode = (nBits == 8) ? 0xff : (nBits == 16) ? 0xffff : 0xffffffff;
1082 pst = new PSTokenizer(getCharFunc, data);
1083 pst->getToken(tok1, sizeof(tok1), &n1);
1084 while (pst->getToken(tok2, sizeof(tok2), &n2)) {
1086 error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
1089 - if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
1090 + if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
1091 tok2[0] == '<' && tok2[n2 - 1] == '>')) {
1092 - error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
1093 + error(-1, "Illegal entry in bfchar block in ToUnicode CMap.");
1096 tok1[n1 - 1] = tok2[n2 - 1] = '\0';
1098 error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
1101 + if (code1 > maxCode) {
1102 + error(-1, "Invalid entry in bfchar block in ToUnicode CMap");
1104 addMapping(code1, tok2 + 1, n2 - 2, 0);
1106 pst->getToken(tok1, sizeof(tok1), &n1);
1108 error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
1111 - if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
1112 - n2 == 2 + nDigits && tok2[0] == '<' && tok2[n2 - 1] == '>')) {
1113 + if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
1114 + tok2[0] == '<' && tok2[n2 - 1] == '>')) {
1115 error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
1118 @@ -277,6 +280,10 @@
1119 error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
1122 + if (code1 > maxCode || code2 > maxCode) {
1123 + error(-1, "Invalid entry in bfrange block in ToUnicode CMap");
1126 if (!strcmp(tok3, "[")) {
1128 while (pst->getToken(tok1, sizeof(tok1), &n1) &&
1129 --- xpdf/Decrypt.cc.orig 2010-01-28 14:19:51.000000000 -0800
1130 +++ xpdf/Decrypt.cc 2010-02-02 16:04:53.000000000 -0800
1135 + if(!n || n>16) n=16;
1136 for (i = 15; i >= n; --i) {
1137 s->buf[i] = s->buf[i-n];
1139 --- xpdf/Catalog.cc.orig 2010-02-02 16:17:24.000000000 -0800
1140 +++ xpdf/Catalog.cc 2010-02-02 16:18:48.000000000 -0800
1142 if (!kids.isArray()) {
1143 error(-1, "Kids object (page %d) is wrong type (%s)",
1144 start+1, kids.getTypeName());
1148 for (i = 0; i < kids.arrayGetLength(); ++i) {
1149 kids.arrayGetNF(i, &kidRef);