From: hanwen Date: Tue, 21 Jun 2005 22:05:51 +0000 (+0000) Subject: (readPostTable): ugh. Kludge: nglyphs in maxp X-Git-Tag: release/2.5.32~11 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d16df970be64993ca36cc684da5a8d7ed132cfc1;p=lilypond.git (readPostTable): ugh. Kludge: nglyphs in maxp and post table may differ. Pass around post_nglyphs as well. --- diff --git a/ChangeLog b/ChangeLog index 8d67369665..a9e0f44954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-06-22 Han-Wen Nienhuys + + * 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 * ly/music-functions-init.ly (musicMap): new music function diff --git a/ttftool/include/proto.h b/ttftool/include/proto.h index d879f947c8..604c91995b 100644 --- a/ttftool/include/proto.h +++ b/ttftool/include/proto.h @@ -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, diff --git a/ttftool/parse.c b/ttftool/parse.c index cf43152b07..1f7f06fd83 100644 --- a/ttftool/parse.c +++ b/ttftool/parse.c @@ -1,5 +1,9 @@ /* Copyright (c) 1997-1998 by Juliusz Chroboczek */ +/* + TODO: junk this in favor of Freetype. + */ + #include #include #include @@ -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); diff --git a/ttftool/ps.c b/ttftool/ps.c index 1fbf7d0b9a..882a50c97d 100644 --- a/ttftool/ps.c +++ b/ttftool/ps.c @@ -24,11 +24,13 @@ 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; diff --git a/ttftool/ttfps.c b/ttftool/ttfps.c index 2be555f5f0..de9a88a31c 100644 --- a/ttftool/ttfps.c +++ b/ttftool/ttfps.c @@ -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");