[poppler] poppler/splash: SplashFTFontEngine.cc, 1.3,
1.4 SplashFTFontEngine.h, 1.2, 1.3 SplashFTFontFile.cc, 1.2,
1.3 SplashFTFontFile.h, 1.1.1.1, 1.2 SplashFontEngine.cc, 1.2,
1.3 SplashFontEngine.h, 1.1.1.1, 1.2 SplashFontFile.cc, 1.2,
1.3 SplashFontFile.h, 1.1.1.1, 1.2 SplashT1FontEngine.cc,
1.1.1.1, 1.2 SplashT1FontFile.cc, 1.2, 1.3 SplashT1FontFile.h,
1.1.1.1, 1.2
Albert Astals Cid
aacid at freedesktop.org
Thu Feb 2 14:50:04 PST 2006
- Previous message: [poppler] poppler: ChangeLog,1.299,1.300
- Next message: [poppler] poppler/poppler: GfxFont.cc, 1.6, 1.7 GfxFont.h, 1.2,
1.3 GlobalParams.cc, 1.15, 1.16 GlobalParams.h, 1.5,
1.6 SplashOutputDev.cc, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/poppler/poppler/splash
In directory gabe:/tmp/cvs-serv24658/splash
Modified Files:
SplashFTFontEngine.cc SplashFTFontEngine.h SplashFTFontFile.cc
SplashFTFontFile.h SplashFontEngine.cc SplashFontEngine.h
SplashFontFile.cc SplashFontFile.h SplashT1FontEngine.cc
SplashT1FontFile.cc SplashT1FontFile.h
Log Message:
don't use files to pass fonts to freetype
Index: SplashFTFontEngine.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFTFontEngine.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- SplashFTFontEngine.cc 8 Dec 2005 18:17:42 -0000 1.3
+++ SplashFTFontEngine.cc 2 Feb 2006 22:50:01 -0000 1.4
@@ -64,22 +64,19 @@
}
SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
char **enc) {
- return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
+ return SplashFTFontFile::loadType1Font(this, idA, src, enc);
}
SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
char **enc) {
- return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
+ return SplashFTFontFile::loadType1Font(this, idA, src, enc);
}
SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile) {
+ SplashFontSrc *src) {
FoFiType1C *ff;
Gushort *cidToGIDMap;
int nCIDs;
@@ -89,15 +86,21 @@
if (useCIDs) {
cidToGIDMap = NULL;
nCIDs = 0;
- } else if ((ff = FoFiType1C::load(fileName))) {
+ } else {
+ if (src->isFile) {
+ ff = FoFiType1C::load(src->fileName->getCString());
+ } else {
+ ff = new FoFiType1C(src->buf, src->bufLen, gFalse);
+ }
+ if (ff) {
cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
delete ff;
} else {
cidToGIDMap = NULL;
nCIDs = 0;
}
- ret = SplashFTFontFile::loadCIDFont(this, idA, fileName, deleteFile,
- cidToGIDMap, nCIDs);
+ }
+ ret = SplashFTFontFile::loadCIDFont(this, idA, src, cidToGIDMap, nCIDs);
if (!ret) {
gfree(cidToGIDMap);
}
@@ -105,16 +108,17 @@
}
SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
Gushort *codeToGID,
- int codeToGIDLen) {
+ int codeToGIDLen,
+ int faceIndex) {
+#if 0
FoFiTrueType *ff;
GooString *tmpFileName;
FILE *tmpFile;
SplashFontFile *ret;
- if (!(ff = FoFiTrueType::load(fileName))) {
+ if (!(ff = FoFiTrueType::load(fileName, faceIndex))) {
return NULL;
}
tmpFileName = NULL;
@@ -127,7 +131,8 @@
fclose(tmpFile);
ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
tmpFileName->getCString(),
- gTrue, codeToGID, codeToGIDLen);
+ gTrue, codeToGID, codeToGIDLen,
+ faceIndex);
if (ret) {
if (deleteFile) {
unlink(fileName);
@@ -137,6 +142,13 @@
}
delete tmpFileName;
return ret;
+#else
+ SplashFontFile *ret;
+ ret = SplashFTFontFile::loadTrueTypeFont(this, idA, src,
+ codeToGID, codeToGIDLen,
+ faceIndex);
+ return ret;
+#endif
}
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
Index: SplashFTFontEngine.h
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFTFontEngine.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashFTFontEngine.h 15 Sep 2005 22:09:50 -0000 1.2
+++ SplashFTFontEngine.h 2 Feb 2006 22:50:01 -0000 1.3
@@ -19,6 +19,7 @@
class SplashFontFile;
class SplashFontFileID;
+class SplashFontSrc;
//------------------------------------------------------------------------
// SplashFTFontEngine
@@ -32,15 +33,12 @@
~SplashFTFontEngine();
// Load fonts.
- SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
- GBool deleteFile, char **enc);
- SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
- GBool deleteFile, char **enc);
- SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
- GBool deleteFile);
- SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
- GBool deleteFile,
- Gushort *codeToGID, int codeToGIDLen);
+ SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
+ SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
+ SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src);
+ SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
+ Gushort *codeToGID, int codeToGIDLen,
+ int faceIndex=0);
private:
Index: SplashFTFontFile.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFTFontFile.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashFTFontFile.cc 27 Aug 2005 08:43:43 -0000 1.2
+++ SplashFTFontFile.cc 2 Feb 2006 22:50:01 -0000 1.3
@@ -13,6 +13,7 @@
#endif
#include "goo/gmem.h"
+#include "goo/GooString.h"
#include "SplashFTFontEngine.h"
#include "SplashFTFont.h"
#include "SplashFTFontFile.h"
@@ -23,16 +24,19 @@
SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA,
- GBool deleteFileA,
+ SplashFontSrc *src,
char **encA) {
FT_Face faceA;
Gushort *codeToGIDA;
char *name;
int i;
- if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
- return NULL;
+ if (src->isFile) {
+ if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA))
+ return NULL;
+ } else {
+ if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA))
+ return NULL;
}
codeToGIDA = (Gushort *)gmallocn(256, sizeof(int));
for (i = 0; i < 256; ++i) {
@@ -42,48 +46,55 @@
}
}
- return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
+ return new SplashFTFontFile(engineA, idA, src,
faceA, codeToGIDA, 256);
}
SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA,
- GBool deleteFileA,
+ SplashFontSrc *src,
Gushort *codeToGIDA,
int codeToGIDLenA) {
FT_Face faceA;
- if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
- return NULL;
+ if (src->isFile) {
+ if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA))
+ return NULL;
+ } else {
+ if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA))
+ return NULL;
}
- return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
+ return new SplashFTFontFile(engineA, idA, src,
faceA, codeToGIDA, codeToGIDLenA);
}
SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA,
- GBool deleteFileA,
+ SplashFontSrc *src,
Gushort *codeToGIDA,
- int codeToGIDLenA) {
+ int codeToGIDLenA,
+ int faceIndexA) {
FT_Face faceA;
- if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
- return NULL;
+ if (src->isFile) {
+ if (FT_New_Face(engineA->lib, src->fileName->getCString(), faceIndexA, &faceA))
+ return NULL;
+ } else {
+ if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, faceIndexA, &faceA))
+ return NULL;
}
- return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
+ return new SplashFTFontFile(engineA, idA, src,
faceA, codeToGIDA, codeToGIDLenA);
}
SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA, GBool deleteFileA,
+ SplashFontSrc *srcA,
FT_Face faceA,
Gushort *codeToGIDA, int codeToGIDLenA):
- SplashFontFile(idA, fileNameA, deleteFileA)
+ SplashFontFile(idA, srcA)
{
engine = engineA;
face = faceA;
Index: SplashFTFontFile.h
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFTFontFile.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SplashFTFontFile.h 3 Mar 2005 19:45:59 -0000 1.1.1.1
+++ SplashFTFontFile.h 2 Feb 2006 22:50:01 -0000 1.2
@@ -28,18 +28,18 @@
public:
static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA,
- SplashFontFileID *idA, char *fileNameA,
- GBool deleteFileA, char **encA);
+ SplashFontFileID *idA,
+ SplashFontSrc *src, char **encA);
static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA,
- SplashFontFileID *idA, char *fileNameA,
- GBool deleteFileA,
- Gushort *codeToCIDA, int codeToGIDLenA);
+ SplashFontFileID *idA,
+ SplashFontSrc *src,
+ Gushort *codeToCIDA, int codeToGIDLenA);
static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA,
- GBool deleteFileA,
+ SplashFontSrc *src,
Gushort *codeToGIDA,
- int codeToGIDLenA);
+ int codeToGIDLenA,
+ int faceIndexA=0);
virtual ~SplashFTFontFile();
@@ -51,7 +51,7 @@
SplashFTFontFile(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA, GBool deleteFileA,
+ SplashFontSrc *srcA,
FT_Face faceA,
Gushort *codeToGIDA, int codeToGIDLenA);
Index: SplashFontEngine.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFontEngine.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashFontEngine.cc 16 Sep 2005 17:42:56 -0000 1.2
+++ SplashFontEngine.cc 2 Feb 2006 22:50:01 -0000 1.3
@@ -105,19 +105,19 @@
}
SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile, char **enc) {
+ SplashFontSrc *src,
+ char **enc) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_T1LIB_H
if (!fontFile && t1Engine) {
- fontFile = t1Engine->loadType1Font(idA, fileName, deleteFile, enc);
+ fontFile = t1Engine->loadType1Font(idA, src, enc);
}
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
- fontFile = ftEngine->loadType1Font(idA, fileName, deleteFile, enc);
+ fontFile = ftEngine->loadType1Font(idA, src, enc);
}
#endif
@@ -126,29 +126,26 @@
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
- if (deleteFile) {
- unlink(fontFile ? fontFile->fileName->getCString() : fileName);
- }
+ src->unref();
#endif
return fontFile;
}
SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
char **enc) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_T1LIB_H
if (!fontFile && t1Engine) {
- fontFile = t1Engine->loadType1CFont(idA, fileName, deleteFile, enc);
+ fontFile = t1Engine->loadType1CFont(idA, src, enc);
}
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
- fontFile = ftEngine->loadType1CFont(idA, fileName, deleteFile, enc);
+ fontFile = ftEngine->loadType1CFont(idA, src, enc);
}
#endif
@@ -157,23 +154,20 @@
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
- if (deleteFile) {
- unlink(fontFile ? fontFile->fileName->getCString() : fileName);
- }
+ src->unref();
#endif
return fontFile;
}
SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile) {
+ SplashFontSrc *src) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
- fontFile = ftEngine->loadCIDFont(idA, fileName, deleteFile);
+ fontFile = ftEngine->loadCIDFont(idA, src);
}
#endif
@@ -182,26 +176,24 @@
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
- if (deleteFile) {
- unlink(fontFile ? fontFile->fileName->getCString() : fileName);
- }
+ src->unref();
#endif
return fontFile;
}
SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
Gushort *codeToGID,
- int codeToGIDLen) {
+ int codeToGIDLen,
+ int faceIndex) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
- fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile,
- codeToGID, codeToGIDLen);
+ fontFile = ftEngine->loadTrueTypeFont(idA, src,
+ codeToGID, codeToGIDLen, faceIndex);
}
#endif
@@ -214,9 +206,7 @@
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
- if (deleteFile) {
- unlink(fontFile ? fontFile->fileName->getCString() : fileName);
- }
+ src->unref();
#endif
return fontFile;
Index: SplashFontEngine.h
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFontEngine.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SplashFontEngine.h 3 Mar 2005 19:45:59 -0000 1.1.1.1
+++ SplashFontEngine.h 2 Feb 2006 22:50:01 -0000 1.2
@@ -19,6 +19,7 @@
class SplashFontFile;
class SplashFontFileID;
class SplashFont;
+class SplashFontSrc;
//------------------------------------------------------------------------
@@ -48,15 +49,12 @@
SplashFontFile *getFontFile(SplashFontFileID *id);
// Load fonts - these create new SplashFontFile objects.
- SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
- GBool deleteFile, char **enc);
- SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
- GBool deleteFile, char **enc);
- SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
- GBool deleteFile);
- SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
- GBool deleteFile,
- Gushort *codeToGID, int codeToGIDLen);
+ SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
+ SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc);
+ SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src);
+ SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
+ Gushort *codeToGID, int codeToGIDLen,
+ int faceIndex=0);
// Get a font - this does a cache lookup first, and if not found,
// creates a new SplashFont object and adds it to the cache. The
Index: SplashFontFile.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFontFile.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashFontFile.cc 8 Dec 2005 18:17:42 -0000 1.2
+++ SplashFontFile.cc 2 Feb 2006 22:50:01 -0000 1.3
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <unistd.h>
+#include "goo/gmem.h"
#include "goo/GooString.h"
#include "SplashFontFile.h"
#include "SplashFontFileID.h"
@@ -26,19 +27,15 @@
// SplashFontFile
//------------------------------------------------------------------------
-SplashFontFile::SplashFontFile(SplashFontFileID *idA, char *fileNameA,
- GBool deleteFileA) {
+SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) {
id = idA;
- fileName = new GooString(fileNameA);
- deleteFile = deleteFileA;
+ src = srcA;
+ src->ref();
refCnt = 0;
}
SplashFontFile::~SplashFontFile() {
- if (deleteFile) {
- unlink(fileName->getCString());
- }
- delete fileName;
+ src->unref();
delete id;
}
@@ -51,3 +48,60 @@
delete this;
}
}
+
+//
+
+SplashFontSrc::SplashFontSrc() {
+ isFile = gFalse;
+ deleteSrc = gFalse;
+ fileName = NULL;
+ buf = NULL;
+ refcnt = 1;
+}
+
+SplashFontSrc::~SplashFontSrc() {
+ if (deleteSrc) {
+ if (isFile) {
+ if (fileName)
+ unlink(fileName->getCString());
+ } else {
+ if (buf)
+ gfree(buf);
+ }
+ }
+
+ if (isFile && fileName)
+ delete fileName;
+}
+
+void SplashFontSrc::ref() {
+ refcnt++;
+}
+
+void SplashFontSrc::unref() {
+ if (! --refcnt)
+ delete this;
+}
+
+void SplashFontSrc::setFile(GooString *file, GBool del)
+{
+ isFile = gTrue;
+ fileName = file->copy();
+ deleteSrc = del;
+}
+
+void SplashFontSrc::setFile(const char *file, GBool del)
+{
+ isFile = gTrue;
+ fileName = new GooString(file);
+ deleteSrc = del;
+}
+
+void SplashFontSrc::setBuf(char *bufA, int bufLenA, GBool del)
+{
+ isFile = gFalse;
+ buf = bufA;
+ bufLen = bufLenA;
+ deleteSrc = del;
+}
+
Index: SplashFontFile.h
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFontFile.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SplashFontFile.h 3 Mar 2005 19:45:59 -0000 1.1.1.1
+++ SplashFontFile.h 2 Feb 2006 22:50:01 -0000 1.2
@@ -23,6 +23,25 @@
// SplashFontFile
//------------------------------------------------------------------------
+struct SplashFontSrc {
+ SplashFontSrc();
+ ~SplashFontSrc();
+
+ void setFile(GooString *file, GBool del);
+ void setFile(const char *file, GBool del);
+ void setBuf(char *bufA, int buflenA, GBool del);
+
+ void ref();
+ void unref();
+
+ GBool isFile;
+ GooString *fileName;
+ char *buf;
+ int bufLen;
+ GBool deleteSrc;
+ int refcnt;
+};
+
class SplashFontFile {
public:
@@ -44,12 +63,10 @@
protected:
- SplashFontFile(SplashFontFileID *idA, char *fileNameA,
- GBool deleteFileA);
+ SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA);
SplashFontFileID *id;
- GooString *fileName;
- GBool deleteFile;
+ SplashFontSrc *src;
int refCnt;
friend class SplashFontEngine;
Index: SplashT1FontEngine.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashT1FontEngine.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SplashT1FontEngine.cc 3 Mar 2005 19:46:00 -0000 1.1.1.1
+++ SplashT1FontEngine.cc 2 Feb 2006 22:50:01 -0000 1.2
@@ -82,22 +82,26 @@
}
SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
char **enc) {
- return SplashT1FontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
+ return SplashT1FontFile::loadType1Font(this, idA, src, enc);
}
SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA,
- char *fileName,
- GBool deleteFile,
+ SplashFontSrc *src,
char **enc) {
FoFiType1C *ff;
GooString *tmpFileName;
FILE *tmpFile;
SplashFontFile *ret;
- if (!(ff = FoFiType1C::load(fileName))) {
+ SplashFontSrc *newsrc;
+
+ if (src->isFile)
+ ff = FoFiType1C::load(src->fileName);
+ else
+ ff = new FoFiType1C(src->buf, src->bufLen, gFalse);
+ if (! ff)
return NULL;
}
tmpFileName = NULL;
@@ -108,16 +112,11 @@
ff->convertToType1(NULL, gTrue, &fileWrite, tmpFile);
delete ff;
fclose(tmpFile);
- ret = SplashT1FontFile::loadType1Font(this, idA, tmpFileName->getCString(),
- gTrue, enc);
- if (ret) {
- if (deleteFile) {
- unlink(fileName);
- }
- } else {
- unlink(tmpFileName->getCString());
- }
+ newsrc = new SplashFontSrc;
+ newsrc->setFile(tmpFileName, gTrue);
delete tmpFileName;
+ ret = SplashT1FontFile::loadType1Font(this, idA, newsrc, enc);
+ newsrc->unref();
return ret;
}
Index: SplashT1FontFile.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashT1FontFile.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashT1FontFile.cc 27 Aug 2005 08:43:43 -0000 1.2
+++ SplashT1FontFile.cc 2 Feb 2006 22:50:01 -0000 1.3
@@ -25,8 +25,7 @@
SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA,
- GBool deleteFileA,
+ SplashFontSrc *src,
char **encA) {
int t1libIDA;
char **encTmp;
@@ -34,9 +33,27 @@
int encStrSize;
char *encPtr;
int i;
+ GString *fileNameA;
+ SplashFontSrc *newsrc = NULL;
+ SplashFontFile *ff;
+ if (! src->isFile) {
+ GString *tmpFileName;
+ FILE *tmpFile;
+ if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL))
+ return NULL;
+ fwrite(src->buf, 1, src->bufLen, tmpFile);
+ fclose(tmpFile);
+ newsrc = new SplashFontSrc;
+ newsrc->setFile(tmpFileName, gTrue);
+ src = newsrc;
+ delete tmpFileName;
+ }
+ fileNameA = src->fileName;
// load the font file
if ((t1libIDA = T1_AddFont(fileNameA)) < 0) {
+ if (newsrc)
+ delete newsrc;
return NULL;
}
T1_LoadFont(t1libIDA);
@@ -63,15 +80,18 @@
encTmp[256] = "custom";
T1_ReencodeFont(t1libIDA, encTmp);
- return new SplashT1FontFile(engineA, idA, fileNameA, deleteFileA,
+ ff = new SplashT1FontFile(engineA, idA, src,
t1libIDA, encTmp, encStrTmp);
+ if (newsrc)
+ newsrc->unref();
+ return ff;
}
SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA, GBool deleteFileA,
+ SplashFontSrc *srcA,
int t1libIDA, char **encA, char *encStrA):
- SplashFontFile(idA, fileNameA, deleteFileA)
+ SplashFontFile(idA, srcA)
{
engine = engineA;
t1libID = t1libIDA;
Index: SplashT1FontFile.h
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashT1FontFile.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SplashT1FontFile.h 3 Mar 2005 19:45:59 -0000 1.1.1.1
+++ SplashT1FontFile.h 2 Feb 2006 22:50:01 -0000 1.2
@@ -26,7 +26,7 @@
static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA, GBool deleteFileA,
+ SplashFontSrc *src,
char **encA);
virtual ~SplashT1FontFile();
@@ -39,7 +39,7 @@
SplashT1FontFile(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
- char *fileNameA, GBool deleteFileA,
+ SplashFontSrc *src,
int t1libIDA, char **encA, char *encStrA);
SplashT1FontEngine *engine;
- Previous message: [poppler] poppler: ChangeLog,1.299,1.300
- Next message: [poppler] poppler/poppler: GfxFont.cc, 1.6, 1.7 GfxFont.h, 1.2,
1.3 GlobalParams.cc, 1.15, 1.16 GlobalParams.h, 1.5,
1.6 SplashOutputDev.cc, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the poppler
mailing list