fofi/FoFiIdentifier.cc | 2 +- fofi/FoFiTrueType.cc | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)
New commits: commit 4d4318e258fb68704b1a51a14fa89134606e2aa7 Author: Carlos Garcia Campos <[email protected]> Date: Wed Aug 31 17:07:25 2011 +0200 xpdf303: Different growing strategy for vmtxTab in FoFiTrueType diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index 958f35c..7114b78 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -1702,7 +1702,7 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, length = sizeof(vheaTab); checksum = computeTableChecksum(vheaTab, length); } else if (needVerticalMetrics && i == t42VmtxTable) { - length = 4 + (nGlyphs - 1) * 4; + length = 4 + (nGlyphs - 1) * 2; vmtxTab = (Guchar *)gmalloc(length); vmtxTab[0] = advance / 256; vmtxTab[1] = advance % 256; commit c8c7fcef9bc8f802be2d376c9d2099971f159317 Author: Carlos Garcia Campos <[email protected]> Date: Wed Aug 31 17:05:16 2011 +0200 xpdf303: Fix memory leak in FoFiTrueType diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index 79e3b68..958f35c 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -1820,7 +1820,6 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, dumpString(vheaTab, length, outputFunc, outputStream); } else if (needVerticalMetrics && i == t42VmtxTable) { dumpString(vmtxTab, length, outputFunc, outputStream); - gfree(vmtxTab); } } } @@ -1831,6 +1830,9 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, gfree(locaData); gfree(locaTable); + if (vmtxTab) { + gfree(vmtxTab); + } } void FoFiTrueType::dumpString(Guchar *s, int length, commit 655b1a97db5449c009e5b63fc7c12233e6fae450 Author: Carlos Garcia Campos <[email protected]> Date: Wed Aug 31 16:54:05 2011 +0200 xpdf303: Check for an invalid loca format field in the head table in FoFiTrueType diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index fecbd34..79e3b68 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -1575,6 +1575,13 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, memcpy(headData, file + pos, 54); headData[8] = headData[9] = headData[10] = headData[11] = (Guchar)0; + // check for a bogus loca format field in the 'head' table + // (I've encountered fonts with loca format set to 0x0100 instead of 0x0001) + if (locaFmt != 0 && locaFmt != 1) { + headData[50] = 0; + headData[51] = 1; + } + // read the original 'loca' table, pad entries out to 4 bytes, and // sort it into proper order -- some (non-compliant) fonts have // out-of-order loca tables; in order to correctly handle the case commit 9710ab96f1cf26394cc473952a3331d60c149451 Author: Carlos Garcia Campos <[email protected]> Date: Wed Aug 31 16:49:54 2011 +0200 Fix the build diff --git a/fofi/FoFiIdentifier.cc b/fofi/FoFiIdentifier.cc index 0864a23..d8ee7e0 100644 --- a/fofi/FoFiIdentifier.cc +++ b/fofi/FoFiIdentifier.cc @@ -13,7 +13,7 @@ #include <stdio.h> #include <string.h> #include <limits.h> -#include "gtypes.h" +#include "goo/gtypes.h" #include "FoFiIdentifier.h" //------------------------------------------------------------------------ commit 36b733a3165fd26aa8c25ba57faa5d2277aa31ec Author: Carlos Garcia Campos <[email protected]> Date: Tue Aug 30 16:31:52 2011 +0200 xpdf303: Handle bogus loca table entries in FoFiTrueType where the offset is past the end of the glyf table. This part was missing in previous commit. diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index 4cede12..fecbd34 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -1539,7 +1539,7 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, GBool ok; Guint checksum; int nNewTables; - int length, pos, glyfPos, i, j, k; + int glyfTableLen, length, pos, glyfPos, i, j, k; Guchar vheaTab[36] = { 0, 1, 0, 0, // table version number 0, 0, // ascent @@ -1579,12 +1579,14 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, // sort it into proper order -- some (non-compliant) fonts have // out-of-order loca tables; in order to correctly handle the case // where (compliant) fonts have empty entries in the middle of the - // table, cmpTrueTypeLocaPos uses offset as its primary sort key, + // table, cmpTrueTypeLocaOffset uses offset as its primary sort key, // and idx as its secondary key (ensuring that adjacent entries with // the same pos value remain in the same order) locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + 1, sizeof(TrueTypeLoca)); i = seekTable("loca"); pos = tables[i].offset; + i = seekTable("glyf"); + glyfTableLen = tables[i].len; ok = gTrue; for (i = 0; i <= nGlyphs; ++i) { locaTable[i].idx = i; @@ -1593,6 +1595,9 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, } else { locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok); } + if (locaTable[i].origOffset > glyfTableLen) { + locaTable[i].origOffset = glyfTableLen; + } } std::sort(locaTable, locaTable + nGlyphs + 1, cmpTrueTypeLocaOffsetFunctor()); _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
