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

Collapse All | Expand All

(-)gpdf-2.8.3/fofi/FoFiTrueType.h (-1 / +1 lines)
Lines 35-40 Link Here
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);
37
37
38
  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
38
  virtual ~FoFiTrueType();
39
  virtual ~FoFiTrueType();
39
40
40
  // Return the number of cmaps defined by this font.
41
  // Return the number of cmaps defined by this font.
Lines 100-106 Link Here
100
101
101
private:
102
private:
102
103
103
  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
104
  void cvtEncoding(char **encoding,
104
  void cvtEncoding(char **encoding,
105
		   FoFiOutputFunc outputFunc,
105
		   FoFiOutputFunc outputFunc,
106
		   void *outputStream);
106
		   void *outputStream);
(-)xpdf-3.00-dist/fofi/FoFiType1C.h (-15 / +24 lines)
Lines 135-140 Link Here
135
  // Create a FoFiType1C object from a file on disk.
135
  // Create a FoFiType1C object from a file on disk.
136
  static FoFiType1C *load(char *fileName);
136
  static FoFiType1C *load(char *fileName);
137
137
138
  FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
138
  virtual ~FoFiType1C();
139
  virtual ~FoFiType1C();
139
140
140
  // Return the font name.
141
  // Return the font name.
Lines 170-176 Link Here
170
171
171
private:
172
private:
172
173
173
  FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
174
  void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName,
174
  void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName,
175
		     int offset, int nBytes,
175
		     int offset, int nBytes,
176
		     Type1CIndex *subrIdx,
176
		     Type1CIndex *subrIdx,
177
--- gpdf-2.8.3/splash/SplashFTFontEngine.cc	2004-05-17 14:10:51.000000000 -0400
177
--- gpdf-2.8.3/splash/SplashFTFontEngine.cc	2004-05-17 14:10:51.000000000 -0400
Lines 59-95 Link Here
59
}
59
}
60
60
61
SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA,
61
SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA,
62
						  char *fileName,
62
						  SplashFontSrc *src,
63
						  GBool deleteFile,
64
						  char **enc) {
63
						  char **enc) {
65
  return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
64
  return SplashFTFontFile::loadType1Font(this, idA, src, enc);
66
}
65
}
67
66
68
SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA,
67
SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA,
69
						   char *fileName,
68
						   SplashFontSrc *src,
70
						   GBool deleteFile,
71
						   char **enc) {
69
						   char **enc) {
72
  return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
70
  return SplashFTFontFile::loadType1Font(this, idA, src, enc);
73
}
71
}
74
72
75
SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
73
SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
76
						char *fileName,
74
						SplashFontSrc *src) {
77
						GBool deleteFile) {
78
  FoFiType1C *ff;
75
  FoFiType1C *ff;
79
  Gushort *cidToGIDMap;
76
  Gushort *cidToGIDMap;
80
  int nCIDs;
77
  int nCIDs;
81
  SplashFontFile *ret;
78
  SplashFontFile *ret;
82
79
83
  // check for a CFF font
80
  // check for a CFF font
84
  if ((ff = FoFiType1C::load(fileName))) {
81
  if (src->isFile) {
82
    ff = FoFiType1C::load(src->fileName->getCString());
83
  } else {
84
    ff = new FoFiType1C(src->buf, src->bufLen, gFalse);
85
  }
86
  if (ff) {
85
    cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
87
    cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
86
    delete ff;
88
    delete ff;
87
  } else {
89
  } else {
88
    cidToGIDMap = NULL;
90
    cidToGIDMap = NULL;
89
    nCIDs = 0;
91
    nCIDs = 0;
90
  }
92
  }
91
  ret = SplashFTFontFile::loadCIDFont(this, idA, fileName, deleteFile,
93
  ret = SplashFTFontFile::loadCIDFont(this, idA, src, cidToGIDMap, nCIDs);
92
				      cidToGIDMap, nCIDs);
93
  if (!ret) {
94
  if (!ret) {
94
    gfree(cidToGIDMap);
95
    gfree(cidToGIDMap);
95
  }
96
  }
Lines 97-106 Link Here
97
}
98
}
98
99
99
SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
100
SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
100
						     char *fileName,
101
						     SplashFontSrc *src,
101
						     GBool deleteFile,
102
						     Gushort *codeToGID,
102
						     Gushort *codeToGID,
103
						     int codeToGIDLen) {
103
						     int codeToGIDLen) {
104
#if 0
104
  FoFiTrueType *ff;
105
  FoFiTrueType *ff;
105
  GString *tmpFileName;
106
  GString *tmpFileName;
106
  FILE *tmpFile;
107
  FILE *tmpFile;
Lines 119-125 Link Here
119
  fclose(tmpFile);
120
  fclose(tmpFile);
120
  ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
121
  ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
121
					   tmpFileName->getCString(),
122
					   tmpFileName->getCString(),
122
					   gTrue, codeToGID, codeToGIDLen);
123
					   gTrue, codeToGID, codeToGIDLen,
124
					   faceIndex);
123
  if (ret) {
125
  if (ret) {
124
    if (deleteFile) {
126
    if (deleteFile) {
125
      unlink(fileName);
127
      unlink(fileName);
Lines 129-134 Link Here
129
  }
131
  }
130
  delete tmpFileName;
132
  delete tmpFileName;
131
  return ret;
133
  return ret;
134
#else
135
  SplashFontFile *ret;
136
  ret = SplashFTFontFile::loadTrueTypeFont(this, idA, src,
137
					   codeToGID, codeToGIDLen,
138
					   faceIndex);
139
  return ret;
140
#endif
132
}
141
}
133
142
134
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
143
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
(-)gpdf-2.8.3/splash/SplashFTFontEngine.h (-8 / +7 lines)
Lines 20-25 Link Here
20
20
21
class SplashFontFile;
21
class SplashFontFile;
22
class SplashFontFileID;
22
class SplashFontFileID;
23
class SplashFontSrc;
23
24
24
//------------------------------------------------------------------------
25
//------------------------------------------------------------------------
25
// SplashFTFontEngine
26
// SplashFTFontEngine
Lines 33-47 Link Here
33
  ~SplashFTFontEngine();
34
  ~SplashFTFontEngine();
34
35
35
  // Load fonts.
36
  // Load fonts.
36
  SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
37
  SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
37
				GBool deleteFile, char **enc);
38
  SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
38
  SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
39
  SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src);
39
				 GBool deleteFile, char **enc);
40
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
40
  SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
41
			      GBool deleteFile);
42
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
43
				   GBool deleteFile,
41
				   GBool deleteFile,
44
				   Gushort *codeToGID, int codeToGIDLen);
42
				   Gushort *codeToGID, int codeToGIDLeni,
43
				   int faceIndex=0);
45
44
46
private:
45
private:
47
46
(-)xpdf-3.00-dist/splash/SplashFTFontFile.cc (-18 / +29 lines)
Lines 16-21 Link Here
16
#include "SplashFTFontEngine.h"
16
#include "SplashFTFontEngine.h"
17
#include "SplashFTFont.h"
17
#include "SplashFTFont.h"
18
#include "SplashFTFontFile.h"
18
#include "SplashFTFontFile.h"
19
#include "GString.h"
19
20
20
//------------------------------------------------------------------------
21
//------------------------------------------------------------------------
21
// SplashFTFontFile
22
// SplashFTFontFile
Lines 23-38 Link Here
23
24
24
SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA,
25
SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA,
25
						SplashFontFileID *idA,
26
						SplashFontFileID *idA,
26
						char *fileNameA,
27
						SplashFontSrc *src,
27
						GBool deleteFileA,
28
						char **encA) {
28
						char **encA) {
29
  FT_Face faceA;
29
  FT_Face faceA;
30
  Gushort *codeToGIDA;
30
  Gushort *codeToGIDA;
31
  char *name;
31
  char *name;
32
  int i;
32
  int i;
33
33
34
  if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
34
  if (src->isFile) {
35
    return NULL;
35
    if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA))
36
      return NULL;
37
  } else {
38
    if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA))
39
      return NULL;
36
  }
40
  }
37
  codeToGIDA = (Gushort *)gmalloc(256 * sizeof(int));
41
  codeToGIDA = (Gushort *)gmalloc(256 * sizeof(int));
38
  for (i = 0; i < 256; ++i) {
42
  for (i = 0; i < 256; ++i) {
Lines 42-89 Link Here
42
    }
46
    }
43
  }
47
  }
44
48
45
  return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
49
  return new SplashFTFontFile(engineA, idA, src,
46
			      faceA, codeToGIDA, 256);
50
			      faceA, codeToGIDA, 256);
47
}
51
}
48
52
49
SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA,
53
SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA,
50
					      SplashFontFileID *idA,
54
					      SplashFontFileID *idA,
51
					      char *fileNameA,
55
					      SplashFontSrc *src,
52
					      GBool deleteFileA,
53
					      Gushort *codeToGIDA,
56
					      Gushort *codeToGIDA,
54
					      int codeToGIDLenA) {
57
					      int codeToGIDLenA) {
55
  FT_Face faceA;
58
  FT_Face faceA;
56
59
57
  if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
60
  if (src->isFile) {
58
    return NULL;
61
    if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA))
62
      return NULL;
63
  } else {
64
    if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA))
65
      return NULL;
59
  }
66
  }
60
67
61
  return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
68
  return new SplashFTFontFile(engineA, idA, src,
62
			      faceA, codeToGIDA, codeToGIDLenA);
69
			      faceA, codeToGIDA, codeToGIDLenA);
63
}
70
}
64
71
65
SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
72
SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
66
						   SplashFontFileID *idA,
73
						   SplashFontFileID *idA,
67
						   char *fileNameA,
74
						   SplashFontSrc *src,
68
						   GBool deleteFileA,
69
						   Gushort *codeToGIDA,
75
						   Gushort *codeToGIDA,
70
						   int codeToGIDLenA) {
76
						   int codeToGIDLenA,
77
						   int faceIndexA) {
71
  FT_Face faceA;
78
  FT_Face faceA;
72
79
73
  if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
80
  if (src->isFile) {
74
    return NULL;
81
    if (FT_New_Face(engineA->lib, src->fileName->getCString(), faceIndexA, &faceA))
82
      return NULL;
83
  } else {
84
    if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, faceIndexA, &faceA))
85
      return NULL;
75
  }
86
  }
76
87
77
  return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
88
  return new SplashFTFontFile(engineA, idA, src,
78
			      faceA, codeToGIDA, codeToGIDLenA);
89
			      faceA, codeToGIDA, codeToGIDLenA);
79
}
90
}
80
91
81
SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA,
92
SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA,
82
				   SplashFontFileID *idA,
93
				   SplashFontFileID *idA,
83
				   char *fileNameA, GBool deleteFileA,
94
				   SplashFontSrc *srcA,
84
				   FT_Face faceA,
95
				   FT_Face faceA,
85
				   Gushort *codeToGIDA, int codeToGIDLenA):
96
				   Gushort *codeToGIDA, int codeToGIDLenA):
86
  SplashFontFile(idA, fileNameA, deleteFileA)
97
  SplashFontFile(idA, srcA)
87
{
98
{
88
  engine = engineA;
99
  engine = engineA;
89
  face = faceA;
100
  face = faceA;
(-)xpdf-3.00-dist/splash/SplashFTFontFile.h (-8 / +8 lines)
Lines 30-47 Link Here
30
public:
30
public:
31
31
32
  static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA,
32
  static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA,
33
				       SplashFontFileID *idA, char *fileNameA,
33
				       SplashFontFileID *idA,
34
				       GBool deleteFileA, char **encA);
34
				       SplashFontSrc *src, char **encA);
35
  static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA,
35
  static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA,
36
				     SplashFontFileID *idA, char *fileNameA,
36
				     SplashFontFileID *idA,
37
				     GBool deleteFileA,
37
				     SplashFontSrc *src,
38
				     Gushort *codeToCIDA, int codeToGIDLenA);
38
				     Gushort *codeToCIDA, int codeToGIDLenA);
39
  static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA,
39
  static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA,
40
					  SplashFontFileID *idA,
40
					  SplashFontFileID *idA,
41
					  char *fileNameA,
41
					  SplashFontSrc *src,
42
					  GBool deleteFileA,
43
					  Gushort *codeToGIDA,
42
					  Gushort *codeToGIDA,
44
					  int codeToGIDLenA);
43
					  int codeToGIDLenA,
44
					  int faceIndexA=0);
45
45
46
  virtual ~SplashFTFontFile();
46
  virtual ~SplashFTFontFile();
47
47
Lines 53-59 Link Here
53
53
54
  SplashFTFontFile(SplashFTFontEngine *engineA,
54
  SplashFTFontFile(SplashFTFontEngine *engineA,
55
		   SplashFontFileID *idA,
55
		   SplashFontFileID *idA,
56
		   char *fileNameA, GBool deleteFileA,
56
		   SplashFontSrc *srcA,
57
		   FT_Face faceA,
57
		   FT_Face faceA,
58
		   Gushort *codeToGIDA, int codeToGIDLenA);
58
		   Gushort *codeToGIDA, int codeToGIDLenA);
(-)gpdf-2.8.3/splash/SplashFontEngine.cc (-26 / +14 lines)
Lines 105-123 Link Here
105
}
105
}
106
106
107
SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA,
107
SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA,
108
						char *fileName,
108
						SplashFontSrc *src, char **enc) {
109
						GBool deleteFile, char **enc) {
110
  SplashFontFile *fontFile;
109
  SplashFontFile *fontFile;
111
110
112
  fontFile = NULL;
111
  fontFile = NULL;
113
#if HAVE_T1LIB_H
112
#if HAVE_T1LIB_H
114
  if (!fontFile && t1Engine) {
113
  if (!fontFile && t1Engine) {
115
    fontFile = t1Engine->loadType1Font(idA, fileName, deleteFile, enc);
114
    fontFile = t1Engine->loadType1Font(idA, src, enc);
116
  }
115
  }
117
#endif
116
#endif
118
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
117
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
119
  if (!fontFile && ftEngine) {
118
  if (!fontFile && ftEngine) {
120
    fontFile = ftEngine->loadType1Font(idA, fileName, deleteFile, enc);
119
    fontFile = ftEngine->loadType1Font(idA, src, enc);
121
  }
120
  }
122
#endif
121
#endif
123
122
Lines 125-152 Link Here
125
  // semantics, this will remove the last link; otherwise it will
124
  // semantics, this will remove the last link; otherwise it will
126
  // return an error, leaving the file to be deleted later (if
125
  // return an error, leaving the file to be deleted later (if
127
  // loadXYZFont failed, the file will always be deleted)
126
  // loadXYZFont failed, the file will always be deleted)
128
  if (deleteFile) {
127
  src->unref();
129
    unlink(fontFile ? fontFile->fileName->getCString() : fileName);
130
  }
131
128
132
  return fontFile;
129
  return fontFile;
133
}
130
}
134
131
135
SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA,
132
SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA,
136
						 char *fileName,
133
						 SplashFontSrc *src,
137
						 GBool deleteFile,
138
						 char **enc) {
134
						 char **enc) {
139
  SplashFontFile *fontFile;
135
  SplashFontFile *fontFile;
140
136
141
  fontFile = NULL;
137
  fontFile = NULL;
142
#if HAVE_T1LIB_H
138
#if HAVE_T1LIB_H
143
  if (!fontFile && t1Engine) {
139
  if (!fontFile && t1Engine) {
144
    fontFile = t1Engine->loadType1CFont(idA, fileName, deleteFile, enc);
140
    fontFile = t1Engine->loadType1CFont(idA, src, enc);
145
  }
141
  }
146
#endif
142
#endif
147
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
143
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
148
  if (!fontFile && ftEngine) {
144
  if (!fontFile && ftEngine) {
149
    fontFile = ftEngine->loadType1CFont(idA, fileName, deleteFile, enc);
145
    fontFile = ftEngine->loadType1CFont(idA, src, enc);
150
  }
146
  }
151
#endif
147
#endif
152
148
Lines 154-175 Link Here
154
  // semantics, this will remove the last link; otherwise it will
150
  // semantics, this will remove the last link; otherwise it will
155
  // return an error, leaving the file to be deleted later (if
151
  // return an error, leaving the file to be deleted later (if
156
  // loadXYZFont failed, the file will always be deleted)
152
  // loadXYZFont failed, the file will always be deleted)
157
  if (deleteFile) {
153
  src->unref();
158
    unlink(fontFile ? fontFile->fileName->getCString() : fileName);
159
  }
160
154
161
  return fontFile;
155
  return fontFile;
162
}
156
}
163
157
164
SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA,
158
SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA,
165
					      char *fileName,
159
					      SplashFontSrc *src) {
166
					      GBool deleteFile) {
167
  SplashFontFile *fontFile;
160
  SplashFontFile *fontFile;
168
161
169
  fontFile = NULL;
162
  fontFile = NULL;
170
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
163
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
171
  if (!fontFile && ftEngine) {
164
  if (!fontFile && ftEngine) {
172
    fontFile = ftEngine->loadCIDFont(idA, fileName, deleteFile);
165
    fontFile = ftEngine->loadCIDFont(idA, src);
173
  }
166
  }
174
#endif
167
#endif
175
168
Lines 177-192 Link Here
177
  // semantics, this will remove the last link; otherwise it will
170
  // semantics, this will remove the last link; otherwise it will
178
  // return an error, leaving the file to be deleted later (if
171
  // return an error, leaving the file to be deleted later (if
179
  // loadXYZFont failed, the file will always be deleted)
172
  // loadXYZFont failed, the file will always be deleted)
180
  if (deleteFile) {
173
  src->unref();
181
    unlink(fontFile ? fontFile->fileName->getCString() : fileName);
182
  }
183
174
184
  return fontFile;
175
  return fontFile;
185
}
176
}
186
177
187
SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
178
SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
188
						   char *fileName,
179
						   SplashFontSrc *src,
189
						   GBool deleteFile,
190
						   Gushort *codeToGID,
180
						   Gushort *codeToGID,
191
						   int codeToGIDLen) {
181
						   int codeToGIDLen) {
192
  SplashFontFile *fontFile;
182
  SplashFontFile *fontFile;
Lines 194-200 Link Here
194
  fontFile = NULL;
184
  fontFile = NULL;
195
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
185
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
196
  if (!fontFile && ftEngine) {
186
  if (!fontFile && ftEngine) {
197
    fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile,
187
    fontFile = ftEngine->loadTrueTypeFont(idA, src,
198
					  codeToGID, codeToGIDLen);
188
					  codeToGID, codeToGIDLen);
199
  }
189
  }
200
#endif
190
#endif
Lines 207-215 Link Here
207
  // semantics, this will remove the last link; otherwise it will
197
  // semantics, this will remove the last link; otherwise it will
208
  // return an error, leaving the file to be deleted later (if
198
  // return an error, leaving the file to be deleted later (if
209
  // loadXYZFont failed, the file will always be deleted)
199
  // loadXYZFont failed, the file will always be deleted)
210
  if (deleteFile) {
200
  src->unref();
211
    unlink(fontFile ? fontFile->fileName->getCString() : fileName);
212
  }
213
201
214
  return fontFile;
202
  return fontFile;
215
}
203
}
(-)gpdf-2.8.3/splash/SplashFontEngine.h (-8 / +5 lines)
Lines 21-26 Link Here
21
class SplashFontFile;
21
class SplashFontFile;
22
class SplashFontFileID;
22
class SplashFontFileID;
23
class SplashFont;
23
class SplashFont;
24
class SplashFontSrc;
24
25
25
//------------------------------------------------------------------------
26
//------------------------------------------------------------------------
26
27
Lines 50-63 Link Here
50
  SplashFontFile *getFontFile(SplashFontFileID *id);
51
  SplashFontFile *getFontFile(SplashFontFileID *id);
51
52
52
  // Load fonts - these create new SplashFontFile objects.
53
  // Load fonts - these create new SplashFontFile objects.
53
  SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
54
  SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
54
				GBool deleteFile, char **enc);
55
  SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
55
  SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
56
  SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src);
56
				 GBool deleteFile, char **enc);
57
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
57
  SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
58
			      GBool deleteFile);
59
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
60
				   GBool deleteFile,
61
				   Gushort *codeToGID, int codeToGIDLen);
58
				   Gushort *codeToGID, int codeToGIDLen);
62
59
63
  // Get a font - this does a cache lookup first, and if not found,
60
  // Get a font - this does a cache lookup first, and if not found,
(-)xpdf-3.00-dist/splash/SplashFontFile.cc (-8 / +62 lines)
Lines 17-22 Link Here
17
#include "GString.h"
17
#include "GString.h"
18
#include "SplashFontFile.h"
18
#include "SplashFontFile.h"
19
#include "SplashFontFileID.h"
19
#include "SplashFontFileID.h"
20
#include "gmem.h"
20
21
21
#ifdef VMS
22
#ifdef VMS
22
#if (__VMS_VER < 70000000)
23
#if (__VMS_VER < 70000000)
Lines 28-46 Link Here
28
// SplashFontFile
29
// SplashFontFile
29
//------------------------------------------------------------------------
30
//------------------------------------------------------------------------
30
31
31
SplashFontFile::SplashFontFile(SplashFontFileID *idA, char *fileNameA,
32
SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) {
32
			       GBool deleteFileA) {
33
  id = idA;
33
  id = idA;
34
  fileName = new GString(fileNameA);
34
  src = srcA;
35
  deleteFile = deleteFileA;
35
  src->ref();
36
  refCnt = 0;
36
  refCnt = 0;
37
}
37
}
38
38
39
SplashFontFile::~SplashFontFile() {
39
SplashFontFile::~SplashFontFile() {
40
  if (deleteFile) {
40
  src->unref();
41
    unlink(fileName->getCString());
42
  }
43
  delete fileName;
44
  delete id;
41
  delete id;
45
}
42
}
46
43
Lines 53-55 Link Here
53
    delete this;
50
    delete this;
54
  }
51
  }
55
}
52
}
53
54
//
55
56
SplashFontSrc::SplashFontSrc() {
57
  isFile = gFalse;
58
  deleteSrc = gFalse;
59
  fileName = NULL;
60
  buf = NULL;
61
  refcnt = 1;
62
}
63
64
SplashFontSrc::~SplashFontSrc() {
65
  if (deleteSrc) {
66
    if (isFile) {
67
      if (fileName)
68
	unlink(fileName->getCString());
69
    } else {
70
      if (buf)
71
	gfree(buf);
72
    }
73
  }
74
75
  if (isFile && fileName)
76
    delete fileName;
77
}
78
79
void SplashFontSrc::ref() {
80
  refcnt++;
81
}
82
83
void SplashFontSrc::unref() {
84
  if (! --refcnt)
85
    delete this;
86
}
87
88
void SplashFontSrc::setFile(GString *file, GBool del)
89
{
90
  isFile = gTrue;
91
  fileName = file->copy();
92
  deleteSrc = del;
93
}
94
95
void SplashFontSrc::setFile(const char *file, GBool del)
96
{
97
  isFile = gTrue;
98
  fileName = new GString(file);
99
  deleteSrc = del;
100
}
101
102
void SplashFontSrc::setBuf(char *bufA, int bufLenA, GBool del)
103
{
104
  isFile = gFalse;
105
  buf = bufA;
106
  bufLen = bufLenA;
107
  deleteSrc = del;
108
}
109
(-)xpdf-3.00-dist/splash/SplashFontFile.h (-4 / +21 lines)
Lines 25-30 Link Here
25
// SplashFontFile
25
// SplashFontFile
26
//------------------------------------------------------------------------
26
//------------------------------------------------------------------------
27
27
28
struct SplashFontSrc {
29
  SplashFontSrc();
30
  ~SplashFontSrc();
31
32
  void setFile(GString *file, GBool del);
33
  void setFile(const char *file, GBool del);
34
  void setBuf(char *bufA, int buflenA, GBool del);
35
36
  void ref();
37
  void unref();
38
39
  GBool isFile;
40
  GString *fileName;
41
  char *buf;
42
  int bufLen;
43
  GBool deleteSrc;
44
  int refcnt;
45
};
46
28
class SplashFontFile {
47
class SplashFontFile {
29
public:
48
public:
30
49
Lines 46-57 Link Here
46
65
47
protected:
66
protected:
48
67
49
  SplashFontFile(SplashFontFileID *idA, char *fileNameA,
68
  SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA);
50
		 GBool deleteFileA);
51
69
52
  SplashFontFileID *id;
70
  SplashFontFileID *id;
53
  GString *fileName;
71
  SplashFontSrc *src;
54
  GBool deleteFile;
55
  int refCnt;
72
  int refCnt;
56
73
57
  friend class SplashFontEngine;
74
  friend class SplashFontEngine;
(-)xpdf-3.00-dist/splash/SplashT1FontEngine.cc (-16 / +13 lines)
Lines 82-105 Link Here
82
}
82
}
83
83
84
SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA,
84
SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA,
85
						  char *fileName,
85
						  SplashFontSrc *src,
86
						  GBool deleteFile,
87
						  char **enc) {
86
						  char **enc) {
88
  return SplashT1FontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
87
  return SplashT1FontFile::loadType1Font(this, idA, src, enc);
89
}
88
}
90
89
91
SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA,
90
SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA,
92
						   char *fileName,
91
						   SplashFontSrc *src,
93
						   GBool deleteFile,
94
						   char **enc) {
92
						   char **enc) {
95
  FoFiType1C *ff;
93
  FoFiType1C *ff;
96
  GString *tmpFileName;
94
  GString *tmpFileName;
97
  FILE *tmpFile;
95
  FILE *tmpFile;
98
  SplashFontFile *ret;
96
  SplashFontFile *ret;
97
  SplashFontSrc *newsrc;
99
98
100
  if (!(ff = FoFiType1C::load(fileName))) {
99
  if (src->isFile)
100
    ff = FoFiType1C::load(src->fileName);
101
  else
102
    ff = new FoFiType1C(src->buf, src->bufLen, gFalse);
103
  if (! ff)
101
    return NULL;
104
    return NULL;
102
  }
103
  tmpFileName = NULL;
105
  tmpFileName = NULL;
104
  if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
106
  if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
105
    delete ff;
107
    delete ff;
Lines 108-123 Link Here
108
  ff->convertToType1(NULL, gTrue, &fileWrite, tmpFile);
110
  ff->convertToType1(NULL, gTrue, &fileWrite, tmpFile);
109
  delete ff;
111
  delete ff;
110
  fclose(tmpFile);
112
  fclose(tmpFile);
111
  ret = SplashT1FontFile::loadType1Font(this, idA, tmpFileName->getCString(),
113
  newsrc = new SplashFontSrc;
112
					gTrue, enc);
114
  newsrc->setFile(tmpFileName, gTrue);
113
  if (ret) {
114
    if (deleteFile) {
115
      unlink(fileName);
116
    }
117
  } else {
118
    unlink(tmpFileName->getCString());
119
  }
120
  delete tmpFileName;
115
  delete tmpFileName;
116
  ret = SplashT1FontFile::loadType1Font(this, idA, newsrc, enc);
117
  newsrc->unref();
121
  return ret;
118
  return ret;
122
}
119
}
123
120
(-)xpdf-3.00-dist/splash/SplashT1FontFile.cc (-6 / +26 lines)
Lines 25-32 Link Here
25
25
26
SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA,
26
SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA,
27
						SplashFontFileID *idA,
27
						SplashFontFileID *idA,
28
						char *fileNameA,
28
						SplashFontSrc *src,
29
						GBool deleteFileA,
30
						char **encA) {
29
						char **encA) {
31
  int t1libIDA;
30
  int t1libIDA;
32
  char **encTmp;
31
  char **encTmp;
Lines 34-42 Link Here
34
  int encStrSize;
33
  int encStrSize;
35
  char *encPtr;
34
  char *encPtr;
36
  int i;
35
  int i;
37
36
  GString *fileNameA;
37
  SplashFontSrc *newsrc = NULL;
38
  SplashFontFile *ff;
39
40
  if (! src->isFile) {
41
    GString *tmpFileName;
42
    FILE *tmpFile;
43
    if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL))
44
      return NULL;
45
    fwrite(src->buf, 1, src->bufLen, tmpFile);
46
    fclose(tmpFile);
47
    newsrc = new SplashFontSrc;
48
    newsrc->setFile(tmpFileName, gTrue);
49
    src = newsrc;
50
    delete tmpFileName;
51
  }
52
  fileNameA = src->fileName;
38
  // load the font file
53
  // load the font file
39
  if ((t1libIDA = T1_AddFont(fileNameA)) < 0) {
54
  if ((t1libIDA = T1_AddFont(fileNameA)) < 0) {
55
    if (newsrc)
56
      delete newsrc;
40
    return NULL;
57
    return NULL;
41
  }
58
  }
42
  T1_LoadFont(t1libIDA);
59
  T1_LoadFont(t1libIDA);
Lines 63-77 Link Here
63
  encTmp[256] = "custom";
80
  encTmp[256] = "custom";
64
  T1_ReencodeFont(t1libIDA, encTmp);
81
  T1_ReencodeFont(t1libIDA, encTmp);
65
82
66
  return new SplashT1FontFile(engineA, idA, fileNameA, deleteFileA,
83
  ff = new SplashT1FontFile(engineA, idA, src,
67
			      t1libIDA, encTmp, encStrTmp);
84
			      t1libIDA, encTmp, encStrTmp);
85
  if (newsrc)
86
    newsrc->unref();
87
  return ff;
68
}
88
}
69
89
70
SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA,
90
SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA,
71
				   SplashFontFileID *idA,
91
				   SplashFontFileID *idA,
72
				   char *fileNameA, GBool deleteFileA,
92
				   SplashFontSrc *srcA,
73
				   int t1libIDA, char **encA, char *encStrA):
93
				   int t1libIDA, char **encA, char *encStrA):
74
  SplashFontFile(idA, fileNameA, deleteFileA)
94
  SplashFontFile(idA, srcA)
75
{
95
{
76
  engine = engineA;
96
  engine = engineA;
77
  t1libID = t1libIDA;
97
  t1libID = t1libIDA;
(-)xpdf-3.00-dist/splash/SplashT1FontFile.h (-2 / +2 lines)
Lines 28-34 Link Here
28
28
29
  static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA,
29
  static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA,
30
				       SplashFontFileID *idA,
30
				       SplashFontFileID *idA,
31
				       char *fileNameA, GBool deleteFileA,
31
				       SplashFontSrc *src,
32
				       char **encA);
32
				       char **encA);
33
33
34
  virtual ~SplashT1FontFile();
34
  virtual ~SplashT1FontFile();
Lines 41-47 Link Here
41
41
42
  SplashT1FontFile(SplashT1FontEngine *engineA,
42
  SplashT1FontFile(SplashT1FontEngine *engineA,
43
		   SplashFontFileID *idA,
43
		   SplashFontFileID *idA,
44
		   char *fileNameA, GBool deleteFileA,
44
		   SplashFontSrc *src,
45
		   int t1libIDA, char **encA, char *encStrA);
45
		   int t1libIDA, char **encA, char *encStrA);
46
46
47
  SplashT1FontEngine *engine;
47
  SplashT1FontEngine *engine;

Return to bug 100265