[poppler] fofi/FoFiTrueType.cc fofi/FoFiTrueType.h splash/SplashFTFontEngine.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Nov 14 06:01:03 PST 2012


 fofi/FoFiTrueType.cc         |  658 -------------------------------------------
 fofi/FoFiTrueType.h          |   11 
 splash/SplashFTFontEngine.cc |   42 --
 3 files changed, 2 insertions(+), 709 deletions(-)

New commits:
commit c7e3c2d7087e4fc36564ba7bd55e27e100e0a5e5
Author: Albert Astals Cid <aacid at kde.org>
Date:   Wed Nov 14 14:58:45 2012 +0100

    Remove unused code

diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index c777d02..e22cb63 100644
--- a/fofi/FoFiTrueType.cc
+++ b/fofi/FoFiTrueType.cc
@@ -842,664 +842,6 @@ void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs,
   delete ff;
 }
 
-void FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc,
-			    void *outputStream, char *name,
-			    int *codeToGID) {
-  // this substitute cmap table maps char code ffff to glyph 0,
-  // with tables for MacRoman and MS Unicode
-  static char cmapTab[44] = {
-    0, 0,			// table version number
-    0, 2,			// number of encoding tables
-    0, 1,			// platform ID
-    0, 0,			// encoding ID
-    0, 0, 0, 20,		// offset of subtable
-    0, 3,			// platform ID
-    0, 1,			// encoding ID
-    0, 0, 0, 20,		// offset of subtable
-    0, 4,			// subtable format
-    0, 24,			// subtable length
-    0, 0,			// subtable version
-    0, 2,			// segment count * 2
-    0, 2,			// 2 * 2 ^ floor(log2(segCount))
-    0, 0,			// floor(log2(segCount))
-    0, 0,			// 2*segCount - 2*2^floor(log2(segCount))
-    (char)0xff, (char)0xff,	// endCount[0]
-    0, 0,			// reserved
-    (char)0xff, (char)0xff,	// startCount[0]
-    0, 1,			// idDelta[0]
-    0, 0			// idRangeOffset[0]
-  };
-  static char nameTab[8] = {
-    0, 0,			// format
-    0, 0,			// number of name records
-    0, 6,			// offset to start of string storage
-    0, 0			// pad to multiple of four bytes
-  };
-  static char postTab[32] = {
-    0, 1, 0, 0,			// format
-    0, 0, 0, 0,			// italic angle
-    0, 0,			// underline position
-    0, 0,			// underline thickness
-    0, 0, 0, 0,			// fixed pitch
-    0, 0, 0, 0,			// min Type 42 memory
-    0, 0, 0, 0,			// max Type 42 memory
-    0, 0, 0, 0,			// min Type 1 memory
-    0, 0, 0, 0			// max Type 1 memory
-  };
-  static char os2Tab[86] = {
-    0, 1,			// version
-    0, 1,			// xAvgCharWidth
-    0x01, (char)0x90,		// usWeightClass
-    0, 5,			// usWidthClass
-    0, 0,			// fsType
-    0, 0,			// ySubscriptXSize
-    0, 0,			// ySubscriptYSize
-    0, 0,			// ySubscriptXOffset
-    0, 0,			// ySubscriptYOffset
-    0, 0,			// ySuperscriptXSize
-    0, 0,			// ySuperscriptYSize
-    0, 0,			// ySuperscriptXOffset
-    0, 0,			// ySuperscriptYOffset
-    0, 0,			// yStrikeoutSize
-    0, 0,			// yStrikeoutPosition
-    0, 0,			// sFamilyClass
-    0, 0, 0, 0, 0,		// panose
-    0, 0, 0, 0, 0,
-    0, 0, 0, 0,			// ulUnicodeRange1
-    0, 0, 0, 0,			// ulUnicodeRange2
-    0, 0, 0, 0,			// ulUnicodeRange3
-    0, 0, 0, 0,			// ulUnicodeRange4
-    0, 0, 0, 0,			// achVendID
-    0, 0,			// fsSelection
-    0, 0,			// usFirstCharIndex
-    0, 0,			// usLastCharIndex
-    0, 0,			// sTypoAscender
-    0, 0,			// sTypoDescender
-    0, 0,			// sTypoLineGap
-    0x20, 0x00,			// usWinAscent
-    0x20, 0x00,			// usWinDescent
-    0, 0, 0, 1,			// ulCodePageRange1
-    0, 0, 0, 0			// ulCodePageRange2
-  };
-  GBool missingCmap, missingName, missingPost, missingOS2;
-  GBool unsortedLoca, emptyCmap, badCmapLen, abbrevHMTX;
-  int nZeroLengthTables, nBogusTables;
-  int nHMetrics, advWidth, lsb;
-  TrueTypeLoca *locaTable;
-  TrueTypeTable *newTables;
-  char *newNameTab, *newCmapTab, *newHHEATab, *newHMTXTab;
-  int nNewTables, cmapIdx, cmapLen, glyfLen, newNameLen, newCmapLen, next;
-  int newHHEALen, newHMTXLen;
-  Guint locaChecksum, glyfChecksum, fileChecksum;
-  char *tableDir;
-  char locaBuf[4], checksumBuf[4];
-  GBool ok;
-  Guint t;
-  int pos, i, j, k, n;
-
-  if (openTypeCFF) {
-    return;
-  }
-
-  if (tables == NULL) {
-    return;
-  }
-
-  // check for missing tables
-  // (Note: if the OS/2 table is missing, the Microsoft PCL5 driver
-  // will embed a PCL TrueType font with the pitch field set to zero,
-  // which apparently causes divide-by-zero errors.  As far as I can
-  // tell, the only important field in the OS/2 table is
-  // xAvgCharWidth.)
-  missingCmap = (cmapIdx = seekTable("cmap")) < 0;
-  missingName = seekTable("name") < 0;
-  missingPost = seekTable("post") < 0;
-  missingOS2 = seekTable("OS/2") < 0;
-
-  // read the loca table, check to see if it's sorted
-  locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + 1, sizeof(TrueTypeLoca));
-  unsortedLoca = gFalse;
-  i = seekTable("loca");
-  pos = tables[i].offset;
-  ok = gTrue;
-  for (i = 0; i <= nGlyphs; ++i) {
-    if (locaFmt) {
-      locaTable[i].origOffset = (int)getU32BE(pos + i*4, &ok);
-    } else {
-      locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok);
-    }
-    if (i > 0 && locaTable[i].origOffset < locaTable[i-1].origOffset) {
-      unsortedLoca = gTrue;
-    }
-    // glyph descriptions must be at least 12 bytes long (nContours,
-    // xMin, yMin, xMax, yMax, instructionLength - two bytes each);
-    // invalid glyph descriptions (even if they're never used) make
-    // Windows choke, so we work around that problem here (ideally,
-    // this would parse the glyph descriptions in the glyf table and
-    // remove any that were invalid, but this quick test is a decent
-    // start)
-    if (i > 0 &&
-	locaTable[i].origOffset - locaTable[i-1].origOffset > 0 &&
-	locaTable[i].origOffset - locaTable[i-1].origOffset < 12) {
-      locaTable[i-1].origOffset = locaTable[i].origOffset;
-      unsortedLoca = gTrue;
-    }
-    locaTable[i].idx = i;
-  }
-
-  // check for zero-length tables and bogus tags
-  nZeroLengthTables = nBogusTables = 0;
-  for (i = 0; i < nTables; ++i) {
-    if (tables[i].len == 0) {
-      ++nZeroLengthTables;
-      if (tables[i].tag == cmapTag) {
-	missingCmap = gTrue;
-      } else if (tables[i].tag == nameTag) {
-	missingName = gTrue;
-      } else if (tables[i].tag == postTag) {
-	missingPost = gTrue;
-      } else if (tables[i].tag == os2Tag) {
-	missingOS2 = gTrue;
-      }
-    } else if (!(tables[i].tag & 0xe0000000) ||
-	       !(tables[i].tag & 0x00e00000) ||
-	       !(tables[i].tag & 0x0000e000) ||
-	       !(tables[i].tag & 0x000000e0)) {
-      // tags where any of the bytes are < 0x20 are probably bogus
-      // (the TrueType spec uses ASCII sequences for tags) -- this
-      // catches problems where the number of tables given in the
-      // header is too large, and so gibberish data is read at the end
-      // of the table directory
-      ++nBogusTables;
-    }
-  }
-
-  // check for an empty cmap table or an incorrect cmap table length
-  emptyCmap = badCmapLen = gFalse;
-  cmapLen = 0; // make gcc happy
-  if (!missingCmap) {
-    if (nCmaps == 0) {
-      emptyCmap = gTrue;
-    } else {
-      cmapLen = cmaps[0].offset + cmaps[0].len;
-      for (i = 1; i < nCmaps; ++i) {
-	if (cmaps[i].offset + cmaps[i].len > cmapLen) {
-	  cmapLen = cmaps[i].offset + cmaps[i].len;
-	}
-      }
-      cmapLen -= tables[cmapIdx].offset;
-      if (cmapLen > tables[cmapIdx].len) {
-	badCmapLen = gTrue;
-      }
-    }
-  }
-
-  // check for an abbreviated hmtx table (this is completely legal,
-  // but confuses the Microsoft PCL5 printer driver, which generates
-  // embedded fonts with the pitch field set to zero)
-  i = seekTable("hhea");
-  nHMetrics = getU16BE(tables[i].offset + 34, &ok);
-  abbrevHMTX = nHMetrics < nGlyphs;
-
-  // if nothing is broken, just write the TTF file as is
-  if (!missingCmap && !missingName && !missingPost && !missingOS2 &&
-      !unsortedLoca && !emptyCmap && !badCmapLen && !abbrevHMTX &&
-      nZeroLengthTables == 0 && nBogusTables == 0 &&
-      !name && !codeToGID) {
-    (*outputFunc)(outputStream, (char *)file, len);
-    goto done1;
-  }
-
-  // sort the 'loca' table: 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, 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)
-  glyfLen = 0; // make gcc happy
-  if (unsortedLoca) {
-    std::sort(locaTable, locaTable + nGlyphs + 1,
-	      cmpTrueTypeLocaOffsetFunctor());
-    for (i = 0; i < nGlyphs; ++i) {
-      locaTable[i].len = locaTable[i+1].origOffset - locaTable[i].origOffset;
-    }
-    locaTable[nGlyphs].len = 0;
-    std::sort(locaTable, locaTable + nGlyphs + 1, cmpTrueTypeLocaIdxFunctor());
-    // if the last entry in the loca is not the max offset (size of
-    // the glyf table), something is wrong -- work around the problem
-    // by forcing the last sorted entry to have a zero length
-    locaTable[nGlyphs].len = 0;
-    pos = 0;
-    for (i = 0; i <= nGlyphs; ++i) {
-      locaTable[i].newOffset = pos;
-      pos += locaTable[i].len;
-      if (pos & 3) {
-	pos += 4 - (pos & 3);
-      }
-    }
-    glyfLen = pos;
-  }
-
-  // compute checksums for the loca and glyf tables
-  locaChecksum = glyfChecksum = 0;
-  if (unsortedLoca) {
-    if (locaFmt) {
-      for (j = 0; j <= nGlyphs; ++j) {
-	locaChecksum += locaTable[j].newOffset;
-      }
-    } else {
-      for (j = 0; j <= nGlyphs; j += 2) {
-	locaChecksum += locaTable[j].newOffset << 16;
-	if (j + 1 <= nGlyphs) {
-	  locaChecksum += locaTable[j+1].newOffset;
-	}
-      }
-    }
-    pos = tables[seekTable("glyf")].offset;
-    for (j = 0; j < nGlyphs; ++j) {
-      n = locaTable[j].len;
-      if (n > 0) {
-	k = locaTable[j].origOffset;
-	if (checkRegion(pos + k, n)) {
-	  glyfChecksum += computeTableChecksum(file + pos + k, n);
-	}
-      }
-    }
-  }
-
-  // construct the new name table
-  if (name) {
-    n = strlen(name);
-    newNameLen = (6 + 4*12 + 2 * (3*n + 7) + 3) & ~3;
-    newNameTab = (char *)gmalloc(newNameLen);
-    memset(newNameTab, 0, newNameLen);
-    newNameTab[0] = 0;		// format selector
-    newNameTab[1] = 0;
-    newNameTab[2] = 0;		// number of name records
-    newNameTab[3] = 4;
-    newNameTab[4] = 0;		// offset to start of string storage
-    newNameTab[5] = 6 + 4*12;
-    next = 0;
-    for (i = 0; i < 4; ++i) {
-      newNameTab[6 + i*12 + 0] = 0;	// platform ID = Microsoft
-      newNameTab[6 + i*12 + 1] = 3;
-      newNameTab[6 + i*12 + 2] = 0;	// encoding ID = Unicode
-      newNameTab[6 + i*12 + 3] = 1;
-      newNameTab[6 + i*12 + 4] = 0x04;	// language ID = American English
-      newNameTab[6 + i*12 + 5] = 0x09;
-      newNameTab[6 + i*12 + 6] = 0;	// name ID
-      newNameTab[6 + i*12 + 7] = i + 1;
-      newNameTab[6 + i*12 + 8] = i+1 == 2 ? 0 : ((2*n) >> 8); // string length
-      newNameTab[6 + i*12 + 9] = i+1 == 2 ? 14 : ((2*n) & 0xff);
-      newNameTab[6 + i*12 + 10] = next >> 8;		    // string offset
-      newNameTab[6 + i*12 + 11] = next & 0xff;
-      if (i+1 == 2) {
-	memcpy(newNameTab + 6 + 4*12 + next, "\0R\0e\0g\0u\0l\0a\0r", 14);
-	next += 14;
-      } else {
-	for (j = 0; j < n; ++j) {
-	  newNameTab[6 + 4*12 + next + 2*j] = 0;
-	  newNameTab[6 + 4*12 + next + 2*j + 1] = name[j];
-	}
-	next += 2*n;
-      }
-    }
-  } else {
-    newNameLen = 0;
-    newNameTab = NULL;
-  }
-
-  // construct the new cmap table
-  if (codeToGID) {
-    newCmapLen = 44 + 256 * 2;
-    newCmapTab = (char *)gmalloc(newCmapLen);
-    newCmapTab[0] = 0;		// table version number = 0
-    newCmapTab[1] = 0;
-    newCmapTab[2] = 0;		// number of encoding tables = 1
-    newCmapTab[3] = 1;
-    newCmapTab[4] = 0;		// platform ID = Microsoft
-    newCmapTab[5] = 3;
-    newCmapTab[6] = 0;		// encoding ID = Unicode
-    newCmapTab[7] = 1;
-    newCmapTab[8] = 0;		// offset of subtable
-    newCmapTab[9] = 0;
-    newCmapTab[10] = 0;
-    newCmapTab[11] = 12;
-    newCmapTab[12] = 0;		// subtable format = 4
-    newCmapTab[13] = 4;
-    newCmapTab[14] = 0x02;	// subtable length
-    newCmapTab[15] = 0x20;
-    newCmapTab[16] = 0;		// subtable version = 0
-    newCmapTab[17] = 0;
-    newCmapTab[18] = 0;		// segment count * 2
-    newCmapTab[19] = 4;
-    newCmapTab[20] = 0;		// 2 * 2 ^ floor(log2(segCount))
-    newCmapTab[21] = 4;
-    newCmapTab[22] = 0;		// floor(log2(segCount))
-    newCmapTab[23] = 1;
-    newCmapTab[24] = 0;		// 2*segCount - 2*2^floor(log2(segCount))
-    newCmapTab[25] = 0;
-    newCmapTab[26] = 0x00;	// endCount[0]
-    newCmapTab[27] = (char)0xff;
-    newCmapTab[28] = (char)0xff; // endCount[1]
-    newCmapTab[29] = (char)0xff;
-    newCmapTab[30] = 0;		// reserved
-    newCmapTab[31] = 0;
-    newCmapTab[32] = 0x00;	// startCount[0]
-    newCmapTab[33] = 0x00;
-    newCmapTab[34] = (char)0xff; // startCount[1]
-    newCmapTab[35] = (char)0xff;
-    newCmapTab[36] = 0;		// idDelta[0]
-    newCmapTab[37] = 0;
-    newCmapTab[38] = 0;		// idDelta[1]
-    newCmapTab[39] = 1;
-    newCmapTab[40] = 0;		// idRangeOffset[0]
-    newCmapTab[41] = 4;
-    newCmapTab[42] = 0;		// idRangeOffset[1]
-    newCmapTab[43] = 0;
-    for (i = 0; i < 256; ++i) {
-      if (codeToGID[i] < 0) {
-	//~ this may not be correct - we want this character to never be
-	//~ displayed, but mapping it to the notdef glyph may result in
-	//~ little boxes being displayed
-	newCmapTab[44 + 2*i] = 0;
-	newCmapTab[44 + 2*i + 1] = 0;
-      } else {
-	newCmapTab[44 + 2*i] = codeToGID[i] >> 8;
-	newCmapTab[44 + 2*i + 1] = codeToGID[i] & 0xff;
-      }
-    }
-  } else {
-    newCmapLen = 0;
-    newCmapTab = NULL;
-  }
-
-  // generate the new hmtx table and the updated hhea table
-  if (abbrevHMTX) {
-    i = seekTable("hhea");
-    pos = tables[i].offset;
-    newHHEALen = 36;
-    newHHEATab = (char *)gmalloc(newHHEALen);
-    for (i = 0; i < newHHEALen; ++i) {
-      newHHEATab[i] = getU8(pos++, &ok);
-    }
-    newHHEATab[34] = nGlyphs >> 8;
-    newHHEATab[35] = nGlyphs & 0xff;
-    i = seekTable("hmtx");
-    pos = tables[i].offset;
-    newHMTXLen = 4 * nGlyphs;
-    newHMTXTab = (char *)gmalloc(newHMTXLen);
-    advWidth = 0;
-    for (i = 0; i < nHMetrics; ++i) {
-      advWidth = getU16BE(pos, &ok);
-      lsb = getU16BE(pos + 2, &ok);
-      pos += 4;
-      newHMTXTab[4*i    ] = advWidth >> 8;
-      newHMTXTab[4*i + 1] = advWidth & 0xff;
-      newHMTXTab[4*i + 2] = lsb >> 8;
-      newHMTXTab[4*i + 3] = lsb & 0xff;
-    }
-    for (; i < nGlyphs; ++i) {
-      lsb = getU16BE(pos, &ok);
-      pos += 2;
-      newHMTXTab[4*i    ] = advWidth >> 8;
-      newHMTXTab[4*i + 1] = advWidth & 0xff;
-      newHMTXTab[4*i + 2] = lsb >> 8;
-      newHMTXTab[4*i + 3] = lsb & 0xff;
-    }
-  } else {
-    newHHEATab = newHMTXTab = NULL;
-    newHHEALen = newHMTXLen = 0; // make gcc happy
-  }
-
-  // construct the new table directory:
-  // - keep all original tables with non-zero length
-  // - fix the cmap table's length, if necessary
-  // - add missing tables
-  // - sort the table by tag
-  // - compute new table positions, including 4-byte alignment
-  // - (re)compute table checksums
-  nNewTables = nTables - nZeroLengthTables - nBogusTables +
-               (missingCmap ? 1 : 0) + (missingName ? 1 : 0) +
-               (missingPost ? 1 : 0) + (missingOS2 ? 1 : 0);
-  newTables = (TrueTypeTable *)gmallocn(nNewTables, sizeof(TrueTypeTable));
-  j = 0;
-  for (i = 0; i < nTables; ++i) {
-    if (tables[i].len > 0 &&
-	(tables[i].tag & 0xe0000000) &&
-	(tables[i].tag & 0x00e00000) &&
-	(tables[i].tag & 0x0000e000) &&
-	(tables[i].tag & 0x000000e0)) {
-      newTables[j] = tables[i];
-      newTables[j].origOffset = tables[i].offset;
-      if (checkRegion(tables[i].offset, tables[i].len)) {
-	newTables[j].checksum =
-	    computeTableChecksum(file + tables[i].offset, tables[i].len);
-	if (tables[i].tag == headTag) {
-	  // don't include the file checksum
-	  newTables[j].checksum -= getU32BE(tables[i].offset + 8, &ok);
-	}
-      }
-      if (newTables[j].tag == cmapTag && codeToGID) {
-	newTables[j].len = newCmapLen;
-	newTables[j].checksum = computeTableChecksum((Guchar *)newCmapTab,
-						     newCmapLen);
-      } else if (newTables[j].tag == cmapTag && emptyCmap) {
-	newTables[j].checksum = computeTableChecksum((Guchar *)cmapTab,
-						     sizeof(cmapTab));
-	newTables[j].len = sizeof(cmapTab);
-      } else if (newTables[j].tag == cmapTag && badCmapLen) {
-	newTables[j].len = cmapLen;
-      } else if (newTables[j].tag == locaTag && unsortedLoca) {
-	newTables[j].len = (nGlyphs + 1) * (locaFmt ? 4 : 2);
-	newTables[j].checksum = locaChecksum;
-      } else if (newTables[j].tag == glyfTag && unsortedLoca) {
-	newTables[j].len = glyfLen;
-	newTables[j].checksum = glyfChecksum;
-      } else if (newTables[j].tag == nameTag && name) {
-	newTables[j].len = newNameLen;
-	newTables[j].checksum = computeTableChecksum((Guchar *)newNameTab,
-						     newNameLen);
-      } else if (newTables[j].tag == hheaTag && abbrevHMTX) {
-	newTables[j].len = newHHEALen;
-	newTables[j].checksum = computeTableChecksum((Guchar *)newHHEATab,
-						     newHHEALen);
-      } else if (newTables[j].tag == hmtxTag && abbrevHMTX) {
-	newTables[j].len = newHMTXLen;
-	newTables[j].checksum = computeTableChecksum((Guchar *)newHMTXTab,
-						     newHMTXLen);
-      }
-      ++j;
-    }
-  }
-  if (missingCmap) {
-    newTables[j].tag = cmapTag;
-    if (codeToGID) {
-      newTables[j].checksum = computeTableChecksum((Guchar *)newCmapTab,
-						   newCmapLen);
-      newTables[j].len = newCmapLen;
-    } else {
-      newTables[j].checksum = computeTableChecksum((Guchar *)cmapTab,
-						   sizeof(cmapTab));
-      newTables[j].len = sizeof(cmapTab);
-    }
-    ++j;
-  }
-  if (missingName) {
-    newTables[j].tag = nameTag;
-    if (name) {
-      newTables[j].checksum = computeTableChecksum((Guchar *)newNameTab,
-						   newNameLen);
-      newTables[j].len = newNameLen;
-    } else {
-      newTables[j].checksum = computeTableChecksum((Guchar *)nameTab,
-						   sizeof(nameTab));
-      newTables[j].len = sizeof(nameTab);
-    }
-    ++j;
-  }
-  if (missingPost) {
-    newTables[j].tag = postTag;
-    newTables[j].checksum = computeTableChecksum((Guchar *)postTab,
-						 sizeof(postTab));
-    newTables[j].len = sizeof(postTab);
-    ++j;
-  }
-  if (missingOS2) {
-    newTables[j].tag = os2Tag;
-    newTables[j].checksum = computeTableChecksum((Guchar *)os2Tab,
-						 sizeof(os2Tab));
-    newTables[j].len = sizeof(os2Tab);
-    ++j;
-  }
-  std::sort(newTables, newTables + nNewTables, cmpTrueTypeTableTagFunctor());
-  pos = 12 + nNewTables * 16;
-  for (i = 0; i < nNewTables; ++i) {
-    newTables[i].offset = pos;
-    pos += newTables[i].len;
-    if (pos & 3) {
-      pos += 4 - (pos & 3);
-    }
-  }
-
-  // write the table directory
-  tableDir = (char *)gmalloc(12 + nNewTables * 16);
-  tableDir[0] = 0x00;					// sfnt version
-  tableDir[1] = 0x01;
-  tableDir[2] = 0x00;
-  tableDir[3] = 0x00;
-  tableDir[4] = (char)((nNewTables >> 8) & 0xff);	// numTables
-  tableDir[5] = (char)(nNewTables & 0xff);
-  for (i = -1, t = (Guint)nNewTables; t; ++i, t >>= 1) ;
-  t = 1 << (4 + i);
-  tableDir[6] = (char)((t >> 8) & 0xff);		// searchRange
-  tableDir[7] = (char)(t & 0xff);
-  tableDir[8] = (char)((i >> 8) & 0xff);		// entrySelector
-  tableDir[9] = (char)(i & 0xff);
-  t = nNewTables * 16 - t;
-  tableDir[10] = (char)((t >> 8) & 0xff);		// rangeShift
-  tableDir[11] = (char)(t & 0xff);
-  pos = 12;
-  for (i = 0; i < nNewTables; ++i) {
-    tableDir[pos   ] = (char)(newTables[i].tag >> 24);
-    tableDir[pos+ 1] = (char)(newTables[i].tag >> 16);
-    tableDir[pos+ 2] = (char)(newTables[i].tag >>  8);
-    tableDir[pos+ 3] = (char) newTables[i].tag;
-    tableDir[pos+ 4] = (char)(newTables[i].checksum >> 24);
-    tableDir[pos+ 5] = (char)(newTables[i].checksum >> 16);
-    tableDir[pos+ 6] = (char)(newTables[i].checksum >>  8);
-    tableDir[pos+ 7] = (char) newTables[i].checksum;
-    tableDir[pos+ 8] = (char)(newTables[i].offset >> 24);
-    tableDir[pos+ 9] = (char)(newTables[i].offset >> 16);
-    tableDir[pos+10] = (char)(newTables[i].offset >>  8);
-    tableDir[pos+11] = (char) newTables[i].offset;
-    tableDir[pos+12] = (char)(newTables[i].len >> 24);
-    tableDir[pos+13] = (char)(newTables[i].len >> 16);
-    tableDir[pos+14] = (char)(newTables[i].len >>  8);
-    tableDir[pos+15] = (char) newTables[i].len;
-    pos += 16;
-  }
-  (*outputFunc)(outputStream, tableDir, 12 + nNewTables * 16);
-
-  // compute the file checksum
-  fileChecksum = computeTableChecksum((Guchar *)tableDir,
-				      12 + nNewTables * 16);
-  for (i = 0; i < nNewTables; ++i) {
-    fileChecksum += newTables[i].checksum;
-  }
-  fileChecksum = 0xb1b0afba - fileChecksum;
-
-  // write the tables
-  for (i = 0; i < nNewTables; ++i) {
-    if (newTables[i].tag == headTag) {
-      if (checkRegion(newTables[i].origOffset, newTables[i].len)) {
-	(*outputFunc)(outputStream, (char *)file + newTables[i].origOffset, 8);
-	checksumBuf[0] = fileChecksum >> 24;
-	checksumBuf[1] = fileChecksum >> 16;
-	checksumBuf[2] = fileChecksum >> 8;
-	checksumBuf[3] = fileChecksum;
-	(*outputFunc)(outputStream, checksumBuf, 4);
-	(*outputFunc)(outputStream,
-		      (char *)file + newTables[i].origOffset + 12,
-		      newTables[i].len - 12);
-      } else {
-	for (j = 0; j < newTables[i].len; ++j) {
-	  (*outputFunc)(outputStream, "\0", 1);
-	}
-      }
-    } else if (newTables[i].tag == cmapTag && codeToGID) {
-      (*outputFunc)(outputStream, newCmapTab, newTables[i].len);
-    } else if (newTables[i].tag == cmapTag && missingCmap) {
-      (*outputFunc)(outputStream, cmapTab, newTables[i].len);
-    } else if (newTables[i].tag == nameTag && name) {
-      (*outputFunc)(outputStream, newNameTab, newTables[i].len);
-    } else if (newTables[i].tag == nameTag && missingName) {
-      (*outputFunc)(outputStream, nameTab, newTables[i].len);
-    } else if (newTables[i].tag == postTag && missingPost) {
-      (*outputFunc)(outputStream, postTab, newTables[i].len);
-    } else if (newTables[i].tag == os2Tag && missingOS2) {
-      (*outputFunc)(outputStream, os2Tab, newTables[i].len);
-    } else if (newTables[i].tag == hheaTag && abbrevHMTX) {
-      (*outputFunc)(outputStream, newHHEATab, newTables[i].len);
-    } else if (newTables[i].tag == hmtxTag && abbrevHMTX) {
-      (*outputFunc)(outputStream, newHMTXTab, newTables[i].len);
-    } else if (newTables[i].tag == locaTag && unsortedLoca) {
-      for (j = 0; j <= nGlyphs; ++j) {
-	if (locaFmt) {
-	  locaBuf[0] = (char)(locaTable[j].newOffset >> 24);
-	  locaBuf[1] = (char)(locaTable[j].newOffset >> 16);
-	  locaBuf[2] = (char)(locaTable[j].newOffset >>  8);
-	  locaBuf[3] = (char) locaTable[j].newOffset;
-	  (*outputFunc)(outputStream, locaBuf, 4);
-	} else {
-	  locaBuf[0] = (char)(locaTable[j].newOffset >> 9);
-	  locaBuf[1] = (char)(locaTable[j].newOffset >> 1);
-	  (*outputFunc)(outputStream, locaBuf, 2);
-	}
-      }
-    } else if (newTables[i].tag == glyfTag && unsortedLoca) {
-      pos = tables[seekTable("glyf")].offset;
-      for (j = 0; j < nGlyphs; ++j) {
-	n = locaTable[j].len;
-	if (n > 0) {
-	  k = locaTable[j].origOffset;
-	  if (checkRegion(pos + k, n)) {
-	    (*outputFunc)(outputStream, (char *)file + pos + k, n);
-	  } else {
-	    for (k = 0; k < n; ++k) {
-	      (*outputFunc)(outputStream, "\0", 1);
-	    }
-	  }
-	  if ((k = locaTable[j].len & 3)) {
-	    (*outputFunc)(outputStream, "\0\0\0\0", 4 - k);
-	  }
-	}
-      }
-    } else {
-      if (checkRegion(newTables[i].origOffset, newTables[i].len)) {
-	(*outputFunc)(outputStream, (char *)file + newTables[i].origOffset,
-		      newTables[i].len);
-      } else {
-	for (j = 0; j < newTables[i].len; ++j) {
-	  (*outputFunc)(outputStream, "\0", 1);
-	}
-      }
-    }
-    if (newTables[i].len & 3) {
-      (*outputFunc)(outputStream, "\0\0\0", 4 - (newTables[i].len & 3));
-    }
-  }
-
-  gfree(newHMTXTab);
-  gfree(newHHEATab);
-  gfree(newCmapTab);
-  gfree(newNameTab);
-  gfree(tableDir);
-  gfree(newTables);
- done1:
-  gfree(locaTable);
-}
-
 void FoFiTrueType::cvtEncoding(char **encoding,
 			       FoFiOutputFunc outputFunc,
 			       void *outputStream) {
diff --git a/fofi/FoFiTrueType.h b/fofi/FoFiTrueType.h
index fb05ae9..b40a44a 100644
--- a/fofi/FoFiTrueType.h
+++ b/fofi/FoFiTrueType.h
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2011 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2011, 2012 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
 //
 // To see a description of the changes please see the Changelog file that
@@ -152,15 +152,6 @@ public:
   void convertToType0(char *psName, int *cidMap, int nCIDs,
 		      FoFiOutputFunc outputFunc, void *outputStream);
 
-  // Write a clean TTF file, filling in missing tables and correcting
-  // various other errors.  If <name> is non-NULL, the font is renamed
-  // to <name>.  If <codeToGID> is non-NULL, the font is re-encoded,
-  // using a Windows Unicode cmap.  If <name> is NULL and the font is
-  // complete and correct, it will be written unmodified.  (Not useful
-  // for OpenType CFF fonts.)
-  void writeTTF(FoFiOutputFunc outputFunc, void *outputStream,
-		char *name = NULL, int *codeToGID = NULL);
-
   // Returns a pointer to the CFF font embedded in this OpenType font.
   // If successful, sets *<start> and *<length>, and returns true.
   // Otherwise returns false.  (Only useful for OpenType CFF fonts).
diff --git a/splash/SplashFTFontEngine.cc b/splash/SplashFTFontEngine.cc
index 7a4568d..9fef8f0 100644
--- a/splash/SplashFTFontEngine.cc
+++ b/splash/SplashFTFontEngine.cc
@@ -12,7 +12,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
-// Copyright (C) 2009, 2011 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009, 2011, 2012 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
 // Copyright (C) 2011 Andreas Hartmetz <ahartmetz at gmail.com>
 //
@@ -48,14 +48,6 @@ extern "C" int unlink(char *filename);
 #endif
 
 //------------------------------------------------------------------------
-
-#if 0
-static void fileWrite(void *stream, const char *data, int len) {
-  fwrite(data, 1, len, (FILE *)stream);
-}
-#endif
-
-//------------------------------------------------------------------------
 // SplashFTFontEngine
 //------------------------------------------------------------------------
 
@@ -178,43 +170,11 @@ SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
 						     int *codeToGID,
 						     int codeToGIDLen,
 						     int faceIndex) {
-#if 0
-  FoFiTrueType *ff;
-  GooString *tmpFileName;
-  FILE *tmpFile;
-  SplashFontFile *ret;
-
-  if (!(ff = FoFiTrueType::load(fileName))) {
-    return NULL;
-  }
-  tmpFileName = NULL;
-  if (!openTempFile(&tmpFileName, &tmpFile, "wb")) {
-    delete ff;
-    return NULL;
-  }
-  ff->writeTTF(&fileWrite, tmpFile);
-  delete ff;
-  fclose(tmpFile);
-  ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
-					   tmpFileName->getCString(),
-					   gTrue, codeToGID, codeToGIDLen,
-					   faceIndex);
-  if (ret) {
-    if (deleteFile) {
-      unlink(fileName);
-    }
-  } else {
-    unlink(tmpFileName->getCString());
-  }
-  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


More information about the poppler mailing list