Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bugzilla DB migration completed. Please report issues to Infra team via email via infra@gentoo.org or IRC
View | Details | Raw Unified | Return to bug 99769 | Differences between
and this patch

Collapse All | Expand All

(-)xpdf-3.00-dist/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, int faceIndexA=0);
36
  static FoFiTrueType *load(char *fileName, int faceIndexA=0);
37
37
38
  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA=0);
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, 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);
(-)xpdf-3.00-dist/fofi/FoFiType1C.h (-1 / +1 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,
(-)xpdf-3.00-dist/splash/SplashFTFontEngine.cc (-14 / +23 lines)
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-107 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
						     int faceIndex) {
104
						     int faceIndex) {
105
#if 0
105
  FoFiTrueType *ff;
106
  FoFiTrueType *ff;
106
  GString *tmpFileName;
107
  GString *tmpFileName;
107
  FILE *tmpFile;
108
  FILE *tmpFile;
Lines 120-126 Link Here
120
  fclose(tmpFile);
121
  fclose(tmpFile);
121
  ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
122
  ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
122
					   tmpFileName->getCString(),
123
					   tmpFileName->getCString(),
123
					   gTrue, codeToGID, codeToGIDLen);
124
					   gTrue, codeToGID, codeToGIDLen,
125
					   faceIndex);
124
  if (ret) {
126
  if (ret) {
125
    if (deleteFile) {
127
    if (deleteFile) {
126
      unlink(fileName);
128
      unlink(fileName);
Lines 130-135 Link Here
130
  }
132
  }
131
  delete tmpFileName;
133
  delete tmpFileName;
132
  return ret;
134
  return ret;
135
#else
136
  SplashFontFile *ret;
137
  ret = SplashFTFontFile::loadTrueTypeFont(this, idA, src,
138
					   codeToGID, codeToGIDLen,
139
					   faceIndex);
140
  return ret;
141
#endif
133
}
142
}
134
143
135
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
144
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
(-)xpdf-3.00-dist/splash/SplashFTFontEngine.h (-8 / +5 lines)
Lines 21-26 Link Here
21
21
22
class SplashFontFile;
22
class SplashFontFile;
23
class SplashFontFileID;
23
class SplashFontFileID;
24
class SplashFontSrc;
24
25
25
//------------------------------------------------------------------------
26
//------------------------------------------------------------------------
26
// SplashFTFontEngine
27
// SplashFTFontEngine
Lines 34-47 Link Here
34
  ~SplashFTFontEngine();
35
  ~SplashFTFontEngine();
35
36
36
  // Load fonts.
37
  // Load fonts.
37
  SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
38
  SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
38
				GBool deleteFile, char **enc);
39
  SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
39
  SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
40
  SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src);
40
				 GBool deleteFile, char **enc);
41
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
41
  SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
42
			      GBool deleteFile);
43
  SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
44
				   GBool deleteFile,
45
				   Gushort *codeToGID, int codeToGIDLen,
42
				   Gushort *codeToGID, int codeToGIDLen,
46
				   int faceIndex=0);
43
				   int faceIndex=0);
47
44
(-)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);
59
59
(-)xpdf-3.00-dist/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
						   int faceIndex) {
182
						   int faceIndex) {
Lines 195-201 Link Here
195
  fontFile = NULL;
185
  fontFile = NULL;
196
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
186
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
197
  if (!fontFile && ftEngine) {
187
  if (!fontFile && ftEngine) {
198
    fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile,
188
    fontFile = ftEngine->loadTrueTypeFont(idA, src,
199
					  codeToGID, codeToGIDLen, faceIndex);
189
					  codeToGID, codeToGIDLen, faceIndex);
200
  }
190
  }
201
#endif
191
#endif
Lines 208-216 Link Here
208
  // semantics, this will remove the last link; otherwise it will
198
  // semantics, this will remove the last link; otherwise it will
209
  // return an error, leaving the file to be deleted later (if
199
  // return an error, leaving the file to be deleted later (if
210
  // loadXYZFont failed, the file will always be deleted)
200
  // loadXYZFont failed, the file will always be deleted)
211
  if (deleteFile) {
201
  src->unref();
212
    unlink(fontFile ? fontFile->fileName->getCString() : fileName);
213
  }
214
202
215
  return fontFile;
203
  return fontFile;
216
}
204
}
(-)xpdf-3.00-dist/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
				   int faceIndex=0);
59
				   int faceIndex=0);
63
60
(-)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;
(-)xpdf-3.00-dist/xpdf/SplashOutputDev.cc (-58 / +43 lines)
Lines 490-499 Link Here
490
  GfxFontType fontType;
490
  GfxFontType fontType;
491
  SplashOutFontFileID *id;
491
  SplashOutFontFileID *id;
492
  SplashFontFile *fontFile;
492
  SplashFontFile *fontFile;
493
  SplashFontSrc *fontsrc;
493
  FoFiTrueType *ff;
494
  FoFiTrueType *ff;
494
  Ref embRef;
495
  Ref embRef;
495
  Object refObj, strObj;
496
  Object refObj, strObj;
496
  GString *tmpFileName, *fileName, *substName;
497
  GString *fileName, *substName;
498
  char *tmpBuf;
499
  int tmpBufLen;
497
  FILE *tmpFile;
500
  FILE *tmpFile;
498
  Gushort *codeToGID;
501
  Gushort *codeToGID;
499
  DisplayFontParam *dfp;
502
  DisplayFontParam *dfp;
Lines 505-511 Link Here
505
508
506
  needFontUpdate = gFalse;
509
  needFontUpdate = gFalse;
507
  font = NULL;
510
  font = NULL;
508
  tmpFileName = NULL;
511
  fileName = NULL;
512
  tmpBuf = NULL;
509
  substIdx = -1;
513
  substIdx = -1;
510
514
511
  if (!(gfxFont = state->getFont())) {
515
  if (!(gfxFont = state->getFont())) {
Lines 525-546 Link Here
525
529
526
    // if there is an embedded font, write it to disk
530
    // if there is an embedded font, write it to disk
527
    if (gfxFont->getEmbeddedFontID(&embRef)) {
531
    if (gfxFont->getEmbeddedFontID(&embRef)) {
528
      if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
532
      tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen);
529
	error(-1, "Couldn't create temporary font file");
533
      if (! tmpBuf)
530
	goto err2;
534
	goto err2;
531
      }
532
      refObj.initRef(embRef.num, embRef.gen);
533
      refObj.fetch(xref, &strObj);
534
      refObj.free();
535
      strObj.streamReset();
536
      while ((c = strObj.streamGetChar()) != EOF) {
537
	fputc(c, tmpFile);
538
      }
539
      strObj.streamClose();
540
      strObj.free();
541
      fclose(tmpFile);
542
      fileName = tmpFileName;
543
544
    // if there is an external font file, use it
535
    // if there is an external font file, use it
545
    } else if (!(fileName = gfxFont->getExtFontFile())) {
536
    } else if (!(fileName = gfxFont->getExtFontFile())) {
546
537
Lines 596-609 Link Here
596
      }
587
      }
597
    }
588
    }
598
589
590
    fontsrc = new SplashFontSrc;
591
    if (fileName)
592
      fontsrc->setFile(fileName, gFalse);
593
    else
594
      fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse);
595
599
    // load the font file
596
    // load the font file
600
    switch (fontType) {
597
    switch (fontType) {
601
    case fontType1:
598
    case fontType1:
602
      if (!(fontFile = fontEngine->loadType1Font(
599
      fontFile = fontEngine->loadType1Font(id, fontsrc, 
603
			   id,
600
					   ((Gfx8BitFont *)gfxFont)->getEncoding());
604
			   fileName->getCString(),
601
      if (! fontFile) {
605
			   fileName == tmpFileName,
606
			   ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
607
	error(-1, "Couldn't create a font for '%s'",
602
	error(-1, "Couldn't create a font for '%s'",
608
	      gfxFont->getName() ? gfxFont->getName()->getCString()
603
	      gfxFont->getName() ? gfxFont->getName()->getCString()
609
	                         : "(unnamed)");
604
	                         : "(unnamed)");
Lines 611-621 Link Here
611
      }
606
      }
612
      break;
607
      break;
613
    case fontType1C:
608
    case fontType1C:
614
      if (!(fontFile = fontEngine->loadType1CFont(
609
      fontFile = fontEngine->loadType1CFont(id, fontsrc,
615
			   id,
610
					    ((Gfx8BitFont *)gfxFont)->getEncoding());
616
			   fileName->getCString(),
611
      if (! fontFile) {
617
			   fileName == tmpFileName,
618
			   ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
619
	error(-1, "Couldn't create a font for '%s'",
612
	error(-1, "Couldn't create a font for '%s'",
620
	      gfxFont->getName() ? gfxFont->getName()->getCString()
613
	      gfxFont->getName() ? gfxFont->getName()->getCString()
621
	                         : "(unnamed)");
614
	                         : "(unnamed)");
Lines 623-638 Link Here
623
      }
616
      }
624
      break;
617
      break;
625
    case fontTrueType:
618
    case fontTrueType:
626
      if (!(ff = FoFiTrueType::load(fileName->getCString()))) {
619
      if (fileName)
620
	ff = FoFiTrueType::load(fileName->getCString());
621
      else
622
	ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse);
623
      if (! ff)
627
	goto err2;
624
	goto err2;
628
      }
629
      codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
625
      codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
630
      delete ff;
626
      delete ff;
631
      if (!(fontFile = fontEngine->loadTrueTypeFont(
627
      fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, 256);
632
			   id,
628
      if (! fontFile) {
633
			   fileName->getCString(),
634
			   fileName == tmpFileName,
635
			   codeToGID, 256))) {
636
	error(-1, "Couldn't create a font for '%s'",
629
	error(-1, "Couldn't create a font for '%s'",
637
	      gfxFont->getName() ? gfxFont->getName()->getCString()
630
	      gfxFont->getName() ? gfxFont->getName()->getCString()
638
	                         : "(unnamed)");
631
	                         : "(unnamed)");
Lines 641-650 Link Here
641
      break;
634
      break;
642
    case fontCIDType0:
635
    case fontCIDType0:
643
    case fontCIDType0C:
636
    case fontCIDType0C:
644
      if (!(fontFile = fontEngine->loadCIDFont(
637
      fontFile = fontEngine->loadCIDFont(id, fontsrc);
645
			   id,
638
      if (! fontFile) {
646
			   fileName->getCString(),
647
			   fileName == tmpFileName))) {
648
	error(-1, "Couldn't create a font for '%s'",
639
	error(-1, "Couldn't create a font for '%s'",
649
	      gfxFont->getName() ? gfxFont->getName()->getCString()
640
	      gfxFont->getName() ? gfxFont->getName()->getCString()
650
	                         : "(unnamed)");
641
	                         : "(unnamed)");
Lines 658-675 Link Here
658
	      memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
649
	      memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
659
		     n * sizeof(Gushort));
650
		     n * sizeof(Gushort));
660
      } else {
651
      } else {
661
	      if (!(ff = FoFiTrueType::load(fileName->getCString()))) {
652
	if (fileName)
662
	    fprintf(stderr, "failture loading cid2 %s\n", fileName->getCString());
653
	  ff = FoFiTrueType::load(fileName->getCString());
663
		      goto err2;
654
	else
664
	      }
655
	  ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse);
665
	      codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
656
	if (! ff)
666
	      delete ff;
657
	  goto err2;
667
      }
658
	codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
668
      if (!(fontFile = fontEngine->loadTrueTypeFont(
659
	delete ff;
669
			   id,
660
      }
670
			   fileName->getCString(),
661
      fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n, faceIndex);
671
			   fileName == tmpFileName,
662
      if (! fontFile) {
672
			   codeToGID, n, faceIndex))) {
673
	error(-1, "Couldn't create a font for '%s'",
663
	error(-1, "Couldn't create a font for '%s'",
674
	      gfxFont->getName() ? gfxFont->getName()->getCString()
664
	      gfxFont->getName() ? gfxFont->getName()->getCString()
675
	                         : "(unnamed)");
665
	                         : "(unnamed)");
Lines 717-733 Link Here
717
  mat[2] = m21;  mat[3] = -m22;
707
  mat[2] = m21;  mat[3] = -m22;
718
  font = fontEngine->getFont(fontFile, mat);
708
  font = fontEngine->getFont(fontFile, mat);
719
709
720
  if (tmpFileName) {
721
    delete tmpFileName;
722
  }
723
  return;
710
  return;
724
711
725
 err2:
712
 err2:
726
  delete id;
713
  delete id;
727
 err1:
714
 err1:
728
  if (tmpFileName) {
729
    delete tmpFileName;
730
  }
731
  return;
715
  return;
732
}
716
}
733
717
Lines 1345-1352 Link Here
1345
    if (dfp->kind != displayFontT1) {
1329
    if (dfp->kind != displayFontT1) {
1346
      return NULL;
1330
      return NULL;
1347
    }
1331
    }
1348
    fontFile = fontEngine->loadType1Font(id, dfp->t1.fileName->getCString(),
1332
    SplashFontSrc *fontsrc = new SplashFontSrc;
1349
					 gFalse, winAnsiEncoding);
1333
    fontsrc->setFile(dfp->t1.fileName, gFalse);
1334
    fontFile = fontEngine->loadType1Font(id, fontsrc, winAnsiEncoding);
1350
  }
1335
  }
1351
1336
1352
  // create the scaled font
1337
  // create the scaled font

Return to bug 99769