Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 100263 | Differences between
and this patch

Collapse All | Expand All

(-)xpdf-3.00.orig/fofi/FoFiTrueType.cc (-7 / +37 lines)
Lines 233-242 Link Here
233
// FoFiTrueType
233
// FoFiTrueType
234
//------------------------------------------------------------------------
234
//------------------------------------------------------------------------
235
235
236
FoFiTrueType *FoFiTrueType::make(char *fileA, int lenA) {
236
FoFiTrueType *FoFiTrueType::make(char *fileA, int lenA, int faceIndexA) {
237
  FoFiTrueType *ff;
237
  FoFiTrueType *ff;
238
238
239
  ff = new FoFiTrueType(fileA, lenA, gFalse);
239
  ff = new FoFiTrueType(fileA, lenA, gFalse, faceIndexA);
240
  if (!ff->parsedOk) {
240
  if (!ff->parsedOk) {
241
    delete ff;
241
    delete ff;
242
    return NULL;
242
    return NULL;
Lines 244-250 Link Here
244
  return ff;
244
  return ff;
245
}
245
}
246
246
247
FoFiTrueType *FoFiTrueType::load(char *fileName) {
247
FoFiTrueType *FoFiTrueType::load(char *fileName, int faceIndexA) {
248
  FoFiTrueType *ff;
248
  FoFiTrueType *ff;
249
  char *fileA;
249
  char *fileA;
250
  int lenA;
250
  int lenA;
Lines 252-258 Link Here
252
  if (!(fileA = FoFiBase::readFile(fileName, &lenA))) {
252
  if (!(fileA = FoFiBase::readFile(fileName, &lenA))) {
253
    return NULL;
253
    return NULL;
254
  }
254
  }
255
  ff = new FoFiTrueType(fileA, lenA, gTrue);
255
  ff = new FoFiTrueType(fileA, lenA, gTrue, faceIndexA);
256
  if (!ff->parsedOk) {
256
  if (!ff->parsedOk) {
257
    delete ff;
257
    delete ff;
258
    return NULL;
258
    return NULL;
Lines 260-266 Link Here
260
  return ff;
260
  return ff;
261
}
261
}
262
262
263
FoFiTrueType::FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA):
263
FoFiTrueType::FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA):
264
  FoFiBase(fileA, lenA, freeFileDataA)
264
  FoFiBase(fileA, lenA, freeFileDataA)
265
{
265
{
266
  tables = NULL;
266
  tables = NULL;
Lines 269-274 Link Here
269
  nCmaps = 0;
269
  nCmaps = 0;
270
  nameToGID = NULL;
270
  nameToGID = NULL;
271
  parsedOk = gFalse;
271
  parsedOk = gFalse;
272
  faceIndex = faceIndexA;
272
273
273
  parse();
274
  parse();
274
}
275
}
Lines 1262-1279 Link Here
1262
  return checksum;
1263
  return checksum;
1263
}
1264
}
1264
1265
1266
#define toTag(a,b,c,d) (((unsigned int)(a)<<24) | ((unsigned int)(b)<<16) | ((unsigned int)(c)<<8) | (d))
1267
1265
void FoFiTrueType::parse() {
1268
void FoFiTrueType::parse() {
1266
  int pos, i, j;
1269
  int pos, i, j;
1270
  unsigned int head;
1267
1271
1268
  parsedOk = gTrue;
1272
  parsedOk = gTrue;
1269
1273
1274
  pos = 0;
1270
  // read the table directory
1275
  // read the table directory
1271
  nTables = getU16BE(4, &parsedOk);
1276
  head = getU32BE(pos, &parsedOk);
1277
  if (! parsedOk)
1278
    return;
1279
  if (head == toTag('t','t','c','f')) {
1280
    /* TTC font */
1281
    unsigned int tableDir;
1282
    int dircount;
1283
1284
    dircount = getU32BE(8, &parsedOk);
1285
    if (!parsedOk)
1286
      return;
1287
    if (! dircount) {
1288
      parsedOk = gFalse;
1289
      return;
1290
    }
1291
1292
    if (faceIndex >= dircount)
1293
      faceIndex = 0;
1294
    pos = getU32BE(12 + faceIndex * 4, &parsedOk);
1295
    if (! parsedOk)
1296
      return;
1297
  }
1298
1299
  pos += 4;
1300
  nTables = getU16BE(pos, &parsedOk);
1272
  if (!parsedOk) {
1301
  if (!parsedOk) {
1273
    return;
1302
    return;
1274
  }
1303
  }
1304
1305
  pos += 8;
1275
  tables = (TrueTypeTable *)gmalloc(nTables * sizeof(TrueTypeTable));
1306
  tables = (TrueTypeTable *)gmalloc(nTables * sizeof(TrueTypeTable));
1276
  pos = 12;
1277
  for (i = 0; i < nTables; ++i) {
1307
  for (i = 0; i < nTables; ++i) {
1278
    tables[i].tag = getU32BE(pos, &parsedOk);
1308
    tables[i].tag = getU32BE(pos, &parsedOk);
1279
    tables[i].checksum = getU32BE(pos + 4, &parsedOk);
1309
    tables[i].checksum = getU32BE(pos + 4, &parsedOk);
(-)xpdf-3.00.orig/fofi/FoFiTrueType.h (-3 / +4 lines)
Lines 30-39 Link Here
30
public:
30
public:
31
31
32
  // Create a FoFiTrueType object from a memory buffer.
32
  // Create a FoFiTrueType object from a memory buffer.
33
  static FoFiTrueType *make(char *fileA, int lenA);
33
  static FoFiTrueType *make(char *fileA, int lenA, int faceIndexA=0);
34
34
35
  // Create a FoFiTrueType object from a file on disk.
35
  // Create a FoFiTrueType object from a file on disk.
36
  static FoFiTrueType *load(char *fileName);
36
  static FoFiTrueType *load(char *fileName, int faceIndexA=0);
37
37
38
  virtual ~FoFiTrueType();
38
  virtual ~FoFiTrueType();
39
39
Lines 100-106 Link Here
100
100
101
private:
101
private:
102
102
103
  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
103
  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA=0);
104
  void cvtEncoding(char **encoding,
104
  void cvtEncoding(char **encoding,
105
		   FoFiOutputFunc outputFunc,
105
		   FoFiOutputFunc outputFunc,
106
		   void *outputStream);
106
		   void *outputStream);
Lines 128-133 Link Here
128
  GHash *nameToGID;
128
  GHash *nameToGID;
129
129
130
  GBool parsedOk;
130
  GBool parsedOk;
131
  int faceIndex;
131
};
132
};
132
133
133
#endif
134
#endif
(-)xpdf-3.00.orig/splash/SplashFTFontEngine.cc (-2 / +3 lines)
Lines 100-112 Link Here
100
						     char *fileName,
100
						     char *fileName,
101
						     GBool deleteFile,
101
						     GBool deleteFile,
102
						     Gushort *codeToGID,
102
						     Gushort *codeToGID,
103
						     int codeToGIDLen) {
103
						     int codeToGIDLen,
104
						     int faceIndex) {
104
  FoFiTrueType *ff;
105
  FoFiTrueType *ff;
105
  GString *tmpFileName;
106
  GString *tmpFileName;
106
  FILE *tmpFile;
107
  FILE *tmpFile;
107
  SplashFontFile *ret;
108
  SplashFontFile *ret;
108
109
109
  if (!(ff = FoFiTrueType::load(fileName))) {
110
  if (!(ff = FoFiTrueType::load(fileName, faceIndex))) {
110
    return NULL;
111
    return NULL;
111
  }
112
  }
112
  tmpFileName = NULL;
113
  tmpFileName = NULL;
(-)xpdf-3.00.orig/splash/SplashFTFontEngine.h (-1 / +2 lines)
Lines 41-47 Link Here
41
			      GBool deleteFile);
41
			      GBool deleteFile);
42
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
42
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
43
				   GBool deleteFile,
43
				   GBool deleteFile,
44
				   Gushort *codeToGID, int codeToGIDLen);
44
				   Gushort *codeToGID, int codeToGIDLen,
45
				   int faceIndex=0);
45
46
46
private:
47
private:
47
48
(-)xpdf-3.00.orig/splash/SplashFontEngine.cc (-2 / +3 lines)
Lines 188-201 Link Here
188
						   char *fileName,
188
						   char *fileName,
189
						   GBool deleteFile,
189
						   GBool deleteFile,
190
						   Gushort *codeToGID,
190
						   Gushort *codeToGID,
191
						   int codeToGIDLen) {
191
						   int codeToGIDLen,
192
						   int faceIndex) {
192
  SplashFontFile *fontFile;
193
  SplashFontFile *fontFile;
193
194
194
  fontFile = NULL;
195
  fontFile = NULL;
195
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
196
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
196
  if (!fontFile && ftEngine) {
197
  if (!fontFile && ftEngine) {
197
    fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile,
198
    fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile,
198
					  codeToGID, codeToGIDLen);
199
					  codeToGID, codeToGIDLen, faceIndex);
199
  }
200
  }
200
#endif
201
#endif
201
202
(-)xpdf-3.00.orig/splash/SplashFontEngine.h (-1 / +2 lines)
Lines 58-64 Link Here
58
			      GBool deleteFile);
58
			      GBool deleteFile);
59
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
59
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
60
				   GBool deleteFile,
60
				   GBool deleteFile,
61
				   Gushort *codeToGID, int codeToGIDLen);
61
				   Gushort *codeToGID, int codeToGIDLen,
62
				   int faceIndex=0);
62
63
63
  // Get a font - this does a cache lookup first, and if not found,
64
  // Get a font - this does a cache lookup first, and if not found,
64
  // creates a new SplashFont object and adds it to the cache.  The
65
  // creates a new SplashFont object and adds it to the cache.  The
(-)xpdf-3.00.orig/xpdf/CharCodeToUnicode.h (+2 lines)
Lines 67-72 Link Here
67
  // Map a CharCode to Unicode.
67
  // Map a CharCode to Unicode.
68
  int mapToUnicode(CharCode c, Unicode *u, int size);
68
  int mapToUnicode(CharCode c, Unicode *u, int size);
69
69
70
  CharCode getMapLen() { return mapLen; }
71
70
private:
72
private:
71
73
72
  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
74
  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
(-)xpdf-3.00.orig/xpdf/GfxFont.cc (-1 / +48 lines)
Lines 323-329 Link Here
323
323
324
void GfxFont::findExtFontFile() {
324
void GfxFont::findExtFontFile() {
325
  static char *type1Exts[] = { ".pfa", ".pfb", ".ps", "", NULL };
325
  static char *type1Exts[] = { ".pfa", ".pfb", ".ps", "", NULL };
326
  static char *ttExts[] = { ".ttf", NULL };
326
  static char *ttExts[] = { ".ttf", ".ttc", NULL };
327
327
328
  if (name) {
328
  if (name) {
329
    if (type == fontType1) {
329
    if (type == fontType1) {
Lines 1442-1447 Link Here
1442
  return cMap ? cMap->getCollection() : (GString *)NULL;
1442
  return cMap ? cMap->getCollection() : (GString *)NULL;
1443
}
1443
}
1444
1444
1445
Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
1446
  Gushort *map;
1447
  int cmapPlatform, cmapEncoding;
1448
  int unicodeCmap, macRomanCmap, msSymbolCmap, cmap;
1449
  GBool useMacRoman, useUnicode;
1450
  char *charName;
1451
  Unicode u;
1452
  int code, i;
1453
  int mapsize;
1454
  int cidlen;
1455
1456
  *mapsizep = 0;
1457
1458
  /* we use only unicode cmap */
1459
  cmap = -1;
1460
  for (i = 0; i < ff->getNumCmaps(); ++i) {
1461
    cmapPlatform = ff->getCmapPlatform(i);
1462
    cmapEncoding = ff->getCmapEncoding(i);
1463
    if ((cmapPlatform == 3 && cmapEncoding == 1) || cmapPlatform == 0)
1464
      cmap = i;
1465
  }
1466
  if (cmap < 0)
1467
    return NULL;
1468
1469
  cidlen = 0;
1470
  mapsize = 64;
1471
  map = (Gushort *)gmalloc(mapsize * sizeof(Gushort));
1472
1473
  while (cidlen < ctu->getMapLen()) {
1474
    int n;
1475
    if ((n = ctu->mapToUnicode((CharCode)cidlen, &u, 1)) == 0) {
1476
      cidlen++;
1477
      continue;
1478
    }
1479
    if (cidlen >= mapsize) {
1480
      while (cidlen >= mapsize)
1481
	mapsize *= 2;
1482
      map = (Gushort *)grealloc(map, mapsize * sizeof(Gushort));
1483
    }
1484
    map[cidlen] = ff->mapCodeToGID(cmap, u);
1485
    cidlen++;
1486
  }
1487
1488
  *mapsizep = cidlen;
1489
  return map;
1490
}
1491
1445
//------------------------------------------------------------------------
1492
//------------------------------------------------------------------------
1446
// GfxFontDict
1493
// GfxFontDict
1447
//------------------------------------------------------------------------
1494
//------------------------------------------------------------------------
(-)xpdf-3.00.orig/xpdf/GfxFont.h (+2 lines)
Lines 276-281 Link Here
276
  Gushort *getCIDToGID() { return cidToGID; }
276
  Gushort *getCIDToGID() { return cidToGID; }
277
  int getCIDToGIDLen() { return cidToGIDLen; }
277
  int getCIDToGIDLen() { return cidToGIDLen; }
278
278
279
  Gushort *getCodeToGIDMap(FoFiTrueType *ff, int *length);
280
279
private:
281
private:
280
282
281
  CMap *cMap;			// char code --> CID
283
  CMap *cMap;			// char code --> CID
(-)xpdf-3.00.orig/xpdf/GlobalParams.cc (-1 / +15 lines)
Lines 15-20 Link Here
15
#include <string.h>
15
#include <string.h>
16
#include <stdio.h>
16
#include <stdio.h>
17
#include <ctype.h>
17
#include <ctype.h>
18
#include <sys/stat.h>
18
#if HAVE_PAPER_H
19
#if HAVE_PAPER_H
19
#include <paper.h>
20
#include <paper.h>
20
#endif
21
#endif
Lines 593-598 Link Here
593
				    DisplayFontParamKind kind,
594
				    DisplayFontParamKind kind,
594
				    GString *fileName, int line) {
595
				    GString *fileName, int line) {
595
  DisplayFontParam *param, *old;
596
  DisplayFontParam *param, *old;
597
  struct stat statbuf;
596
598
597
  if (tokens->getLength() < 2) {
599
  if (tokens->getLength() < 2) {
598
    goto err1;
600
    goto err1;
Lines 605-616 Link Here
605
      goto err2;
607
      goto err2;
606
    }
608
    }
607
    param->t1.fileName = ((GString *)tokens->get(2))->copy();
609
    param->t1.fileName = ((GString *)tokens->get(2))->copy();
610
    if (stat((param->t1.fileName->getCString)(), &statbuf)) {
611
      delete param; // silently ignore non-existing files
612
      return;
613
    }    
608
    break;
614
    break;
609
  case displayFontTT:
615
  case displayFontTT:
610
    if (tokens->getLength() != 3) {
616
    if (tokens->getLength() < 3) {
611
      goto err2;
617
      goto err2;
612
    }
618
    }
613
    param->tt.fileName = ((GString *)tokens->get(2))->copy();
619
    param->tt.fileName = ((GString *)tokens->get(2))->copy();
620
    if (stat((param->tt.fileName->getCString)(), &statbuf)) {
621
      delete param; // silently ignore non-existing files
622
      return;
623
    }
624
    if (tokens->getLength() > 3)
625
      param->tt.faceIndex = atoi(((GString *)tokens->get(3))->getCString());
626
    else
627
      param->tt.faceIndex = 0;
614
    break;
628
    break;
615
  }
629
  }
616
630
(-)xpdf-3.00.orig/xpdf/GlobalParams.h (+1 lines)
Lines 60-65 Link Here
60
    } t1;
60
    } t1;
61
    struct {
61
    struct {
62
      GString *fileName;
62
      GString *fileName;
63
      int faceIndex;
63
    } tt;
64
    } tt;
64
  };
65
  };
65
66
(-)xpdf-3.00.orig/xpdf/SplashOutputDev.cc (-4 / +15 lines)
Lines 501-506 Link Here
501
  SplashCoord mat[4];
501
  SplashCoord mat[4];
502
  char *name;
502
  char *name;
503
  int c, substIdx, n, code;
503
  int c, substIdx, n, code;
504
  int faceIndex = 0;
504
505
505
  needFontUpdate = gFalse;
506
  needFontUpdate = gFalse;
506
  font = NULL;
507
  font = NULL;
Lines 590-595 Link Here
590
      case displayFontTT:
591
      case displayFontTT:
591
	fileName = dfp->tt.fileName;
592
	fileName = dfp->tt.fileName;
592
	fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType;
593
	fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType;
594
	faceIndex = dfp->tt.faceIndex;
593
	break;
595
	break;
594
      }
596
      }
595
    }
597
    }
Lines 651-664 Link Here
651
      break;
653
      break;
652
    case fontCIDType2:
654
    case fontCIDType2:
653
      n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
655
      n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
654
      codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
656
      if (n) {
655
      memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
657
	      codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
656
	     n * sizeof(Gushort));
658
	      memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
659
		     n * sizeof(Gushort));
660
      } else {
661
	      if (!(ff = FoFiTrueType::load(fileName->getCString()))) {
662
	    fprintf(stderr, "failture loading cid2 %s\n", fileName->getCString());
663
		      goto err2;
664
	      }
665
	      codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
666
	      delete ff;
667
      }
657
      if (!(fontFile = fontEngine->loadTrueTypeFont(
668
      if (!(fontFile = fontEngine->loadTrueTypeFont(
658
			   id,
669
			   id,
659
			   fileName->getCString(),
670
			   fileName->getCString(),
660
			   fileName == tmpFileName,
671
			   fileName == tmpFileName,
661
			   codeToGID, n))) {
672
			   codeToGID, n, faceIndex))) {
662
	error(-1, "Couldn't create a font for '%s'",
673
	error(-1, "Couldn't create a font for '%s'",
663
	      gfxFont->getName() ? gfxFont->getName()->getCString()
674
	      gfxFont->getName() ? gfxFont->getName()->getCString()
664
	                         : "(unnamed)");
675
	                         : "(unnamed)");

Return to bug 100263