[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
Albert Astals Cid
aacid at freedesktop.org
Thu Feb 2 14:50:04 PST 2006
- Previous message: [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
- Next message: [poppler] poppler: ChangeLog,1.300,1.301
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv24658/poppler
Modified Files:
GfxFont.cc GfxFont.h GlobalParams.cc GlobalParams.h
SplashOutputDev.cc
Log Message:
don't use files to pass fonts to freetype
Index: GfxFont.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- GfxFont.cc 18 Jan 2006 22:32:13 -0000 1.6
+++ GfxFont.cc 2 Feb 2006 22:50:01 -0000 1.7
@@ -361,7 +361,7 @@
void GfxFont::findExtFontFile() {
static char *type1Exts[] = { ".pfa", ".pfb", ".ps", "", NULL };
- static char *ttExts[] = { ".ttf", NULL };
+ static char *ttExts[] = { ".ttf", ".ttc", NULL };
if (name) {
if (type == fontType1) {
@@ -1522,6 +1522,53 @@
return cMap ? cMap->getCollection() : (GooString *)NULL;
}
+Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
+ Gushort *map;
+ int cmapPlatform, cmapEncoding;
+ int unicodeCmap, macRomanCmap, msSymbolCmap, cmap;
+ GBool useMacRoman, useUnicode;
+ char *charName;
+ Unicode u;
+ int code, i;
+ int mapsize;
+ int cidlen;
+
+ *mapsizep = 0;
+
+ /* we use only unicode cmap */
+ cmap = -1;
+ for (i = 0; i < ff->getNumCmaps(); ++i) {
+ cmapPlatform = ff->getCmapPlatform(i);
+ cmapEncoding = ff->getCmapEncoding(i);
+ if ((cmapPlatform == 3 && cmapEncoding == 1) || cmapPlatform == 0)
+ cmap = i;
+ }
+ if (cmap < 0)
+ return NULL;
+
+ cidlen = 0;
+ mapsize = 64;
+ map = (Gushort *)gmalloc(mapsize * sizeof(Gushort));
+
+ while (cidlen < ctu->getLength()) {
+ int n;
+ if ((n = ctu->mapToUnicode((CharCode)cidlen, &u, 1)) == 0) {
+ cidlen++;
+ continue;
+ }
+ if (cidlen >= mapsize) {
+ while (cidlen >= mapsize)
+ mapsize *= 2;
+ map = (Gushort *)grealloc(map, mapsize * sizeof(Gushort));
+ }
+ map[cidlen] = ff->mapCodeToGID(cmap, u);
+ cidlen++;
+ }
+
+ *mapsizep = cidlen;
+ return map;
+}
+
//------------------------------------------------------------------------
// GfxFontDict
//------------------------------------------------------------------------
Index: GfxFont.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- GfxFont.h 6 Jul 2005 17:12:36 -0000 1.2
+++ GfxFont.h 2 Feb 2006 22:50:01 -0000 1.3
@@ -310,6 +310,8 @@
Gushort *getCIDToGID() { return cidToGID; }
int getCIDToGIDLen() { return cidToGIDLen; }
+ Gushort *getCodeToGIDMap(FoFiTrueType *ff, int *length);
+
private:
CMap *cMap; // char code --> CID
Index: GlobalParams.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GlobalParams.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- GlobalParams.cc 1 Feb 2006 03:52:12 -0000 1.15
+++ GlobalParams.cc 2 Feb 2006 22:50:01 -0000 1.16
@@ -1278,6 +1278,7 @@
{
dfp = new DisplayFontParam(fontName->copy(), displayFontTT);
dfp->tt.fileName = new GooString((char*)s);
+ FcPatternGetInteger(m, FC_INDEX, 0, &(dfp->tt.faceIndex));
}
else if (!strncasecmp(ext,".pfa",4) || !strncasecmp(ext,".pfb",4))
{
Index: GlobalParams.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GlobalParams.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- GlobalParams.h 20 Sep 2005 14:00:43 -0000 1.5
+++ GlobalParams.h 2 Feb 2006 22:50:01 -0000 1.6
@@ -55,6 +55,7 @@
struct DisplayFontParamTT {
GooString *fileName;
+ int faceIndex;
};
class DisplayFontParam {
Index: SplashOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/SplashOutputDev.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- SplashOutputDev.cc 30 Oct 2005 20:29:05 -0000 1.4
+++ SplashOutputDev.cc 2 Feb 2006 22:50:01 -0000 1.5
@@ -941,10 +941,13 @@
GfxFontType fontType;
SplashOutFontFileID *id;
SplashFontFile *fontFile;
+ SplashFontSrc *fontsrc;
FoFiTrueType *ff;
Ref embRef;
Object refObj, strObj;
- GooString *tmpFileName, *fileName, *substName;
+ GooString *fileName, *substName;
+ char *tmpBuf;
+ int tmpBufLen;
FILE *tmpFile;
Gushort *codeToGID;
DisplayFontParam *dfp;
@@ -954,10 +957,12 @@
char *name;
Unicode uBuf[8];
int c, substIdx, n, code, cmap;
+ int faceIndex = 0;
needFontUpdate = gFalse;
font = NULL;
- tmpFileName = NULL;
+ fileName = NULL;
+ tmpBuf = NULL;
substIdx = -1;
dfp = NULL;
@@ -978,22 +983,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())) {
@@ -1016,18 +1008,23 @@
case displayFontTT:
fileName = dfp->tt.fileName;
fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType;
+ faceIndex = dfp->tt.faceIndex;
break;
}
}
+ 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)");
@@ -1035,11 +1032,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)");
@@ -1047,7 +1042,8 @@
}
break;
case fontTrueType:
- if ((ff = FoFiTrueType::load(fileName->getCString()))) {
+ if ((ff = FoFiTrueType::load(fileName->getCString())) ||
+ (ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse))) {
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
n = 256;
delete ff;
@@ -1057,8 +1053,7 @@
}
if (!(fontFile = fontEngine->loadTrueTypeFont(
id,
- fileName->getCString(),
- fileName == tmpFileName,
+ fontsrc,
codeToGID, n))) {
error(-1, "Couldn't create a font for '%s'",
gfxFont->getName() ? gfxFont->getName()->getCString()
@@ -1068,10 +1063,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)");
@@ -1084,7 +1077,8 @@
if (dfp) {
// create a CID-to-GID mapping, via Unicode
if ((ctu = ((GfxCIDFont *)gfxFont)->getToUnicode())) {
- if ((ff = FoFiTrueType::load(fileName->getCString()))) {
+ if ((ff = FoFiTrueType::load(fileName->getCString())) ||
+ (ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse))) {
// look for a Unicode cmap
for (cmap = 0; cmap < ff->getNumCmaps(); ++cmap) {
if ((ff->getCmapPlatform(cmap) == 3 &&
@@ -1116,16 +1110,28 @@
} else {
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
- codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
- memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
- n * sizeof(Gushort));
+ if (n) {
+ codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
+ memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
+ n * sizeof(Gushort));
+ } else {
+ 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;
+ }
}
}
if (!(fontFile = fontEngine->loadTrueTypeFont(
id,
- fileName->getCString(),
- fileName == tmpFileName,
- codeToGID, n))) {
+ fontsrc,
+ codeToGID,
+ n,
+ faceIndex))) {
error(-1, "Couldn't create a font for '%s'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
@@ -1153,17 +1159,11 @@
}
font = fontEngine->getFont(fontFile, mat);
- if (tmpFileName) {
- delete tmpFileName;
- }
return;
err2:
delete id;
err1:
- if (tmpFileName) {
- delete tmpFileName;
- }
return;
}
- Previous message: [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
- Next message: [poppler] poppler: ChangeLog,1.300,1.301
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the poppler
mailing list