1 /* Copyright (c) 1997-1998 by Juliusz Chroboczek */
11 #define ALIAS_FILE_TO_FILECOOKIE
12 #include "libc-extension.hh"
14 static void endianness_test (void);
15 static void usage (char *);
20 create_type42 (const char *infile, FILE * out)
23 struct OffsetTable ot;
26 struct TableDirectoryEntry *td;
28 struct HheaTable *hhea = NULL;
29 struct Box *bbox = NULL;
30 longHorMetric *hmtx = NULL;
31 char **strings = NULL;
32 struct GlyphName *gnt = NULL;
33 struct KernEntry0 **ke;
35 int nglyphs, postType, nkern;
36 off_t headOff = 0, maxpOff = 0, postOff = 0, nameOff = 0,
37 locaOff = 0, glyfOff = 0, hheaOff = 0, hmtxOff = 0, kernOff = 0;
45 if ((fd = open (infile, O_RDONLY)) < 0)
46 syserror ("Error opening input file");
48 td = readDirectory (fd, &ot);
50 fprintf (stderr, "True type version %d.%u\n",
51 ot.version.mantissa, ot.version.fraction);
53 for (i = 0; i < ot.numTables; i++)
56 fprintf (stderr, "Found `%c%c%c%c' table\n",
57 (char) (td[i].tag >> 24),
58 (char) (td[i].tag >> 16) & 255,
59 (char) (td[i].tag >> 8) & 255, (char) td[i].tag & 255);
62 case MAKE_ULONG ('m', 'a', 'x', 'p'):
63 maxpOff = td[i].offset;
65 case MAKE_ULONG ('h', 'e', 'a', 'd'):
66 headOff = td[i].offset;
68 case MAKE_ULONG ('p', 'o', 's', 't'):
69 postOff = td[i].offset;
71 case MAKE_ULONG ('n', 'a', 'm', 'e'):
72 nameOff = td[i].offset;
74 case MAKE_ULONG ('l', 'o', 'c', 'a'):
75 locaOff = td[i].offset;
77 case MAKE_ULONG ('g', 'l', 'y', 'f'):
78 glyfOff = td[i].offset;
80 case MAKE_ULONG ('h', 'h', 'e', 'a'):
81 hheaOff = td[i].offset;
83 case MAKE_ULONG ('h', 'm', 't', 'x'):
84 hmtxOff = td[i].offset;
86 case MAKE_ULONG ('k', 'e', 'r', 'n'):
87 kernOff = td[i].offset;
91 if (maxpOff == 0 || headOff == 0 || postOff == 0 || nameOff == 0)
92 error ("Incomplete TTF file\n");
95 fprintf (stderr, "Processing `maxp' table\n");
96 surely_lseek (fd, maxpOff, SEEK_SET);
97 nglyphs = readMaxpTable (fd);
99 fprintf (stderr, " %d glyphs\n", nglyphs);
102 fprintf (stderr, "Processing `head' table\n");
103 surely_lseek (fd, headOff, SEEK_SET);
104 ht = mymalloc (sizeof (struct HeadTable));
105 readHeadTable (fd, ht);
108 fprintf (stderr, "Processing `post' table\n");
109 surely_lseek (fd, postOff, SEEK_SET);
110 pt = mymalloc (sizeof (struct PostTable));
111 postType = readPostTable (fd, nglyphs, pt, &gnt);
114 fprintf (stderr, "Processing `name' table\n");
115 surely_lseek (fd, nameOff, SEEK_SET);
116 strings = readNamingTable (fd);
119 fprintf (stderr, "Generating PS file\n");
120 printPSFont (out, ht, strings, nglyphs, postType, pt, gnt, fd);
123 fprintf (stderr, "Done.\n");
145 if (v != (((((1 << 8) + 2) << 8) + 3) << 8) + 4)
147 fprintf (stderr, "Code badly compiled for this architecture\n");
148 fprintf (stderr, "Please set SMALLENDIAN and recompile\n");