fofi/FoFiType1.cc | 36 ++++++++++++++++++++++++++++++++++++ fofi/FoFiType1.h | 1 + 2 files changed, 37 insertions(+)
New commits: commit 44dbb28a07125f92a0835aea7ad3403310bc451d Author: Carlos Garcia Campos <[email protected]> Date: Fri Sep 2 18:08:39 2011 +0200 xpdf303: Handle PFB headers in Type 1 font files diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc index d47f543..d256c9c 100644 --- a/fofi/FoFiType1.cc +++ b/fofi/FoFiType1.cc @@ -66,6 +66,7 @@ FoFiType1::FoFiType1(char *fileA, int lenA, GBool freeFileDataA): fontMatrix[4] = 0; fontMatrix[5] = 0; parsed = gFalse; + undoPFB(); } FoFiType1::~FoFiType1() { @@ -325,3 +326,38 @@ void FoFiType1::parse() { parsed = gTrue; } + +// Undo the PFB encoding, i.e., remove the PFB headers. +void FoFiType1::undoPFB() { + GBool ok; + Guchar *file2; + int pos1, pos2, type; + Guint segLen; + + ok = gTrue; + if (getU8(0, &ok) != 0x80 || !ok) { + return; + } + file2 = (Guchar *)gmalloc(len); + pos1 = pos2 = 0; + while (getU8(pos1, &ok) == 0x80 && ok) { + type = getU8(pos1 + 1, &ok); + if (type < 1 || type > 2 || !ok) { + break; + } + segLen = getU32LE(pos1 + 2, &ok); + pos1 += 6; + if (!ok || !checkRegion(pos1, segLen)) { + break; + } + memcpy(file2 + pos2, file + pos1, segLen); + pos1 += segLen; + pos2 += segLen; + } + if (freeFileData) { + gfree(fileData); + } + file = fileData = file2; + freeFileData = gTrue; + len = pos2; +} diff --git a/fofi/FoFiType1.h b/fofi/FoFiType1.h index ae1d73b..f4e29b4 100644 --- a/fofi/FoFiType1.h +++ b/fofi/FoFiType1.h @@ -51,6 +51,7 @@ private: char *getNextLine(char *line); void parse(); + void undoPFB(); char *name; char **encoding; _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
