#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
#include "types.h"
#include "proto.h"
+#include "ttftool.h"
struct TableDirectoryEntry *
readDirectory (int fd, struct OffsetTable *ot)
int i;
struct TableDirectoryEntry *td;
+ if (ttf_verbosity >= 3)
+ fprintf (stderr, "");
+
surely_read (fd, ot, sizeof (struct OffsetTable));
FIX_OffsetTable (*ot);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "%d tables\n", ot->numTables);
n = sizeof (struct TableDirectoryEntry) * ot->numTables;
td = mymalloc (n);
strings[records[i].nameID] = mymalloc (records[i].length / 2 + 1);
unistrncpy (strings[records[i].nameID],
data + records[i].offset, records[i].length);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "%d: %s\n", records[i].nameID,
strings[records[i].nameID]);
}
strncpy (strings[id],
data + records[i].offset, records[i].length);
strings[id][records[i].length] = 0;
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "%d: %s\n", records[i].nameID,
strings[records[i].nameID]);
}
surely_read (fd, &data, sizeof (data));
FIX_Fixed (data.version);
FIX_UH (data.nglyphs);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, " version %d.%u\n",
data.version.mantissa, data.version.fraction);
return data.nglyphs;
{
surely_read (fd, ht, sizeof (struct HeadTable));
FIX_HeadTable (*ht);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
{
fprintf (stderr, " version %d.%d\n",
ht->version.mantissa, ht->version.fraction);
}
if (ht->magicNumber != 0x5F0F3CF5)
ttf_error ("Bad magic number");
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, " %d units per Em\n", ht->unitsPerEm);
}
surely_read (fd, pt, sizeof (struct PostTable));
FIX_PostTable (*pt);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, " format type %d.%u\n",
pt->formatType.mantissa, pt->formatType.fraction);
FIX_UH (nglyphspost);
if (nglyphspost != nglyphs)
ttf_error ("Inconsistency between `maxp' and `nglyphs' tables!");
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, " %d glyphs\n", nglyphs);
glyphNameIndex = mymalloc (sizeof (USHORT) * nglyphs);
surely_read (fd, glyphNameIndex, sizeof (USHORT) * nglyphs);
glyphNamesTemp[i] = mymalloc (c + 1);
surely_read (fd, glyphNamesTemp[i], c);
glyphNamesTemp[i][c] = '\0';
- if (verbosity >= 3)
+ if (ttf_verbosity >= 3)
fprintf (stderr, " %d: %s\n", i, glyphNamesTemp[i]);
i++;
}
hhea = mymalloc (sizeof (struct HheaTable));
surely_read (fd, hhea, sizeof (struct HheaTable));
FIX_HheaTable (*hhea);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, " version %d.%u\n",
hhea->version.mantissa, hhea->version.fraction);
if (hhea->metricDataFormat != 0)
surely_read (fd, &kt, sizeof (struct KernTable));
FIX_KernTable (kt);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
{
fprintf (stderr, " version %d\n", kt.version);
fprintf (stderr, " %d subtables\n", kt.nTables);
{
surely_read (fd, &ksth, sizeof (struct KernSubTableHeader));
FIX_KernSubTableHeader (ksth);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, " analyzing subtable %d, version %d... ",
i, ksth.version);
if ((ksth.coverage & kernHorizontal) &&
{
surely_read (fd, &kst, sizeof (struct KernSubTable0));
FIX_KernSubTable0 (kst);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "reading %d entries.\n", kst.nPairs);
nke[i] = kst.nPairs;
ke[i] = mymalloc (kst.nPairs * sizeof (struct KernEntry0));
}
else
{
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "skipping.\n");
surely_lseek (fd, ksth.length - sizeof (struct KernSubTableHeader),
SEEK_CUR);
static void endianness_test (void);
static void usage (char *);
-int verbosity = 0;
+int ttf_verbosity = 0;
void
create_type42 (const char *infile, void *out)
}
td = readDirectory (fd, &ot);
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "True type version %d.%u\n",
ot.version.mantissa, ot.version.fraction);
for (i = 0; i < ot.numTables; i++)
{
- if (verbosity >= 2)
+ if (ttf_verbosity >= 2)
fprintf (stderr, "Found `%c%c%c%c' table\n",
(char) (td[i].tag >> 24),
(char) (td[i].tag >> 16) & 255,
if (maxpOff == 0 || headOff == 0 || postOff == 0 || nameOff == 0)
ttf_error ("Incomplete TTF file\n");
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, "Processing `maxp' table\n");
surely_lseek (fd, maxpOff, SEEK_SET);
nglyphs = readMaxpTable (fd);
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, " %d glyphs\n", nglyphs);
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, "Processing `head' table\n");
surely_lseek (fd, headOff, SEEK_SET);
ht = mymalloc (sizeof (struct HeadTable));
readHeadTable (fd, ht);
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, "Processing `post' table\n");
surely_lseek (fd, postOff, SEEK_SET);
pt = mymalloc (sizeof (struct PostTable));
postType = readPostTable (fd, nglyphs, pt, &gnt);
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, "Processing `name' table\n");
surely_lseek (fd, nameOff, SEEK_SET);
strings = readNamingTable (fd);
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, "Generating PS file\n");
printPSFont (out, ht, strings, nglyphs, postType, pt, gnt, fd);
lily_cookie_fclose (out);
- if (verbosity >= 1)
+ if (ttf_verbosity >= 1)
fprintf (stderr, "Done.\n");
close (fd);
}