[poppler] poppler/fofi: FoFiTrueType.cc, 1.4, 1.5 FoFiTrueType.h, 1.2, 1.3 FoFiType1C.h, 1.2, 1.3

Albert Astals Cid aacid at freedesktop.org
Thu Feb 2 14:50:04 PST 2006


Update of /cvs/poppler/poppler/fofi
In directory gabe:/tmp/cvs-serv24658/fofi

Modified Files:
	FoFiTrueType.cc FoFiTrueType.h FoFiType1C.h 
Log Message:
don't use files to pass fonts to freetype


Index: FoFiTrueType.cc
===================================================================
RCS file: /cvs/poppler/poppler/fofi/FoFiTrueType.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- FoFiTrueType.cc	14 Sep 2005 21:20:36 -0000	1.4
+++ FoFiTrueType.cc	2 Feb 2006 22:50:01 -0000	1.5
@@ -241,10 +241,10 @@
 // FoFiTrueType
 //------------------------------------------------------------------------
 
-FoFiTrueType *FoFiTrueType::make(char *fileA, int lenA) {
+FoFiTrueType *FoFiTrueType::make(char *fileA, int lenA, int faceIndexA) {
   FoFiTrueType *ff;
 
-  ff = new FoFiTrueType(fileA, lenA, gFalse);
+  ff = new FoFiTrueType(fileA, lenA, gFalse, faceIndexA);
   if (!ff->parsedOk) {
     delete ff;
     return NULL;
@@ -252,7 +252,7 @@
   return ff;
 }
 
-FoFiTrueType *FoFiTrueType::load(char *fileName) {
+FoFiTrueType *FoFiTrueType::load(char *fileName, int faceIndexA) {
   FoFiTrueType *ff;
   char *fileA;
   int lenA;
@@ -260,7 +260,7 @@
   if (!(fileA = FoFiBase::readFile(fileName, &lenA))) {
     return NULL;
   }
-  ff = new FoFiTrueType(fileA, lenA, gTrue);
+  ff = new FoFiTrueType(fileA, lenA, gTrue, faceIndexA);
   if (!ff->parsedOk) {
     delete ff;
     return NULL;
@@ -268,7 +268,7 @@
   return ff;
 }
 
-FoFiTrueType::FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA):
+FoFiTrueType::FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA):
   FoFiBase(fileA, lenA, freeFileDataA)
 {
   tables = NULL;
@@ -277,6 +277,7 @@
   nCmaps = 0;
   nameToGID = NULL;
   parsedOk = gFalse;
+  faceIndex = faceIndexA;
 
   parse();
 }
@@ -1535,9 +1536,12 @@
   return checksum;
 }
 
+#define toTag(a,b,c,d) (((unsigned int)(a)<<24) | ((unsigned int)(b)<<16) | ((unsigned int)(c)<<8) | (d))
+
 void FoFiTrueType::parse() {
   Guint topTag;
   int pos, i, j;
+  unsigned int head;
 
   parsedOk = gTrue;
 
@@ -1556,12 +1560,37 @@
   }
 
   // read the table directory
-  nTables = getU16BE(pos + 4, &parsedOk);
+  head = getU32BE(pos, &parsedOk);
+  if (! parsedOk)
+    return;
+  if (head == toTag('t','t','c','f')) {
+    /* TTC font */
+    unsigned int tableDir;
+    int dircount;
+
+    dircount = getU32BE(8, &parsedOk);
+    if (!parsedOk)
+      return;
+    if (! dircount) {
+      parsedOk = gFalse;
+      return;
+    }
+
+    if (faceIndex >= dircount)
+      faceIndex = 0;
+    pos = getU32BE(12 + faceIndex * 4, &parsedOk);
+    if (! parsedOk)
+      return;
+  }
+
+  pos += 4;
+  nTables = getU16BE(pos, &parsedOk);
   if (!parsedOk) {
     return;
   }
+
+  pos += 8;
   tables = (TrueTypeTable *)gmallocn(nTables, sizeof(TrueTypeTable));
-  pos += 12;
   for (i = 0; i < nTables; ++i) {
     tables[i].tag = getU32BE(pos, &parsedOk);
     tables[i].checksum = getU32BE(pos + 4, &parsedOk);

Index: FoFiTrueType.h
===================================================================
RCS file: /cvs/poppler/poppler/fofi/FoFiTrueType.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FoFiTrueType.h	14 Sep 2005 21:20:36 -0000	1.2
+++ FoFiTrueType.h	2 Feb 2006 22:50:01 -0000	1.3
@@ -29,11 +29,12 @@
 public:
 
   // Create a FoFiTrueType object from a memory buffer.
-  static FoFiTrueType *make(char *fileA, int lenA);
+  static FoFiTrueType *make(char *fileA, int lenA, int faceIndexA=0);
 
   // Create a FoFiTrueType object from a file on disk.
-  static FoFiTrueType *load(char *fileName);
+  static FoFiTrueType *load(char *fileName, int faceIndexA=0);
 
+  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA=0);
   virtual ~FoFiTrueType();
 
   // Return the number of cmaps defined by this font.
@@ -104,7 +105,6 @@
 
 private:
 
-  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
   void cvtEncoding(char **encoding,
 		   FoFiOutputFunc outputFunc,
 		   void *outputStream);
@@ -133,6 +133,7 @@
   GooHash *nameToGID;
 
   GBool parsedOk;
+  int faceIndex;
 };
 
 #endif

Index: FoFiType1C.h
===================================================================
RCS file: /cvs/poppler/poppler/fofi/FoFiType1C.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FoFiType1C.h	14 Sep 2005 21:20:36 -0000	1.2
+++ FoFiType1C.h	2 Feb 2006 22:50:01 -0000	1.3
@@ -138,6 +138,7 @@
   // Create a FoFiType1C object from a file on disk.
   static FoFiType1C *load(char *fileName);
 
+  FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
   virtual ~FoFiType1C();
 
   // Return the font name.
@@ -173,7 +174,6 @@
 
 private:
 
-  FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
   void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName,
 		     int offset, int nBytes,
 		     Type1CIndex *subrIdx,



More information about the poppler mailing list