]> git.donarmstrong.com Git - lilypond.git/commitdiff
(readPostTable): ugh. Kludge: nglyphs in maxp
authorhanwen <hanwen>
Tue, 21 Jun 2005 22:05:51 +0000 (22:05 +0000)
committerhanwen <hanwen>
Tue, 21 Jun 2005 22:05:51 +0000 (22:05 +0000)
and post table may differ. Pass around post_nglyphs as well.

ChangeLog
ttftool/include/proto.h
ttftool/parse.c
ttftool/ps.c
ttftool/ttfps.c

index 8d67369665408caa51d00424650caf8059668e51..a9e0f4495482c24ba0418cc9502d3a3bccafd26c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-06-22  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * ttftool/parse.c (readPostTable): ugh. Kludge: nglyphs in maxp
+       and post table may differ. Pass around post_nglyphs as well.
+
 2005-06-20  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * ly/music-functions-init.ly (musicMap): new music function
index d879f947c8a75f1c93721031f3b2668855db9234..604c91995b7a102f8dffdb87c10e6cf556697bcb 100644 (file)
@@ -3,8 +3,9 @@
 struct TableDirectoryEntry *readDirectory (FILE *fd, struct OffsetTable *ot);
 char **readNamingTable (FILE *fd);
 void readHeadTable (FILE *fd, struct HeadTable *ht);
-int readPostTable (FILE *fd, int nglyphs,
-                  struct PostTable *pt, struct GlyphName **gnt);
+int readPostTable (FILE *fd, int root_nglyphs,
+                  struct PostTable *pt, USHORT *nglyphs,
+                  struct GlyphName **gnt);
 int readMaxpTable (FILE *fd);
 void *readLocaTable (FILE *fd, int nglyphs, int format);
 struct Box *readGlyfTable (FILE *fd, int nglyphs, int format, void *loca);
@@ -14,13 +15,15 @@ int readKernTable (FILE *fd, int **nke, struct KernEntry0 ***ke);
 
 void printPSFont (void * out, struct HeadTable *ht,
                  char **strings, int nglyphs, int postType,
-                 struct PostTable *pt, struct GlyphName *gnt, FILE *fd);
+                 struct PostTable *pt,
+                 USHORT png,
+                 struct GlyphName *gnt, FILE *fd);
 
 void printPSHeader (void * out, struct HeadTable *ht,
                    char **strings, struct PostTable *pt);
 void printPSData (void * out, FILE *fd);
 void printPSTrailer (void * out, int nglyphs,
-                    int postType, struct GlyphName *gnt);
+                    int postType, USHORT pnt, struct GlyphName *gnt);
 
 void printAFM (FILE * afm, struct HeadTable *ht,
               char **strings, int nglyphs, int postType,
index cf43152b073f9437c5fa3ebea41a76870f50e797..1f7f06fd83f4104c847ce60705d2d23863166db0 100644 (file)
@@ -1,5 +1,9 @@
 /* Copyright (c) 1997-1998 by Juliusz Chroboczek */
 
+/*
+  TODO: junk this  in favor of Freetype.
+ */
+
 #include <sys/types.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -150,15 +154,15 @@ readHeadTable (FILE *fd, struct HeadTable *ht)
 
 int
 readPostTable (FILE *fd, int root_nglyphs, struct PostTable *pt,
-              struct GlyphName **gt)
+              USHORT *nglyphs, struct GlyphName **gt)
 {
-  USHORT nglyphs;
   USHORT *glyphNameIndex;
   struct GlyphName *glyphNames;
   char **glyphNamesTemp;
   int i, maxIndex;
   CHAR c;
 
+  *nglyphs = 0; 
   surely_read (fd, pt, sizeof (struct PostTable));
   FIX_PostTable (*pt);
   if (ttf_verbosity >= 2)
@@ -172,7 +176,7 @@ readPostTable (FILE *fd, int root_nglyphs, struct PostTable *pt,
     case 2:
       if (pt->formatType.fraction != 0)
        ttf_error ("Unsupported `post' table format");
-      surely_read (fd, &nglyphs, sizeof (USHORT));
+      surely_read (fd, nglyphs, sizeof (USHORT));
 
       /*from freetype2:
        */
@@ -180,18 +184,18 @@ readPostTable (FILE *fd, int root_nglyphs, struct PostTable *pt,
        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)
+      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);
-      surely_read (fd, glyphNameIndex, sizeof (USHORT) * nglyphs);
-      glyphNames = mymalloc (sizeof (struct GlyphName) * nglyphs);
-      for (i = 0, maxIndex = -1; i < nglyphs; i++)
+       fprintf (stderr, "  %d glyphs\n", *nglyphs);
+      glyphNameIndex = mymalloc (sizeof (USHORT) * *nglyphs);
+      surely_read (fd, glyphNameIndex, sizeof (USHORT) * *nglyphs);
+      glyphNames = mymalloc (sizeof (struct GlyphName) * *nglyphs);
+      for (i = 0, maxIndex = -1; i < *nglyphs; i++)
        {
          FIX_UH (glyphNameIndex[i]);
          if (glyphNameIndex[i] < 258)
@@ -222,7 +226,7 @@ readPostTable (FILE *fd, int root_nglyphs, struct PostTable *pt,
            fprintf (stderr, "    %d: %s\n", i, glyphNamesTemp[i]);
          i++;
        }
-      for (i = 0; i < nglyphs; i++)
+      for (i = 0; i < *nglyphs; i++)
        if (glyphNames[i].type == 1)
          glyphNames[i].name.name = glyphNamesTemp[glyphNames[i].name.index];
       free (glyphNamesTemp);
index 1fbf7d0b9ade3fe626b08d6b07d76e4ad3df0e5e..882a50c97d87e248e849c842d11228c4c946ee33 100644 (file)
 void
 printPSFont (void *out, struct HeadTable *ht,
             char **strings, int nglyphs, int postType,
-            struct PostTable *pt, struct GlyphName *gnt, FILE *fd)
+            struct PostTable *pt,
+            USHORT post_nglyphs,
+            struct GlyphName *gnt, FILE *fd)
 {
   printPSHeader (out, ht, strings, pt);
   printPSData (out, fd);
-  printPSTrailer (out, nglyphs, postType, gnt);
+  printPSTrailer (out, nglyphs, post_nglyphs, postType, gnt);
 }
 
 void
@@ -115,7 +117,8 @@ printPSData (void *out, FILE *fd)
 }
 
 void
-printPSTrailer (void *out, int nglyphs, int postType, struct GlyphName *gnt)
+printPSTrailer (void *out, int nglyphs, int postType,
+               USHORT postNGlyphs, struct GlyphName *gnt)
 {
   int i, n;
   char *name;
index 2be555f5f0a35966e6863d555ccbbf728f4825b8..de9a88a31c09471bda50879011eea4e430cb1eb8 100644 (file)
@@ -30,6 +30,7 @@ create_type42 (const char *infile, void *out)
   char **strings = NULL;
   struct GlyphName *gnt = NULL;
   struct KernEntry0 **ke;
+  USHORT post_nglyphs = 0;
   int *nke;
   int nglyphs, postType, nkern;
   off_t headOff = 0, maxpOff = 0, postOff = 0, nameOff = 0,
@@ -109,7 +110,8 @@ create_type42 (const char *infile, void *out)
     fprintf (stderr, "Processing `post' table\n");
   surely_lseek (fd, postOff, SEEK_SET);
   pt = mymalloc (sizeof (struct PostTable));
-  postType = readPostTable (fd, nglyphs, pt, &gnt);
+  
+  postType = readPostTable (fd, nglyphs, pt, &post_nglyphs, &gnt);
 
   if (ttf_verbosity >= 1)
     fprintf (stderr, "Processing `name' table\n");
@@ -118,7 +120,7 @@ create_type42 (const char *infile, void *out)
 
   if (ttf_verbosity >= 1)
     fprintf (stderr, "Generating PS file\n");
-  printPSFont (out, ht, strings, nglyphs, postType, pt, gnt, fd);
+  printPSFont (out, ht, strings, nglyphs, postType, pt, post_nglyphs, gnt, fd);
   lily_cookie_fclose (out);
   if (ttf_verbosity >= 1)
     fprintf (stderr, "Done.\n");