#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);
}
char **
-readNamingTable (int fd)
+readNamingTable (FILE *fd)
{
USHORT format;
USHORT nrecords;
char *data;
char **strings;
- position = surely_lseek (fd, 0, SEEK_CUR);
+ position = ftell (fd);
surely_read (fd, &format, sizeof (USHORT));
FIX_UH (format);
}
int
-readMaxpTable (int fd)
+readMaxpTable (FILE *fd)
{
struct
{
}
void
-readHeadTable (int fd, struct HeadTable *ht)
+readHeadTable (FILE *fd, struct HeadTable *ht)
{
surely_read (fd, ht, sizeof (struct HeadTable));
FIX_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;
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);
/*NOTREACHED*/}
void *
-readLocaTable (int fd, int nglyphs, int format)
+readLocaTable (FILE *fd, int nglyphs, int format)
{
int i;
switch (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++)
}
longHorMetric *
-readHmtxTable (int fd, int nummetrics)
+readHmtxTable (FILE *fd, int nummetrics)
{
longHorMetric *metrics;
int i;
}
struct HheaTable *
-readHheaTable (int fd)
+readHheaTable (FILE *fd)
{
struct HheaTable *hhea;
hhea = mymalloc (sizeof (struct HheaTable));
}
int
-readKernTable (int fd, int **nkep, struct KernEntry0 ***kep)
+readKernTable (FILE *fd, int **nkep, struct KernEntry0 ***kep)
{
struct KernTable kt;
struct KernSubTableHeader ksth;