and post table may differ. Pass around post_nglyphs as well.
+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
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);
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,
/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
+/*
+ TODO: junk this in favor of Freetype.
+ */
+
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
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)
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:
*/
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)
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);
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
}
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;
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,
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");
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");