"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fofi/FoFiTrueType.cc" between
xpdf-4.02.tar.gz and xpdf-4.03.tar.gz

About: Xpdf is a PDF viewer for X.

FoFiTrueType.cc  (xpdf-4.02):FoFiTrueType.cc  (xpdf-4.03)
skipping to change at line 1733 skipping to change at line 1733
// 1. use encoding to map name to char code // 1. use encoding to map name to char code
// 2. use codeToGID to map char code to glyph index // 2. use codeToGID to map char code to glyph index
// N.B. We do this in reverse order because font subsets can have // N.B. We do this in reverse order because font subsets can have
// weird encodings that use the same character name twice, and // weird encodings that use the same character name twice, and
// the first definition is probably the one we want. // the first definition is probably the one we want.
k = 0; // make gcc happy k = 0; // make gcc happy
for (i = 255; i >= 0; --i) { for (i = 255; i >= 0; --i) {
if (encoding) { if (encoding) {
name = encoding[i]; name = encoding[i];
} else { } else {
sprintf(buf2, "c%02x", i); snprintf(buf2, sizeof(buf2), "c%02x", i);
name = buf2; name = buf2;
} }
if (name && strcmp(name, ".notdef")) { if (name && strcmp(name, ".notdef")) {
k = codeToGID[i]; k = codeToGID[i];
// note: Distiller (maybe Adobe's PS interpreter in general) // note: Distiller (maybe Adobe's PS interpreter in general)
// doesn't like TrueType fonts that have CharStrings entries // doesn't like TrueType fonts that have CharStrings entries
// which point to nonexistent glyphs, hence the (k < nGlyphs) // which point to nonexistent glyphs, hence the (k < nGlyphs)
// test // test
if (k > 0 && k < nGlyphs) { if (k > 0 && k < nGlyphs) {
(*outputFunc)(outputStream, "/", 1); (*outputFunc)(outputStream, "/", 1);
skipping to change at line 2146 skipping to change at line 2146
word |= (data[i ] & 0xff) << 24; word |= (data[i ] & 0xff) << 24;
break; break;
} }
checksum += word; checksum += word;
} }
return checksum; return checksum;
} }
void FoFiTrueType::parse(int fontNum, GBool allowHeadlessCFF) { void FoFiTrueType::parse(int fontNum, GBool allowHeadlessCFF) {
Guint topTag; Guint topTag;
int offset, pos, ver, i, j; int offset, pos, ver, i, j, k;
parsedOk = gTrue; parsedOk = gTrue;
// check for a dfont or TrueType collection (TTC) // check for a dfont or TrueType collection (TTC)
// offset = start of actual TrueType font file (table positions are // offset = start of actual TrueType font file (table positions are
// relative to this // relative to this
// pos = position of table directory (relative to offset) // pos = position of table directory (relative to offset)
if (isDfont) { if (isDfont) {
parseDfont(fontNum, &offset, &pos); parseDfont(fontNum, &offset, &pos);
} else { } else {
skipping to change at line 2209 skipping to change at line 2209
pos += 16; pos += 16;
} }
nTables = j; nTables = j;
if (!parsedOk) { if (!parsedOk) {
return; return;
} }
// check for the head table; allow for a head-less OpenType CFF font // check for the head table; allow for a head-less OpenType CFF font
headlessCFF = gFalse; headlessCFF = gFalse;
if (seekTable("head") < 0) { if (seekTable("head") < 0) {
if (openTypeCFF && allowHeadlessCFF) { if (openTypeCFF && allowHeadlessCFF && seekTable("CFF ") >= 0) {
headlessCFF = gTrue; headlessCFF = gTrue;
nGlyphs = 0; nGlyphs = 0;
bbox[0] = bbox[1] = bbox[2] = bbox[3] = 0; bbox[0] = bbox[1] = bbox[2] = bbox[3] = 0;
locaFmt = 0; locaFmt = 0;
return; return;
} }
parsedOk = gFalse; parsedOk = gFalse;
return; return;
} }
skipping to change at line 2241 skipping to change at line 2241
// read the cmaps // read the cmaps
if ((i = seekTable("cmap")) >= 0 && tables[i].len >= 4) { if ((i = seekTable("cmap")) >= 0 && tables[i].len >= 4) {
pos = tables[i].offset + 2; pos = tables[i].offset + 2;
nCmaps = getU16BE(pos, &parsedOk); nCmaps = getU16BE(pos, &parsedOk);
pos += 2; pos += 2;
if (!parsedOk) { if (!parsedOk) {
return; return;
} }
cmaps = (TrueTypeCmap *)gmallocn(nCmaps, sizeof(TrueTypeCmap)); cmaps = (TrueTypeCmap *)gmallocn(nCmaps, sizeof(TrueTypeCmap));
k = 0;
for (j = 0; j < nCmaps; ++j) { for (j = 0; j < nCmaps; ++j) {
cmaps[j].platform = getU16BE(pos, &parsedOk); cmaps[k].platform = getU16BE(pos, &parsedOk);
cmaps[j].encoding = getU16BE(pos + 2, &parsedOk); cmaps[k].encoding = getU16BE(pos + 2, &parsedOk);
cmaps[j].offset = tables[i].offset + getU32BE(pos + 4, &parsedOk); cmaps[k].offset = getU32BE(pos + 4, &parsedOk);
pos += 8; pos += 8;
cmaps[j].fmt = getU16BE(cmaps[j].offset, &parsedOk); if (cmaps[k].offset >= tables[i].len) {
cmaps[j].len = getU16BE(cmaps[j].offset + 2, &parsedOk); // skip any invalid subtables
continue;
}
cmaps[k].offset += tables[i].offset;
cmaps[k].fmt = getU16BE(cmaps[k].offset, &parsedOk);
cmaps[k].len = getU16BE(cmaps[k].offset + 2, &parsedOk);
++k;
} }
nCmaps = k;
if (!parsedOk) { if (!parsedOk) {
return; return;
} }
} }
// get the number of glyphs from the maxp table // get the number of glyphs from the maxp table
i = seekTable("maxp"); i = seekTable("maxp");
nGlyphs = getU16BE(tables[i].offset + 4, &parsedOk); nGlyphs = getU16BE(tables[i].offset + 4, &parsedOk);
if (!parsedOk) { if (!parsedOk) {
return; return;
skipping to change at line 2276 skipping to change at line 2284
bbox[3] = getS16BE(tables[i].offset + 42, &parsedOk); bbox[3] = getS16BE(tables[i].offset + 42, &parsedOk);
locaFmt = getS16BE(tables[i].offset + 50, &parsedOk); locaFmt = getS16BE(tables[i].offset + 50, &parsedOk);
if (!parsedOk) { if (!parsedOk) {
return; return;
} }
// make sure the loca table is sane (correct length) // make sure the loca table is sane (correct length)
// NB: out-of-bounds entries are handled in writeTTF() // NB: out-of-bounds entries are handled in writeTTF()
if (!openTypeCFF) { if (!openTypeCFF) {
i = seekTable("loca"); i = seekTable("loca");
if (tables[i].len < 0) { if (tables[i].len < (locaFmt ? 4 : 2)) {
parsedOk = gFalse; parsedOk = gFalse;
return; return;
} }
if (tables[i].len < (nGlyphs + 1) * (locaFmt ? 4 : 2)) { if (tables[i].len < (nGlyphs + 1) * (locaFmt ? 4 : 2)) {
nGlyphs = tables[i].len / (locaFmt ? 4 : 2) - 1; nGlyphs = tables[i].len / (locaFmt ? 4 : 2) - 1;
} }
if (!parsedOk) { if (!parsedOk) {
return; return;
} }
} }
 End of changes. 8 change blocks. 
9 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)