patch for xpdf-3.02 path handling
[swftools.git] / lib / pdf / xpdf-changes.patch
1 Index: Gfx.cc
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
6 diff -u -r1.9 -r1.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
9 @@ -439,7 +439,11 @@
10    fontChanged = gFalse;
11    clip = clipNone;
12    ignoreUndef = 0;
13 -  out->startPage(pageNum, state);
14 +  if(cropBox) {
15 +      out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
16 +  } else {
17 +      out->startPage(pageNum, state, 0,0,0,0);
18 +  }
19    out->setDefaultCTM(state->getCTM());
20    out->updateAll(state);
21    for (i = 0; i < 6; ++i) {
22 @@ -450,7 +450,8 @@
23    abortCheckCbkData = abortCheckCbkDataA;
24  
25    // set crop box
26 -  if (cropBox) {
27 +#ifdef XPDFEXE
28 +  if (cropBox) {
29      state->moveTo(cropBox->x1, cropBox->y1);
30      state->lineTo(cropBox->x2, cropBox->y1);
31      state->lineTo(cropBox->x2, cropBox->y2);
32 @@ -459,7 +460,8 @@
33      state->clip();
34      out->clip(state);
35      state->clearPath();
36 -  }
37 +  }
38 +#endif
39  }
40  
41  Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
42 Index: GfxFont.h
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
47 diff -u -r1.6 -r1.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
50 @@ -207,7 +207,7 @@
51    CharCodeToUnicode *getToUnicode();
52  
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]; }
56  
57    // Returns true if the PDF font specified an encoding.
58    GBool getHasEncoding() { return hasEncoding; }
59 Index: GfxState.cc
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
64 diff -u -r1.10 -r1.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
67 @@ -21,6 +21,7 @@
68  #include "Array.h"
69  #include "Page.h"
70  #include "GfxState.h"
71 +#include "cmyk.h"
72  
73  //------------------------------------------------------------------------
74  
75 @@ -468,6 +469,18 @@
76                                 - 0.11 * color->c[2] + 0.5));
77  }
78  
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);
86 +    rgb->r = r/255.0;
87 +    rgb->g = g/255.0;
88 +    rgb->b = b/255.0;
89 +}*/
90 +
91  void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
92    double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
93  
94 @@ -3099,6 +3112,7 @@
95    GfxIndexedColorSpace *indexedCS;
96    GfxSeparationColorSpace *sepCS;
97    int maxPixel, indexHigh;
98 +  int maxPixelForAlloc;
99    Guchar *lookup2;
100    Function *sepFunc;
101    Object obj;
102 @@ -3111,6 +3125,7 @@
103    // bits per component and color space
104    bits = bitsA;
105    maxPixel = (1 << bits) - 1;
106 +  maxPixelForAlloc = (1 << (bits>8?bits:8));
107    colorSpace = colorSpaceA;
108  
109    // get decode map
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 @@
129      }
130    } else {
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 @@
138  }
139  
140  void GfxState::setPath(GfxPath *pathA) {
141 +  if(pathA) {
142 +      if(path)
143    delete path;
144 +  }
145    path = pathA;
146  }
147
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
153 diff -u -r1.4 -r1.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
156 @@ -498,6 +498,29 @@
157    char buf[512];
158    FILE *f2;
159  
160 +  /* extract path */
161 +  if(fileName) {
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));
168 +    if(pos1>=0)
169 +       path->append('/');
170 +    else if(pos2>=0)
171 +       path->append('\\');
172 +    else
173 +#ifdef WIN32
174 +       path->append('\\');
175 +#else
176 +       path->append('/');
177 +#endif
178 +    this->path = path;
179 +  } else {
180 +    this->path = new GString();
181 +  }
182 +  
183    line = 1;
184    while (getLine(buf, sizeof(buf) - 1, f)) {
185  
186 @@ -1142,6 +1165,42 @@
187    deleteGList(tokens, GString);
188  }
189  
190 +static char is_absolute(char*filename)
191 +{
192 +    int l = strlen(filename);
193 +    if(filename[0] == '/' || filename[0] == '\\') 
194 +       return 1;
195 +    if(l>2 && filename[1]==':' && (filename[2]=='\\' || filename[2]=='/'))
196 +       return 1;
197 +    return 0;
198 +}
199 +
200 +static GString* qualify_filename(GString*path, GString*filename)
201 +{
202 +  GString*fullpath = 0;
203 +  char*prefix = "/usr/local/share/xpdf/";
204 +
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), '/');
212 +    if(s) {
213 +       fullpath = path->copy();
214 +       fullpath->append(s+1);
215 +    } else {
216 +       fullpath = filename->copy();
217 +    }
218 +  } else {
219 +    /* absolute path */
220 +    fullpath = filename->copy();
221 +  }
222 +  //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
223 +  return fullpath;
224 +}
225 +
226  void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
227                                          int line) {
228    GString *name;
229 @@ -1156,10 +1215,10 @@
230           fileName->getCString(), line);
231      return;
232    }
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());
240      return;
241    }
242    line2 = 1;
243 @@ -705,10 +754,12 @@
244    }
245    collection = (GString *)tokens->get(1);
246    name = (GString *)tokens->get(2);
247 +
248    if ((old = (GString *)cidToUnicodes->remove(collection))) {
249      delete old;
250    }
251 -  cidToUnicodes->add(collection->copy(), name->copy());
252 +
253 +  cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
254  }
255  
256  void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
257 @@ -725,7 +776,8 @@
258    if ((old = (GString *)unicodeToUnicodes->remove(font))) {
259      delete old;
260    }
261 -  unicodeToUnicodes->add(font->copy(), file->copy());
262 +
263 +  unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
264  }
265  
266  void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
267 @@ -742,7 +794,8 @@
268    if ((old = (GString *)unicodeMaps->remove(encodingName))) {
269      delete old;
270    }
271 -  unicodeMaps->add(encodingName->copy(), name->copy());
272 +
273 +  unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
274  }
275  
276  void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
277 @@ -760,23 +813,30 @@
278      list = new GList();
279      cMapDirs->add(collection->copy(), list);
280    }
281 -  list->append(dir->copy());
282 +
283 +  list->append(qualify_filename(this->path, dir));
284  }
285  
286  void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
287                                      int line) {
288 +  GString *dir;
289 +
290    if (tokens->getLength() != 2) {
291      error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
292           fileName->getCString(), line);
293      return;
294    }
295 -  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
296 +
297 +  dir = (GString *)tokens->get(1);
298 +
299 +  toUnicodeDirs->append(qualify_filename(this->path, dir));
300  }
301  
302  void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
303                                     DisplayFontParamKind kind,
304                                     GString *fileName, int line) {
305    DisplayFontParam *param, *old;
306 +  GString *file;
307  
308    if (tokens->getLength() < 2) {
309      goto err1;
310 @@ -788,13 +848,15 @@
311      if (tokens->getLength() != 3) {
312        goto err2;
313      }
314 -    param->t1.fileName = ((GString *)tokens->get(2))->copy();
315 +    file = (GString *)tokens->get(2);
316 +    param->t1.fileName = qualify_filename(this->path, file);
317      break;
318    case displayFontTT:
319      if (tokens->getLength() != 3) {
320        goto err2;
321      }
322 -    param->tt.fileName = ((GString *)tokens->get(2))->copy();
323 +    file = (GString *)tokens->get(2);
324 +    param->tt.fileName = qualify_filename(this->path, file);
325      break;
326    }
327  
328 Index: Lexer.cc
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
333 diff -u -r1.4 -r1.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
336 @@ -74,6 +74,7 @@
337      curStr.streamReset();
338    }
339  }
340 +static int illegalChars = 0;
341  
342  Lexer::~Lexer() {
343    if (!curStr.isNone()) {
344 @@ -83,6 +84,9 @@
345    if (freeArray) {
346      delete streams;
347    }
348 +  if(illegalChars)
349 +      error(0, "Illegal characters in hex string (%d)", illegalChars);
350 +  illegalChars = 0;
351  }
352  
353  int Lexer::getChar() {
354 @@ -330,7 +334,8 @@
355         } else if (c2 >= 'a' && c2 <= 'f') {
356           c += c2 - 'a' + 10;
357         } else {
358 -         error(getPos(), "Illegal digit in hex char in name");
359 +         illegalChars++;
360 +         //error(getPos(), "Illegal digit in hex char in name");
361         }
362        }
363       notEscChar:
364 @@ -384,8 +389,10 @@
365             c2 += c - 'A' + 10;
366           else if (c >= 'a' && c <= 'f')
367             c2 += c - 'a' + 10;
368 -         else
369 -           error(getPos(), "Illegal character <%02x> in hex string", c);
370 +         else {
371 +           illegalChars++;
372 +           //error(getPos(), "Illegal character <%02x> in hex string", c);
373 +         }
374           if (++m == 2) {
375             if (n == tokBufSize) {
376               if (!s)
377 @@ -421,7 +428,8 @@
378        tokBuf[2] = '\0';
379        obj->initCmd(tokBuf);
380      } else {
381 -      error(getPos(), "Illegal character '>'");
382 +      illegalChars++;
383 +      //error(getPos(), "Illegal character '>'");
384        obj->initError();
385      }
386      break;
387 @@ -430,7 +438,8 @@
388    case ')':
389    case '{':
390    case '}':
391 -    error(getPos(), "Illegal character '%c'", c);
392 +    //error(getPos(), "Illegal character '%c'", c);
393 +    illegalChars++;
394      obj->initError();
395      break;
396  
397 @@ -459,7 +468,6 @@
398      }
399      break;
400    }
401 -
402    return obj;
403  }
404  
405 Index: Link.cc
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
410 diff -u -r1.5 -r1.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
413 @@ -430,10 +430,9 @@
414        delete dest;
415        dest = NULL;
416      }
417 -
418    // error
419    } else {
420 -    error(-1, "Illegal annotation destination");
421 +    error(-1, "Illegal annotation destination %d", destObj->getType());
422    }
423  }
424  
425 @@ -468,10 +467,9 @@
426        delete dest;
427        dest = NULL;
428      }
429 -
430    // error
431    } else {
432 -    error(-1, "Illegal annotation destination");
433 +    error(-1, "Illegal annotation destination %d", destObj->getType());
434    }
435  }
436  
437 Index: OutputDev.h
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
442 diff -u -r1.7 -r1.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
445 @@ -74,7 +74,7 @@
446    virtual void setDefaultCTM(double *ctm);
447  
448    // Start a page.
449 -  virtual void startPage(int pageNum, GfxState *state) {}
450 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
451  
452    // End a page.
453    virtual void endPage() {}
454 Index: Stream.cc
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
459 diff -u -r1.7 -r1.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
462 @@ -17,6 +17,8 @@
463  #include <stddef.h>
464  #ifndef WIN32
465  #include <unistd.h>
466 +#else
467 +extern "C" int unlink(char *filename);
468  #endif
469  #include <string.h>
470  #include <ctype.h>
471 Index: config.h
472 --- config.h    2007-09-09 12:11:20.000000000 +0200
473 +++ config.h    2007-09-09 12:11:40.000000000 +0200
474 @@ -53,9 +53,9 @@
475  
476  // user config file name, relative to the user's home directory
477  #if defined(VMS) || defined(WIN32)
478 -#define xpdfUserConfigFile "xpdfrc"
479 +#define xpdfUserConfigFile "pdf2swf.conf"
480  #else
481 -#define xpdfUserConfigFile ".xpdfrc"
482 +#define xpdfUserConfigFile ".pdf2swf.conf"
483  #endif
484  
485  // system config file name (set via the configure script)
486 @@ -64,7 +64,7 @@
487  #else
488  // under Windows, we get the directory with the executable and then
489  // append this file name
490 -#define xpdfSysConfigFile "xpdfrc"
491 +#define xpdfSysConfigFile "pdf2swf.conf"
492  #endif
493  
494  //------------------------------------------------------------------------
495 Index: gfile.cc
496 ===================================================================
497 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
498 retrieving revision 1.12
499 retrieving revision 1.13
500 diff -u -r1.12 -r1.13
501 --- gfile.cc    3 Dec 2005 10:11:33 -0000       1.12
502 +++ gfile.cc    3 Dec 2005 10:30:41 -0000       1.13
503 @@ -437,6 +437,52 @@
504  #endif
505  }
506  
507 +static char* getTempDir()
508 +{
509 +#ifdef WIN32
510 +    char*dir = getenv("TMP");
511 +    if(!dir) dir = getenv("TEMP");
512 +    if(!dir) dir = getenv("tmp");
513 +    if(!dir) dir = getenv("temp");
514 +    if(!dir) dir = "C:\\";
515 +#else
516 +    char* dir = "/tmp/";
517 +#endif
518 +    return dir;
519 +}
520 +
521 +char* mktmpname(char*ptr) {
522 +    static char tmpbuf[128];
523 +    char*dir = getTempDir();
524 +    int l = strlen(dir);
525 +    char*sep = "";
526 +    if(!ptr)
527 +       ptr = tmpbuf;
528 +    if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
529 +#ifdef WIN32
530 +       sep = "\\";
531 +#else
532 +       sep = "/";
533 +#endif
534 +    }
535 +
536 + //   used to be mktemp. This does remove the warnings, but
537 + //   It's not exactly an improvement.
538 +#ifdef HAVE_LRAND48
539 +    sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
540 +#else
541 +#   ifdef HAVE_RAND
542 +       sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
543 +#   else
544 +       static int count = 1;
545 +       sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
546 +       count ++;
547 +#   endif
548 +#endif
549 +     return ptr;
550 +}
551 +
552 +
553  GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
554  #if defined(WIN32)
555    //---------- Win32 ----------
556 @@ -463,7 +509,7 @@
557    // with this file name after the tmpnam call and before the fopen
558    // call.  I will happily accept fixes to this function for non-Unix
559    // OSs.
560 -  if (!(s = tmpnam(NULL))) {
561 +  if (!(s = mktmpname(NULL))) {
562      return gFalse;
563    }
564    *name = new GString(s);
565 @@ -490,7 +536,7 @@
566      (*name)->append("/XXXXXX")->append(ext);
567      fd = mkstemps((*name)->getCString(), strlen(ext));
568  #else
569 -    if (!(s = tmpnam(NULL))) {
570 +    if (!(s = mktmpname(NULL))) {
571        return gFalse;
572      }
573      *name = new GString(s);
574 @@ -507,7 +553,7 @@
575      (*name)->append("/XXXXXX");
576      fd = mkstemp((*name)->getCString());
577  #else // HAVE_MKSTEMP
578 -    if (!(s = tmpnam(NULL))) {
579 +    if (!(s = mktmpname(NULL))) {
580        return gFalse;
581      }
582      *name = new GString(s);
583 Index: gfile.h
584 ===================================================================
585 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
586 retrieving revision 1.9
587 retrieving revision 1.10
588 diff -u -r1.9 -r1.10
589 --- gfile.h     3 Dec 2005 10:11:33 -0000       1.9
590 +++ gfile.h     3 Dec 2005 10:30:41 -0000       1.10
591 @@ -58,6 +58,9 @@
592  // Get current directory.
593  extern GString *getCurrentDir();
594  
595 +/* create a temporary filename */
596 +char* mktmpname(char*ptr);
597 +
598  // Append a file name to a path string.  <path> may be an empty
599  // string, denoting the current directory).  Returns <path>.
600  extern GString *appendToPath(GString *path, char *fileName);
601 Index: GlobalParams.h
602 ===================================================================
603 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
604 retrieving revision 1.5
605 retrieving revision 1.6
606 diff -u -r1.5 -r1.6
607 --- GlobalParams.h      2006-10-10 19:54:29.000000000 +0200
608 +++ GlobalParams.h      2006-11-12 11:19:40.000000000 +0100
609 @@ -213,8 +213,8 @@
610    FILE *getUnicodeMapFile(GString *encodingName);
611    FILE *findCMapFile(GString *collection, GString *cMapName);
612    FILE *findToUnicodeFile(GString *name);
613 -  DisplayFontParam *getDisplayFont(GString *fontName);
614 -  DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
615 +  virtual DisplayFontParam *getDisplayFont(GString *fontName);
616 +  virtual DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
617    GString *getPSFile();
618    int getPSPaperWidth();
619    int getPSPaperHeight();
620 @@ -218,1 +218,1 @@
621 -  void parseFile(GString *fileName, FILE *f);
622 +public: void parseFile(GString *fileName, FILE *f); private:
623 @@ -246,6 +246,10 @@
624    GBool loadPlugin(char *type, char *name);
625  #endif
626  
627 +  //----- config file base path
628 +
629 +  GString*path;
630 +
631    //----- static tables
632  
633    NameToCharCode *             // mapping from char name to
634 --- SplashOutputDev.h   2006-11-12 12:07:22.000000000 +0100
635 +++ SplashOutputDev.h   2006-11-12 12:08:48.000000000 +0100
636 @@ -70,7 +70,7 @@
637    //----- initialization and control
638  
639    // Start a page.
640 -  virtual void startPage(int pageNum, GfxState *state);
641 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
642  
643    // End a page.
644    virtual void endPage();
645 --- SplashOutputDev.cc  2006-11-12 12:07:06.000000000 +0100
646 +++ SplashOutputDev.cc  2006-11-12 12:09:36.000000000 +0100
647 @@ -696,7 +696,7 @@
648    nT3Fonts = 0;
649  }
650  
651 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
652 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
653    int w, h;
654    double *ctm;
655    SplashCoord mat[6];
656 --- TextOutputDev.h     2006-11-12 12:23:01.000000000 +0100
657 +++ TextOutputDev.h     2006-11-12 12:25:31.000000000 +0100
658 @@ -578,7 +578,7 @@
659    //----- initialization and control
660  
661    // Start a page.
662 -  virtual void startPage(int pageNum, GfxState *state);
663 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
664  
665    // End a page.
666    virtual void endPage();
667 --- TextOutputDev.cc    2006-11-12 12:22:53.000000000 +0100
668 +++ TextOutputDev.cc    2006-11-12 12:25:03.000000000 +0100
669 @@ -3805,7 +3805,7 @@
670    }
671  }
672  
673 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
674 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
675    text->startPage(state);
676  }
677  
678 --- CoreOutputDev.cc    2006-11-12 12:21:59.000000000 +0100
679 +++ CoreOutputDev.cc    2006-11-12 12:23:29.000000000 +0100
680 @@ -57,5 +57,5 @@
681  
682  void CoreOutputDev::clear() {
683    startDoc(NULL);
684 -  startPage(0, NULL);
685 +  startPage(0, NULL, 0,0,0,0);
686  }
687 --- SplashFTFontEngine.cc       2006-11-19 22:30:44.000000000 +0100
688 +++ SplashFTFontEngine.cc       2006-11-19 22:30:56.000000000 +0100
689 @@ -13,9 +13,7 @@
690  #endif
691  
692  #include <stdio.h>
693 -#ifndef WIN32
694  #  include <unistd.h>
695 -#endif
696  #include "gmem.h"
697  #include "GString.h"
698  #include "gfile.h"
699 --- SplashOutputDev.cc  2007-09-09 12:29:45.000000000 +0200
700 +++ SplashOutputDev.cc  2007-09-09 12:30:02.000000000 +0200
701 @@ -13,6 +13,7 @@
702  #endif
703  
704  #include <string.h>
705 +#include <unistd.h>
706  #include <math.h>
707  #include "gfile.h"
708  #include "GlobalParams.h"
709 --- SplashFontFile.cc   2007-09-09 12:33:00.000000000 +0200
710 +++ SplashFontFile.cc   2007-09-09 12:33:07.000000000 +0200
711 @@ -11,9 +11,7 @@
712  #endif
713  
714  #include <stdio.h>
715 -#ifndef WIN32
716 -#  include <unistd.h>
717 -#endif
718 +#include <unistd.h>
719  #include "GString.h"
720  #include "SplashFontFile.h"
721  #include "SplashFontFileID.h"
722 --- SplashFont.h        2007-09-09 14:23:47.000000000 +0200
723 +++ SplashFont.h        2007-09-09 14:24:28.000000000 +0200
724 @@ -73,6 +73,9 @@
725    virtual GBool makeGlyph(int c, int xFrac, int yFrac,
726                           SplashGlyphBitmap *bitmap) = 0;
727  
728 +  // return the number of characters in this font
729 +  virtual int getNumChars() = 0;
730 +
731    // Return the path for a glyph.
732    virtual SplashPath *getGlyphPath(int c) = 0;
733  
734 --- SplashFTFont.h      2007-09-09 14:23:47.000000000 +0200
735 +++ SplashFTFont.h      2007-09-09 14:25:19.000000000 +0200
736 @@ -42,6 +42,9 @@
737    virtual GBool makeGlyph(int c, int xFrac, int yFrac,
738                           SplashGlyphBitmap *bitmap);
739  
740 +  // return the number of characters in this font
741 +  virtual int getNumChars();
742 +
743    // Return the path for a glyph.
744    virtual SplashPath *getGlyphPath(int c);
745  
746 --- SplashFTFont.cc.h   2007-09-09 14:23:50.000000000 +0200
747 +++ SplashFTFont.cc     2007-09-09 14:27:35.000000000 +0200
748 @@ -228,6 +228,12 @@
749    GBool needClose;
750  };
751  
752 +int SplashFTFont::getNumChars()
753 +{
754 +  SplashFTFontFile* ff = (SplashFTFontFile *)fontFile;
755 +  return ff->face->num_glyphs;
756 +}
757 +
758  SplashPath *SplashFTFont::getGlyphPath(int c) {
759    static FT_Outline_Funcs outlineFuncs = {
760  #if FREETYPE_MINOR <= 1
761 --- orig/GfxFont.h      2007-07-28 00:11:06.000000000 +0200
762 +++ GfxFont.h   2007-09-09 18:31:31.000000000 +0200
763 @@ -164,6 +164,7 @@
764    virtual int getNextChar(char *s, int len, CharCode *code,
765                           Unicode *u, int uSize, int *uLen,
766                           double *dx, double *dy, double *ox, double *oy) = 0;
767 +  virtual CharCodeToUnicode* getCTU() = 0;
768  
769  protected:
770  
771 @@ -204,6 +205,7 @@
772    virtual int getNextChar(char *s, int len, CharCode *code,
773                           Unicode *u, int uSize, int *uLen,
774                           double *dx, double *dy, double *ox, double *oy);
775 +  virtual CharCodeToUnicode* getCTU();
776  
777    // Return the encoding.
778    char **getEncoding() { return enc; }
779 @@ -266,6 +268,7 @@
780    virtual int getNextChar(char *s, int len, CharCode *code,
781                           Unicode *u, int uSize, int *uLen,
782                           double *dx, double *dy, double *ox, double *oy);
783 +  virtual CharCodeToUnicode* getCTU();
784  
785    // Return the writing mode (0=horizontal, 1=vertical).
786    virtual int getWMode();
787 --- orig/GfxFont.cc     2007-07-28 00:11:06.000000000 +0200
788 +++ GfxFont.cc  2007-09-09 18:33:37.000000000 +0200
789 @@ -925,6 +925,10 @@
790    return 1;
791  }
792  
793 +CharCodeToUnicode* Gfx8BitFont::getCTU() {
794 +    return ctu;
795 +}
796 +
797  CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
798    ctu->incRefCnt();
799    return ctu;
800 @@ -1417,6 +1421,10 @@
801    }
802  }
803  
804 +CharCodeToUnicode* GfxCIDFont::getCTU() {
805 +    return ctu;
806 +}
807 +
808  int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
809                             Unicode *u, int uSize, int *uLen,
810                             double *dx, double *dy, double *ox, double *oy) {
811 --- OutputDev.h Sat Jul 28 00:11:08 2007
812 +++ OutputDev.h Sun Sep  9 13:50:40 2007
813 @@ -17,6 +17,7 @@
814  
815  #include "gtypes.h"
816  #include "CharTypes.h"
817 +#include "Object.h"
818  
819  class GString;
820  class Gfx;
821 --- SplashOutputDev.h   2007-10-20 13:17:02.000000000 +0200
822 +++ SplashOutputDev.h   2007-10-20 13:17:23.000000000 +0200
823 @@ -206,6 +206,7 @@
824    virtual void setVectorAntialias(GBool vaa);
825  #endif
826  
827 +  void doUpdateFont(GfxState *state);
828  private:
829  
830    void setupScreenParams(double hDPI, double vDPI);
831 @@ -215,7 +216,6 @@
832    SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
833  #endif
834    SplashPath *convertPath(GfxState *state, GfxPath *path);
835 -  void doUpdateFont(GfxState *state);
836    void drawType3Glyph(T3FontCache *t3Font,
837                       T3FontCacheTag *tag, Guchar *data);
838    static GBool imageMaskSrc(void *data, SplashColorPtr line);
839 --- xpdf/GlobalParams.h 2007-10-20 13:18:03.000000000 +0200
840 +++ xpdf/GlobalParams.h 2007-10-20 13:25:52.000000000 +0200
841 @@ -196,7 +196,7 @@
842    // file.
843    GlobalParams(char *cfgFileName);
844  
845 -  ~GlobalParams();
846 +  virtual ~GlobalParams();
847  
848    void setBaseDir(char *dir);
849    void setupBaseFonts(char *dir);
850 --- xpdf/SplashOutputDev.h.orig 2007-10-21 17:43:29.000000000 +0200
851 +++ xpdf/SplashOutputDev.h      2007-11-19 10:07:27.000000000 +0100
852 @@ -197,6 +197,8 @@
853  #endif
854  
855    void doUpdateFont(GfxState *state);
856 +  
857 +  SplashPath *convertPath(GfxState *state, GfxPath *path);
858  private:
859  
860    void setupScreenParams(double hDPI, double vDPI);
861 @@ -205,7 +207,6 @@
862  #else
863    SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
864  #endif
865 -  SplashPath *convertPath(GfxState *state, GfxPath *path);
866    void drawType3Glyph(T3FontCache *t3Font,
867                       T3FontCacheTag *tag, Guchar *data);
868    static GBool imageMaskSrc(void *data, SplashColorPtr line);