]> git.donarmstrong.com Git - lilypond.git/blobdiff - ttftool/parse.c
*** empty log message ***
[lilypond.git] / ttftool / parse.c
index a8e7e3326d54b90d5b4424fb0b5d918e271a5d0e..cf43152b073f9437c5fa3ebea41a76870f50e797 100644 (file)
 #include "ttftool.h"
 
 struct TableDirectoryEntry *
-readDirectory (int fd, struct OffsetTable *ot)
+readDirectory (FILE *fd, struct OffsetTable *ot)
 {
   unsigned n;
   int i;
 
   struct TableDirectoryEntry *td;
-  if (ttf_verbosity >= 3)
-    fprintf (stderr, "");
   
   surely_read (fd, ot, sizeof (struct OffsetTable));
   FIX_OffsetTable (*ot);
   if (ttf_verbosity >= 2)
     fprintf (stderr, "%d tables\n", ot->numTables);
+
   n = sizeof (struct TableDirectoryEntry) * ot->numTables;
   td = mymalloc (n);
   surely_read (fd, td, n);
@@ -33,7 +32,7 @@ readDirectory (int fd, struct OffsetTable *ot)
 }
 
 char **
-readNamingTable (int fd)
+readNamingTable (FILE *fd)
 {
   USHORT format;
   USHORT nrecords;
@@ -44,7 +43,7 @@ readNamingTable (int fd)
   char *data;
   char **strings;
 
-  position = surely_lseek (fd, 0, SEEK_CUR);
+  position = ftell (fd);
 
   surely_read (fd, &format, sizeof (USHORT));
   FIX_UH (format);
@@ -115,7 +114,7 @@ readNamingTable (int fd)
 }
 
 int
-readMaxpTable (int fd)
+readMaxpTable (FILE *fd)
 {
   struct
   {
@@ -132,7 +131,7 @@ readMaxpTable (int fd)
 }
 
 void
-readHeadTable (int fd, struct HeadTable *ht)
+readHeadTable (FILE *fd, struct HeadTable *ht)
 {
   surely_read (fd, ht, sizeof (struct HeadTable));
   FIX_HeadTable (*ht);
@@ -150,10 +149,10 @@ readHeadTable (int fd, struct HeadTable *ht)
 }
 
 int
-readPostTable (int fd, int nglyphs, struct PostTable *pt,
+readPostTable (FILE *fd, int root_nglyphs, struct PostTable *pt,
               struct GlyphName **gt)
 {
-  USHORT nglyphspost;
+  USHORT nglyphs;
   USHORT *glyphNameIndex;
   struct GlyphName *glyphNames;
   char **glyphNamesTemp;
@@ -173,10 +172,20 @@ readPostTable (int fd, int nglyphs, struct PostTable *pt,
     case 2:
       if (pt->formatType.fraction != 0)
        ttf_error ("Unsupported `post' table format");
-      surely_read (fd, &nglyphspost, sizeof (USHORT));
-      FIX_UH (nglyphspost);
-      if (nglyphspost != nglyphs)
-       ttf_error ("Inconsistency between `maxp' and `nglyphs' tables!");
+      surely_read (fd, &nglyphs, sizeof (USHORT));
+
+      /*from freetype2:
+       */
+      /*
+       UNDOCUMENTED!  The number of glyphs in this table can be smaller
+       than the value in the maxp table (cf. cyberbit.ttf).             
+       */
+      FIX_UH (nglyphs);
+      if (nglyphs > root_nglyphs)
+       {
+         fprintf (stderr, "More glyphs in 'post' table than in 'maxp' table");
+       }
+      
       if (ttf_verbosity >= 2)
        fprintf (stderr, "  %d glyphs\n", nglyphs);
       glyphNameIndex = mymalloc (sizeof (USHORT) * nglyphs);
@@ -227,7 +236,7 @@ readPostTable (int fd, int nglyphs, struct PostTable *pt,
  /*NOTREACHED*/}
 
 void *
-readLocaTable (int fd, int nglyphs, int format)
+readLocaTable (FILE *fd, int nglyphs, int format)
 {
   int i;
   switch (format)
@@ -256,13 +265,13 @@ readLocaTable (int fd, int nglyphs, int format)
  /*NOTREACHED*/}
 
 struct Box *
-readGlyfTable (int fd, int nglyphs, int format, void *loca)
+readGlyfTable (FILE *fd, int nglyphs, int format, void *loca)
 {
   int i;
   struct Box *bbox;
   off_t base, offset;
 
-  base = surely_lseek (fd, 0, SEEK_CUR);
+  base = ftell (fd);
 
   bbox = mymalloc (nglyphs * sizeof (struct Box));
   for (i = 0; i < nglyphs; i++)
@@ -279,7 +288,7 @@ readGlyfTable (int fd, int nglyphs, int format, void *loca)
 }
 
 longHorMetric *
-readHmtxTable (int fd, int nummetrics)
+readHmtxTable (FILE *fd, int nummetrics)
 {
   longHorMetric *metrics;
   int i;
@@ -294,7 +303,7 @@ readHmtxTable (int fd, int nummetrics)
 }
 
 struct HheaTable *
-readHheaTable (int fd)
+readHheaTable (FILE *fd)
 {
   struct HheaTable *hhea;
   hhea = mymalloc (sizeof (struct HheaTable));
@@ -309,7 +318,7 @@ readHheaTable (int fd)
 }
 
 int
-readKernTable (int fd, int **nkep, struct KernEntry0 ***kep)
+readKernTable (FILE *fd, int **nkep, struct KernEntry0 ***kep)
 {
   struct KernTable kt;
   struct KernSubTableHeader ksth;