Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 63959 Details for
Bug 99769
app-text/xpdf another issue (CAN-2005-2097)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
xpdf-font-optimize.dif
xpdf-font-optimize.dif (text/plain), 28.00 KB, created by
Sune Kloppenborg Jeppesen (RETIRED)
on 2005-07-21 03:09:35 UTC
(
hide
)
Description:
xpdf-font-optimize.dif
Filename:
MIME Type:
Creator:
Sune Kloppenborg Jeppesen (RETIRED)
Created:
2005-07-21 03:09:35 UTC
Size:
28.00 KB
patch
obsolete
>diff -ru xpdf-3.00-dist/fofi/FoFiTrueType.h xpdf-3.00/fofi/FoFiTrueType.h >--- xpdf-3.00-dist/fofi/FoFiTrueType.h 2004-05-10 17:41:22.949471000 +0200 >+++ xpdf-3.00/fofi/FoFiTrueType.h 2004-05-10 20:17:28.408273921 +0200 >@@ -35,6 +35,7 @@ > // Create a FoFiTrueType object from a file on disk. > static FoFiTrueType *load(char *fileName, int faceIndexA=0); > >+ FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA=0); > virtual ~FoFiTrueType(); > > // Return the number of cmaps defined by this font. >@@ -100,7 +101,6 @@ > > private: > >- FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA=0); > void cvtEncoding(char **encoding, > FoFiOutputFunc outputFunc, > void *outputStream); >diff -ru xpdf-3.00-dist/fofi/FoFiType1C.h xpdf-3.00/fofi/FoFiType1C.h >--- xpdf-3.00-dist/fofi/FoFiType1C.h 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/fofi/FoFiType1C.h 2004-05-10 20:11:04.972360896 +0200 >@@ -135,6 +135,7 @@ > // Create a FoFiType1C object from a file on disk. > static FoFiType1C *load(char *fileName); > >+ FoFiType1C(char *fileA, int lenA, GBool freeFileDataA); > virtual ~FoFiType1C(); > > // Return the font name. >@@ -170,7 +171,6 @@ > > private: > >- FoFiType1C(char *fileA, int lenA, GBool freeFileDataA); > void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName, > int offset, int nBytes, > Type1CIndex *subrIdx, >diff -ru xpdf-3.00-dist/splash/SplashFTFontEngine.cc xpdf-3.00/splash/SplashFTFontEngine.cc >--- xpdf-3.00-dist/splash/SplashFTFontEngine.cc 2004-05-10 17:41:22.949471000 +0200 >+++ xpdf-3.00/splash/SplashFTFontEngine.cc 2004-05-10 20:11:22.994266800 +0200 >@@ -59,37 +59,38 @@ > } > > 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; > SplashFontFile *ret; > > // check for a CFF font >- if ((ff = FoFiType1C::load(fileName))) { >+ 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); > } >@@ -97,11 +98,11 @@ > } > > SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > Gushort *codeToGID, > int codeToGIDLen, > int faceIndex) { >+#if 0 > FoFiTrueType *ff; > GString *tmpFileName; > FILE *tmpFile; >@@ -120,7 +121,8 @@ > fclose(tmpFile); > ret = SplashFTFontFile::loadTrueTypeFont(this, idA, > tmpFileName->getCString(), >- gTrue, codeToGID, codeToGIDLen); >+ gTrue, codeToGID, codeToGIDLen, >+ faceIndex); > if (ret) { > if (deleteFile) { > unlink(fileName); >@@ -130,6 +132,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 >diff -ru xpdf-3.00-dist/splash/SplashFTFontEngine.h xpdf-3.00/splash/SplashFTFontEngine.h >--- xpdf-3.00-dist/splash/SplashFTFontEngine.h 2004-05-10 17:41:22.949471000 +0200 >+++ xpdf-3.00/splash/SplashFTFontEngine.h 2004-05-10 20:11:34.498653362 +0200 >@@ -21,6 +21,7 @@ > > class SplashFontFile; > class SplashFontFileID; >+class SplashFontSrc; > > //------------------------------------------------------------------------ > // SplashFTFontEngine >@@ -34,14 +35,10 @@ > ~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, >+ 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); > >diff -ru xpdf-3.00-dist/splash/SplashFTFontFile.cc xpdf-3.00/splash/SplashFTFontFile.cc >--- xpdf-3.00-dist/splash/SplashFTFontFile.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashFTFontFile.cc 2004-05-10 20:32:37.079860584 +0200 >@@ -16,6 +16,7 @@ > #include "SplashFTFontEngine.h" > #include "SplashFTFont.h" > #include "SplashFTFontFile.h" >+#include "GString.h" > > //------------------------------------------------------------------------ > // SplashFTFontFile >@@ -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 *)gmalloc(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; >diff -ru xpdf-3.00-dist/splash/SplashFTFontFile.h xpdf-3.00/splash/SplashFTFontFile.h >--- xpdf-3.00-dist/splash/SplashFTFontFile.h 2004-05-10 17:41:22.939474000 +0200 >+++ xpdf-3.00/splash/SplashFTFontFile.h 2004-05-10 19:32:26.463323990 +0200 >@@ -30,18 +30,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, >+ 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(); > >@@ -53,7 +53,7 @@ > > SplashFTFontFile(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *srcA, > FT_Face faceA, > Gushort *codeToGIDA, int codeToGIDLenA); > >diff -ru xpdf-3.00-dist/splash/SplashFontEngine.cc xpdf-3.00/splash/SplashFontEngine.cc >--- xpdf-3.00-dist/splash/SplashFontEngine.cc 2004-05-10 17:41:22.950471000 +0200 >+++ xpdf-3.00/splash/SplashFontEngine.cc 2004-05-10 20:15:19.348582076 +0200 >@@ -105,19 +105,18 @@ > } > > 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 > >@@ -125,28 +124,25 @@ > // 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(); > > 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 > >@@ -154,22 +150,19 @@ > // 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(); > > 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 > >@@ -177,16 +170,13 @@ > // 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(); > > return fontFile; > } > > SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > Gushort *codeToGID, > int codeToGIDLen, > int faceIndex) { >@@ -195,7 +185,7 @@ > fontFile = NULL; > #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H > if (!fontFile && ftEngine) { >- fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile, >+ fontFile = ftEngine->loadTrueTypeFont(idA, src, > codeToGID, codeToGIDLen, faceIndex); > } > #endif >@@ -208,9 +198,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(); > > return fontFile; > } >diff -ru xpdf-3.00-dist/splash/SplashFontEngine.h xpdf-3.00/splash/SplashFontEngine.h >--- xpdf-3.00-dist/splash/SplashFontEngine.h 2004-05-10 17:41:22.950471000 +0200 >+++ xpdf-3.00/splash/SplashFontEngine.h 2004-05-10 20:14:51.040011194 +0200 >@@ -21,6 +21,7 @@ > class SplashFontFile; > class SplashFontFileID; > class SplashFont; >+class SplashFontSrc; > > //------------------------------------------------------------------------ > >@@ -50,14 +51,10 @@ > 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, >+ 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); > >diff -ru xpdf-3.00-dist/splash/SplashFontFile.cc xpdf-3.00/splash/SplashFontFile.cc >--- xpdf-3.00-dist/splash/SplashFontFile.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashFontFile.cc 2004-05-10 20:41:01.232292315 +0200 >@@ -17,6 +17,7 @@ > #include "GString.h" > #include "SplashFontFile.h" > #include "SplashFontFileID.h" >+#include "gmem.h" > > #ifdef VMS > #if (__VMS_VER < 70000000) >@@ -28,19 +29,15 @@ > // SplashFontFile > //------------------------------------------------------------------------ > >-SplashFontFile::SplashFontFile(SplashFontFileID *idA, char *fileNameA, >- GBool deleteFileA) { >+SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) { > id = idA; >- fileName = new GString(fileNameA); >- deleteFile = deleteFileA; >+ src = srcA; >+ src->ref(); > refCnt = 0; > } > > SplashFontFile::~SplashFontFile() { >- if (deleteFile) { >- unlink(fileName->getCString()); >- } >- delete fileName; >+ src->unref(); > delete id; > } > >@@ -53,3 +50,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(GString *file, GBool del) >+{ >+ isFile = gTrue; >+ fileName = file->copy(); >+ deleteSrc = del; >+} >+ >+void SplashFontSrc::setFile(const char *file, GBool del) >+{ >+ isFile = gTrue; >+ fileName = new GString(file); >+ deleteSrc = del; >+} >+ >+void SplashFontSrc::setBuf(char *bufA, int bufLenA, GBool del) >+{ >+ isFile = gFalse; >+ buf = bufA; >+ bufLen = bufLenA; >+ deleteSrc = del; >+} >+ >diff -ru xpdf-3.00-dist/splash/SplashFontFile.h xpdf-3.00/splash/SplashFontFile.h >--- xpdf-3.00-dist/splash/SplashFontFile.h 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashFontFile.h 2004-05-10 20:08:31.770168702 +0200 >@@ -25,6 +25,25 @@ > // SplashFontFile > //------------------------------------------------------------------------ > >+struct SplashFontSrc { >+ SplashFontSrc(); >+ ~SplashFontSrc(); >+ >+ void setFile(GString *file, GBool del); >+ void setFile(const char *file, GBool del); >+ void setBuf(char *bufA, int buflenA, GBool del); >+ >+ void ref(); >+ void unref(); >+ >+ GBool isFile; >+ GString *fileName; >+ char *buf; >+ int bufLen; >+ GBool deleteSrc; >+ int refcnt; >+}; >+ > class SplashFontFile { > public: > >@@ -46,12 +65,10 @@ > > protected: > >- SplashFontFile(SplashFontFileID *idA, char *fileNameA, >- GBool deleteFileA); >+ SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA); > > SplashFontFileID *id; >- GString *fileName; >- GBool deleteFile; >+ SplashFontSrc *src; > int refCnt; > > friend class SplashFontEngine; >diff -ru xpdf-3.00-dist/splash/SplashT1FontEngine.cc xpdf-3.00/splash/SplashT1FontEngine.cc >--- xpdf-3.00-dist/splash/SplashT1FontEngine.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashT1FontEngine.cc 2004-05-10 19:57:05.300244166 +0200 >@@ -82,24 +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; > GString *tmpFileName; > FILE *tmpFile; > SplashFontFile *ret; >+ SplashFontSrc *newsrc; > >- if (!(ff = FoFiType1C::load(fileName))) { >+ if (src->isFile) >+ ff = FoFiType1C::load(src->fileName); >+ else >+ ff = new FoFiType1C(src->buf, src->bufLen, gFalse); >+ if (! ff) > return NULL; >- } > tmpFileName = NULL; > if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) { > delete ff; >@@ -108,16 +110,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; > } > >diff -ru xpdf-3.00-dist/splash/SplashT1FontFile.cc xpdf-3.00/splash/SplashT1FontFile.cc >--- xpdf-3.00-dist/splash/SplashT1FontFile.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashT1FontFile.cc 2004-05-10 20:37:08.106264053 +0200 >@@ -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; >diff -ru xpdf-3.00-dist/splash/SplashT1FontFile.h xpdf-3.00/splash/SplashT1FontFile.h >--- xpdf-3.00-dist/splash/SplashT1FontFile.h 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashT1FontFile.h 2004-05-10 19:39:07.153270918 +0200 >@@ -28,7 +28,7 @@ > > static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *src, > char **encA); > > virtual ~SplashT1FontFile(); >@@ -41,7 +41,7 @@ > > SplashT1FontFile(SplashT1FontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *src, > int t1libIDA, char **encA, char *encStrA); > > SplashT1FontEngine *engine; >diff -ru xpdf-3.00-dist/xpdf/SplashOutputDev.cc xpdf-3.00/xpdf/SplashOutputDev.cc >--- xpdf-3.00-dist/xpdf/SplashOutputDev.cc 2004-05-10 17:41:22.955470000 +0200 >+++ xpdf-3.00/xpdf/SplashOutputDev.cc 2004-05-10 20:17:17.997637930 +0200 >@@ -490,10 +490,13 @@ > GfxFontType fontType; > SplashOutFontFileID *id; > SplashFontFile *fontFile; >+ SplashFontSrc *fontsrc; > FoFiTrueType *ff; > Ref embRef; > Object refObj, strObj; >- GString *tmpFileName, *fileName, *substName; >+ GString *fileName, *substName; >+ char *tmpBuf; >+ int tmpBufLen; > FILE *tmpFile; > Gushort *codeToGID; > DisplayFontParam *dfp; >@@ -505,7 +508,8 @@ > > needFontUpdate = gFalse; > font = NULL; >- tmpFileName = NULL; >+ fileName = NULL; >+ tmpBuf = NULL; > substIdx = -1; > > if (!(gfxFont = state->getFont())) { >@@ -525,22 +529,9 @@ > > // if there is an embedded font, write it to disk > if (gfxFont->getEmbeddedFontID(&embRef)) { >- if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) { >- error(-1, "Couldn't create temporary font file"); >+ tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); >+ if (! tmpBuf) > goto err2; >- } >- refObj.initRef(embRef.num, embRef.gen); >- refObj.fetch(xref, &strObj); >- refObj.free(); >- strObj.streamReset(); >- while ((c = strObj.streamGetChar()) != EOF) { >- fputc(c, tmpFile); >- } >- strObj.streamClose(); >- strObj.free(); >- fclose(tmpFile); >- fileName = tmpFileName; >- > // if there is an external font file, use it > } else if (!(fileName = gfxFont->getExtFontFile())) { > >@@ -596,14 +587,18 @@ > } > } > >+ fontsrc = new SplashFontSrc; >+ if (fileName) >+ fontsrc->setFile(fileName, gFalse); >+ else >+ fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse); >+ > // load the font file > switch (fontType) { > case fontType1: >- if (!(fontFile = fontEngine->loadType1Font( >- id, >- fileName->getCString(), >- fileName == tmpFileName, >- ((Gfx8BitFont *)gfxFont)->getEncoding()))) { >+ fontFile = fontEngine->loadType1Font(id, fontsrc, >+ ((Gfx8BitFont *)gfxFont)->getEncoding()); >+ if (! fontFile) { > error(-1, "Couldn't create a font for '%s'", > gfxFont->getName() ? gfxFont->getName()->getCString() > : "(unnamed)"); >@@ -611,11 +606,9 @@ > } > break; > case fontType1C: >- if (!(fontFile = fontEngine->loadType1CFont( >- id, >- fileName->getCString(), >- fileName == tmpFileName, >- ((Gfx8BitFont *)gfxFont)->getEncoding()))) { >+ fontFile = fontEngine->loadType1CFont(id, fontsrc, >+ ((Gfx8BitFont *)gfxFont)->getEncoding()); >+ if (! fontFile) { > error(-1, "Couldn't create a font for '%s'", > gfxFont->getName() ? gfxFont->getName()->getCString() > : "(unnamed)"); >@@ -623,16 +616,16 @@ > } > break; > case fontTrueType: >- if (!(ff = FoFiTrueType::load(fileName->getCString()))) { >+ if (fileName) >+ ff = FoFiTrueType::load(fileName->getCString()); >+ else >+ ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse); >+ if (! ff) > goto err2; >- } > codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); > delete ff; >- if (!(fontFile = fontEngine->loadTrueTypeFont( >- id, >- fileName->getCString(), >- fileName == tmpFileName, >- codeToGID, 256))) { >+ fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, 256); >+ if (! fontFile) { > error(-1, "Couldn't create a font for '%s'", > gfxFont->getName() ? gfxFont->getName()->getCString() > : "(unnamed)"); >@@ -641,10 +634,8 @@ > break; > case fontCIDType0: > case fontCIDType0C: >- if (!(fontFile = fontEngine->loadCIDFont( >- id, >- fileName->getCString(), >- fileName == tmpFileName))) { >+ fontFile = fontEngine->loadCIDFont(id, fontsrc); >+ if (! fontFile) { > error(-1, "Couldn't create a font for '%s'", > gfxFont->getName() ? gfxFont->getName()->getCString() > : "(unnamed)"); >@@ -658,18 +649,17 @@ > memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), > n * sizeof(Gushort)); > } else { >- if (!(ff = FoFiTrueType::load(fileName->getCString()))) { >- fprintf(stderr, "failture loading cid2 %s\n", fileName->getCString()); >- goto err2; >- } >- codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); >- delete ff; >- } >- if (!(fontFile = fontEngine->loadTrueTypeFont( >- id, >- fileName->getCString(), >- fileName == tmpFileName, >- codeToGID, n, faceIndex))) { >+ if (fileName) >+ ff = FoFiTrueType::load(fileName->getCString()); >+ else >+ ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse); >+ if (! ff) >+ goto err2; >+ codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); >+ delete ff; >+ } >+ fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n, faceIndex); >+ if (! fontFile) { > error(-1, "Couldn't create a font for '%s'", > gfxFont->getName() ? gfxFont->getName()->getCString() > : "(unnamed)"); >@@ -717,17 +707,11 @@ > mat[2] = m21; mat[3] = -m22; > font = fontEngine->getFont(fontFile, mat); > >- if (tmpFileName) { >- delete tmpFileName; >- } > return; > > err2: > delete id; > err1: >- if (tmpFileName) { >- delete tmpFileName; >- } > return; > } > >@@ -1345,8 +1329,9 @@ > if (dfp->kind != displayFontT1) { > return NULL; > } >- fontFile = fontEngine->loadType1Font(id, dfp->t1.fileName->getCString(), >- gFalse, winAnsiEncoding); >+ SplashFontSrc *fontsrc = new SplashFontSrc; >+ fontsrc->setFile(dfp->t1.fileName, gFalse); >+ fontFile = fontEngine->loadType1Font(id, fontsrc, winAnsiEncoding); > } > > // create the scaled font
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 99769
: 63959 |
65072