All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GlyphLessFont.c
Go to the documentation of this file.
1 /* I don't expect anyone to run this program, ever again. It is
2  * included primarily as documentation for how the GlyphLessFont was
3  * created.
4  */
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include "GlyphLessFont.h"
10 
11 #define LITTLE_ENDIAN
12 
14 #ifdef LITTLE_ENDIAN
15  0x00000100, /* sfnt_version */
16  0x0A00, /* numTables (10) */
17  0x8000, /* searchRange = Max power of 2 <= numTables*16 (128) */
18  0x0300, /* entrySelector Log2(searchRange) (3) */
19  0x2000, /* rangeShift = numTables*16 - searchRange (160 - 128 = 32) */
20 #else
21  0x00010000, /* sfnt_version */
22  0x000A, /* numTables (10) */
23  0x0080, /* searchRange = Max power of 2 <= numTables*16 (128) */
24  0x0003, /* entrySelector Log2(searchRange) (3) */
25  0x0020, /* rangeShift = numTables*16 - searchRange (160 - 128 = 32) */
26 #endif
27 };
28 
30 #ifdef LITTLE_ENDIAN
31  0x00000100, /* sfnt_version */
32  0x00000100, /* font_version */
33  0, /* checksum adjustment */
34  0xF53C0F5F, /* Magic number */
35  0x0704, /* flags:
36  * Bit 0 - 1 - baseline of font at y = 0
37  * Bit 1 - 1 - Left sidebearing at x = 0
38  * Bit 2 - 0 - instructions not dependent on font size
39  * Bit 3 - 1 - force integer ppem
40  * Bit 4 - 0 - instructions may not alter advance width
41  * Bit 5 - 0 - Not laid out vertically
42  * Bit 6 - 0 - required to be 0
43  * Bit 7 - 0 - Does not require layout for rendering
44  * Bit 8 - 0 - Not an AAT font with metamorphosis
45  * Bit 9 - 0 - Not strongly right to left
46  * Bit 10 - 0 - Does not require indic-style rearrangements
47  * Bit 11 - 0 - Font data is not 'lossless'
48  * Bit 12 - 0 - Font not 'covnerted'
49  * Bit 13 - 0 - Not optimised for ClearType
50  * Bit 14 - 1 - This is a 'last resort' font
51  * Bit 15 - 0 - Reserved, must be 0
52  */
53  0x0001, /* 16 units per em */
54  0x0,0x6EFC9ACF,/* Creation time */
55  0x0,0x6EFC9ACF,/* Modified time */
56  0, /* xMin */
57  0x0080, /* yMin */
58  0, /* xMax */
59  0x0100, /* yMax */
60  0x0000, /* macStyle (none) */
61  0x1000, /* Lowest readable size (16 pixels) */
62  0x0200, /* font direction (deprecated, should be 2) */
63  0, /* index to LOCA format (shorts) */
64  0 /* glyph data format (must be 0) */
65 #else
66  0x00010000, /* afnt version */
67  0x00010000, /* font version */
68  0, /* checksum adjustment */
69  0x5F0F3CF5, /* Magic number */
70  0x0407, /* flags:
71  * Bit 0 - 1 - baseline of font at y = 0
72  * Bit 1 - 1 - Left sidebearing at x = 0
73  * Bit 2 - 0 - instructions not dependent on font size
74  * Bit 3 - 1 - force integer ppem
75  * Bit 4 - 0 - instructions may not alter advance width
76  * Bit 5 - 0 - Not laid out vertically
77  * Bit 6 - 0 - required to be 0
78  * Bit 7 - 0 - Does not require layout for rendering
79  * Bit 8 - 0 - Not an AAT font with metamorphosis
80  * Bit 9 - 0 - Not strongly right to left
81  * Bit 10 - 0 - Does not require indic-style rearrangements
82  * Bit 11 - 0 - Font data is not 'lossless'
83  * Bit 12 - 0 - Font not 'covnerted'
84  * Bit 13 - 0 - Not optimised for ClearType
85  * Bit 14 - 1 - This is a 'last resort' font
86  * Bit 15 - 0 - Reserved, must be 0
87  */
88  0x0100, /* 16 units per em */
89  0x0,0xCF9AFC6E,/* Creation time */
90  0x0,0xCF9AFC6E,/* Modified time */
91  0, /* xMin */
92  0xFFFF, /* yMin */
93  0, /* xMax */
94  0x001, /* yMax */
95  0, /* macStyle (none) */
96  0x0010, /* Lowest readable size (16 pixels) */
97  0x0002, /* font direction (deprecated, should be 2) */
98  0, /* index to LOCA format (shorts) */
99  0 /* glyph data format (must be 0) */
100 #endif
101 };
102 
104 #ifdef LITTLE_ENDIAN
105  0x00000100, /* table version */
106  0x0100, /* Ascender */
107 #else
108  0x00001000, /* table version */
109  0x0001, /* Ascender */
110 #endif
111  0xFFFF, /* Descender */
112  0x0000, /* LineGap */
113  0x0000, /* AdvanceWidthMax */
114  0x0000, /* MinLeftSideBearing */
115  0x0000, /* MinRightSideBearing */
116  0x0000, /* xMaxExtent */
117 #ifdef LITTLE_ENDIAN
118  0x0100, /* caretSlopeRise (1 = vertical) */
119 #else
120  0x0001, /* caretSlopeRise (1 = vertical) */
121 #endif
122  0x0000, /* caretslopeRun (0 = vertical) */
123  0x0000, /* caretOffset */
124  0x0000, /* Reserved1 */
125  0x0000, /* Reserved2 */
126  0x0000, /* Reserved3 */
127  0x0000, /* Reserved4 */
128  0x0000, /* merticDataFormat (must be 0) */
129 #ifdef LITTLE_ENDIAN
130  0x0200, /* number of hMetric entries in hmtx */
131 #else
132  0x0002, /* number of hMetric entries in hmtx */
133 #endif
134 };
135 
137 #ifdef LITTLE_ENDIAN
138  0x00000100, /* table version */
139  0x0200, /* numGlyphs */
140  0x00000000, /* maxPoints */
141  0x00000000, /* maxContours */
142  0x00000000, /* maxCompositePoints */
143  0x00000000, /* maxCompositeContours */
144  0x00000100, /* maxZones */
145  0x00000000, /* maxTwilightPoints */
146  0x00000000, /* maxStorage */
147  0x00000000, /* maxFunctionDefs */
148  0x00000000, /* maxInstructionDefs */
149  0x00000000, /* maxStackElements */
150  0x00000000, /* maxSizeOfInstructions */
151  0x00000000, /* maxComponentElements */
152  0x00000000, /* maxComponentDepth */
153 #else
154  0x00001000, /* table version */
155  0x0002, /* numGlyphs */
156  0x00000000, /* maxPoints */
157  0x00000000, /* maxContours */
158  0x00000000, /* maxCompositePoints */
159  0x00000000, /* maxCompositeContours */
160  0x00000001, /* maxZones */
161  0x00000000, /* maxTwilightPoints */
162  0x00000000, /* maxStorage */
163  0x00000000, /* maxFunctionDefs */
164  0x00000000, /* maxInstructionDefs */
165  0x00000000, /* maxStackElements */
166  0x00000000, /* maxSizeOfInstructions */
167  0x00000000, /* maxComponentElements */
168  0x00000000, /* maxComponentDepth */
169 #endif
170 };
171 
173 #ifdef LITTLE_ENDIAN
174  0x0300, /* table version */
175  0x0000, /* xAvgCharWidth */
176  0x9001, /* usWeight Class (400 = FW_NORMAL) */
177  0x0500, /* usWidthClass (5 = FWIDTH_NORMAL) */
178  0x0000, /* fsType (0 = no embedding restrictions) */
179  0x0000, /* ySubscriptXSize */
180  0x0000, /* ySubscriptYSize */
181  0x0000, /* ySubscriptXOffset */
182  0x0000, /* ySubscriptYOffset */
183  0x0000, /* ySuperscriptXSize */
184  0x0000, /* ySuperscriptYSize */
185  0x0000, /* ySuperscriptXOffset */
186  0x0000, /* ySuperscriptYOffset */
187  0x0000, /* yStikeoutPosition */
188  0x0000, /* sFamilyClass (0 = no classification) */
189  0,5,0,1,0,1,0,0,0,0,0, /* PANOSE */
190  0x00000000, /* ulUnicodeRanges1 */
191  0x00000000, /* ulUnicodeRanges2 */
192  0x00000000, /* ulUnicodeRanges3 */
193  0x00000000, /* ulUnicodeRanges4 */
194  'G', 'O', 'O', 'G', /* achVendID (GOOG = Google) */
195  0x4000, /* fsSelection (bit 6 set = regular font) */
196  0xFFFF, /* fsFirstCharIndex */
197  0x0000, /* fsLastCharIndex */
198  0x0100, /* sTypoAscender */
199  0xFFFF, /* StypoDescender */
200  0x0000, /* STypoLineGap */
201  0x0100, /* usWinAscent */
202  0x0100, /* usWinDescent */
203  0x00000080,/* ulCodePageRange1 */
204  0x00000000,/* ulCodePageRange2 */
205  0x0000, /* sxHeight */
206  0x0000, /* sCapHeight */
207  0x0000, /* usDefaultChar */
208  0x0100, /* usBreakChar */
209  0x0000, /* usMaxContent */
210 #else
211  0x0003, /* table version */
212  0x0000, /* xAvgCharWidth */
213  0x0190, /* usWeight Class (400 = FW_NORMAL) */
214  0x0005, /* usWidthClass (5 = FWIDTH_NORMAL) */
215  0x0000, /* fsType (0 = no embedding restrictions) */
216  0x0000, /* ySubscriptXSize */
217  0x0000, /* ySubscriptYSize */
218  0x0000, /* ySubscriptXOffset */
219  0x0000, /* ySubscriptYOffset */
220  0x0000, /* ySuperscriptXSize */
221  0x0000, /* ySuperscriptYSize */
222  0x0000, /* ySuperscriptXOffset */
223  0x0000, /* ySuperscriptYOffset */
224  0x0000, /* yStikeoutPosition */
225  0x0000, /* sFamilyClass (0 = no classification) */
226  0,5,0,1,0,1,0,0,0,0,0, /* PANOSE */
227  0x00000000,/* ulUnicodeRanges1 */
228  0x00000000,/* ulUnicodeRanges2 */
229  0x00000000,/* ulUnicodeRanges3 */
230  0x00000000,/* ulUnicodeRanges4 */
231  'G', 'O', 'O', 'G', /* achVendID (GOOG = Google) */
232  0x0040, /* fsSelection (bit 6 set = regular font) */
233  0xFFFF, /* fsFirstCharIndex */
234  0x0000, /* fsLastCharIndex */
235  0x0001, /* sTypoAscender */
236  0xFFFF, /* StypoDescender */
237  0x0000, /* STypoLineGap */
238  0x0001, /* usWinAscent */
239  0x0001, /* usWinDescent */
240  0x80000000,/* ulCodePageRange1 */
241  0x00000000,/* ulCodePageRange2 */
242  0x0000, /* sxHeight */
243  0x0000, /* sCapHeight */
244  0x0000, /* usDefaultChar */
245  0x0001, /* usBreakChar */
246  0x0000, /* usMaxContent */
247 #endif
248 };
249 
251 0x0000, 0x0000,
252 0x0000, 0x0000
253 };
254 
256  0x0000, /* Cmap version (0) */
257 #ifdef LITTLE_ENDIAN
258  0x0200, /* numTables (2) */
259  0x0100, /* Start of first subtable record, platformID = 1 */
260  0x0000, /* encodingID = 0 */
261  0x14000000, /* Offset of data */
262  0x0300, /* Start of second subtable record, platformID = 3 */
263  0x0000, /* encodingID = 0 */
264  0x20000000, /* Offset of data */
265  0x0600, /* STart of Apple table (format 6) */
266  0x0C00, /* lenght of table (12) */
267  0x0000, /* Language must be 0 for non-Apple or
268  non-specific language */
269  0x0000, /* firstCode = 0 */
270  0x0100, /* number of codes is 1 */
271  0x0000, /* GID is 0 */
272  0x0600, /* Start of MS Table (format 4) */
273  0x0C00, /* lenght of table (12) */
274  0x0000, /* Language must be 0 for non-Apple or
275  non-specific language */
276  0x0000, /* firstCode = 0 */
277  0x0100, /* number of codes is 1 */
278  0x0000, /* GID is 0 */
279 #else
280  0x0002, /* numTables (2) */
281  0x0001,
282  0x0000,
283  0x00000014,
284  0x0003,
285  0x0000,
286  0x00000020,
287  0x0006,
288  0x000C,
289  0x0000,
290  0x0000,
291  0x0001,
292  0x0000,
293  0x0006,
294  0x000C,
295  0x0000,
296  0x0000,
297  0x0001,
298  0x0000,
299 #endif
300 };
301 
302 /* Changing these strings requires you to change the offset and lengths
303  in the name table below */
304 char Macnamestring[] = {'V', 'e', 'r', 's', 'i', 'o', 'n', ' ', '1', '.', '0'};
305 char Unamestring[] = {0x00, 'V', 0x00, 'e', 0x00, 'r', 0x00, 's', 0x00, 'i',
306  0x00, 'o', 0x00, 'n', 0x00, ' ', 0x00, '1', 0x00, '.',
307  0x00, '0', 0x00, 0x00, 0x00};
309  0x0000, /* format 0 */
310 #ifdef LITTLE_ENDIAN
311  0x0300, /* 3 records */
312  0x2A00, /* Offset of string storage */
313 
314  0x0000, /* Start of 1st name record, platform = 0 (Unicode) */
315  0x0300, /* Platform-specific ID = 0 */
316  0x0000, /* Language ID (0 = none) */
317  0x0500, /* name ID (5 = version string) */
318  0x1600, /* String length */
319  0x0B00, /* Offset from start of storage */
320 
321  0x0100, /* Start of 2nd name record, platform = 1 (Mac) */
322  0x0000,
323  0x0000,
324  0x0500, /* name ID (5 = version string) */
325  0x0B00, /* String length */
326  0x0000, /* Offset from start of storage */
327 
328  0x0300, /* Start of 3rd name record, platform = 3 */
329  0x0100, /* Platform-specific ID = 1 */
330  0x0904, /* Language ID (0x409 = US English) */
331  0x0500, /* name ID (5 = version string) */
332  0x1600, /* String length */
333  0x0B00, /* Offset from start of storage */
334 #else
335  0x0003, /* 3 record2 */
336  0x002A, /* Offset of string storage */
337 
338  0x0000, /* Start of 1st name record, platform = 0 (Unicode) */
339  0x0003, /* Platform-specific ID = 0 */
340  0x0000, /* Language ID (0 = none) */
341  0x0005, /* name ID (5 = version string) */
342  0x0016, /* String length */
343  0x000B, /* Offset from start of storage */
344 
345  0x0001, /* Start of 2nd name record, platform = 1 (Mac) */
346  0x0000,
347  0x0000,
348  0x0500, /* name ID (5 = version string) */
349  0x000B, /* String length */
350  0x0000, /* Offset from start of storage */
351 
352  0x0003, /* Start of 3rd name record, platform = 3 */
353  0x0001, /* Platform-specific ID = 0 */
354  0x0409, /* Language ID (0 = none) */
355  0x0005, /* name ID (5 = version string) */
356  0x0016, /* String length */
357  0x000B, /* Offset from start of storage */
358 #endif
359 };
360 
362 #ifdef LITTLE_ENDIAN
363  0x0100, /* Version (2) */
364 #else
365  0x0001, /* Version (2) */
366 #endif
367  0x00000000, /* italicAngle */
368  0x0000, /* underlinePosition */
369  0x0000, /* underlineThickness */
370 #ifdef LITTLE_ENDIAN
371  0x01000000, /* isFixedPitch */
372 #else
373  0x00000001, /* isFixedPitch */
374 #endif
375  0x00000000, /* minMemType42 */
376  0x00000000, /* maxMemType42 */
377  0x00000000, /* minMemType1 */
378  0x00000000, /* maxMemType1 */
379 };
380 
381 int main (int argc, char **argv)
382 {
383  FILE *OutputFile;
384  TableRecord Table[10];
385  unsigned long offset =
386  sizeof(Offset_Table) + (sizeof(TableRecord) * 10),
387  length = 0, checksum = 0, HeadTableOffset, Working;
388  short fword = -1;
389  short loca = 0;
390  long glyf = 0;
391  unsigned int NameLength, i, FileLength;
392 
393  printf("Ken's Glyph-free font creator\n");
394  if (argc != 2) {
395  fprintf (stderr, "Usage: GlyphLessFont <output filename>\n");
396  exit (1);
397  }
398 
399  OutputFile = fopen (argv[1], "wb+");
400  if (OutputFile == 0) {
401  fprintf (stderr, "Couldn't open file %s for writing\n", argv[1]);
402  exit (1);
403  }
404 
405  fwrite (&Offsets, sizeof(Offset_Table), 1, OutputFile);
406  memset(&Table, 0x00, sizeof(TableRecord) + 10);
407  fwrite (&Table, sizeof (TableRecord), 10, OutputFile);
408  offset = ftell(OutputFile);
409  Table[3].offset = HeadTableOffset = offset;
410 
411  /* The whole business of writing a TrueType file is complicated by
412  * the way its laid out Firstly there is the fact that it wants
413  * the tables to be laid out in alphabetical order, but it wants
414  * the actual table data (which the table record points to) to be
415  * in quite a different order. Then there's the requirement to
416  * have all the table offsets be a multiple of 4 bytes. Finally
417  * we have to calculate a checksum for each table as well, which
418  * we cna't realistically do until we have written the table data,
419  * but which gets stored in the table record at the start of the
420  * file.
421  *
422  * So we start by writing a dumm set of table records, we'll fill
423  * in the array as we go and once we've written all the data and
424  * worked out the offsets and checksums of all the tables, we'll
425  * come back and write the table records into the area we left
426  * reserved.
427  */
428  fwrite (&head, sizeof(head_table), 1, OutputFile);
429  offset = ftell(OutputFile);
430  Table[4].offset = offset;
431 
432  fwrite (&hhea, sizeof(hhea_table), 1, OutputFile);
433  offset = ftell(OutputFile);
434  Table[7].offset = offset;
435 
436  fwrite (&maxp, sizeof(maxp_table), 1, OutputFile);
437  offset = ftell(OutputFile);
438  Table[0].offset = offset;
439 
440  fwrite (&OS2, sizeof(OS2_table), 1, OutputFile);
441  offset = ftell(OutputFile);
442  Table[5].offset = offset;
443 
444  fwrite (&hmtx, sizeof(hmtx_table), 1, OutputFile);
445  offset = ftell(OutputFile);
446  Table[1].offset = offset;
447 
448  fwrite (&cmap, sizeof(cmap_table), 1, OutputFile);
449  offset = ftell(OutputFile);
450  Table[6].offset = offset;
451 
452  fwrite (&loca, sizeof(short), 1, OutputFile);
453  fwrite (&loca, sizeof(short), 1, OutputFile);
454  fwrite (&loca, sizeof(short), 1, OutputFile);
455  fwrite (&loca, sizeof(short), 1, OutputFile);
456  offset = ftell(OutputFile);
457  Table[2].offset = offset;
458 
459  fwrite (&glyf, sizeof(long), 1, OutputFile);
460  offset = ftell(OutputFile);
461  Table[8].offset = offset;
462 
463  length = (sizeof(name_table) + sizeof(Macnamestring) +
464  sizeof(Unamestring) + 3) / 4;
465  length *= 4;
466  NameLength = length;
467  fwrite (&name, sizeof(name_table), 1, OutputFile);
468  fwrite (&Macnamestring, sizeof(Macnamestring), 1, OutputFile);
469  fwrite (&Unamestring, NameLength -
470  (sizeof(name_table) + sizeof(Macnamestring)), 1, OutputFile);
471  offset = ftell(OutputFile);
472  Table[9].offset = offset;
473 
474  fwrite (&post, sizeof(post_table), 1, OutputFile);
475  FileLength = ftell(OutputFile);
476 
477  Table[3].tag[0] = 'h';
478  Table[3].tag[1] = 'e';
479  Table[3].tag[2] = 'a';
480  Table[3].tag[3] = 'd';
481  Table[3].checkSum = 0;
482  Table[3].length = sizeof(head_table) - 2; /* Don't count size
483  of padding bytes in table */
484 
485  Table[4].tag[0] = 'h';
486  Table[4].tag[1] = 'h';
487  Table[4].tag[2] = 'e';
488  Table[4].tag[3] = 'a';
489  Table[4].checkSum = 0;
490  Table[4].length = sizeof(hhea_table);
491 
492  Table[7].tag[0] = 'm';
493  Table[7].tag[1] = 'a';
494  Table[7].tag[2] = 'x';
495  Table[7].tag[3] = 'p';
496  Table[7].checkSum = 0;
497  Table[7].length = sizeof(maxp_table);
498 
499  Table[0].tag[0] = 'O';
500  Table[0].tag[1] = 'S';
501  Table[0].tag[2] = '/';
502  Table[0].tag[3] = '2';
503  Table[0].checkSum = 0;
504  Table[0].length = sizeof(OS2_table);
505 
506  Table[5].tag[0] = 'h';
507  Table[5].tag[1] = 'm';
508  Table[5].tag[2] = 't';
509  Table[5].tag[3] = 'x';
510  Table[5].checkSum = 0;
511  Table[5].length = sizeof(hmtx_table);
512 
513  Table[1].tag[0] = 'c';
514  Table[1].tag[1] = 'm';
515  Table[1].tag[2] = 'a';
516  Table[1].tag[3] = 'p';
517  Table[1].checkSum = 0;
518  Table[1].length = sizeof(cmap_table);
519 
520  Table[6].tag[0] = 'l';
521  Table[6].tag[1] = 'o';
522  Table[6].tag[2] = 'c';
523  Table[6].tag[3] = 'a';
524  Table[6].checkSum = 0;
525  Table[6].length = sizeof(USHORT) * 3;
526 
527  Table[2].tag[0] = 'g';
528  Table[2].tag[1] = 'l';
529  Table[2].tag[2] = 'y';
530  Table[2].tag[3] = 'f';
531  Table[2].checkSum = 0;
532  Table[2].length = 1;
533 
534  Table[8].tag[0] = 'n';
535  Table[8].tag[1] = 'a';
536  Table[8].tag[2] = 'm';
537  Table[8].tag[3] = 'e';
538  Table[8].checkSum = 0;
539  Table[8].length = (sizeof(name_table) +
540  sizeof(Macnamestring) +
541  sizeof(Unamestring) + 3) / 4;
542  Table[8].length *= 4;
543  NameLength = Table[8].length;
544 
545  Table[9].tag[0] = 'p';
546  Table[9].tag[1] = 'o';
547  Table[9].tag[2] = 's';
548  Table[9].tag[3] = 't';
549  Table[9].checkSum = 0;
550  Table[9].length = sizeof(post_table);
551 
552  for (i=0;i<10;i++) {
553  ULONG LENGTH, Sum = 0L;
554  ULONG *EndPtr, *Data, *Current;
555 
556  offset = Table[i].offset;
557  length = Table[i].length;
558  LENGTH = (length + 3 & ~3);
559  Data = (ULONG *)malloc(LENGTH);
560  memset(Data, 0x00, LENGTH);
561  fseek(OutputFile, offset, SEEK_SET);
562  fread(Data, length, 1, OutputFile);
563 
564  Current = Data;
565  EndPtr = Data + (LENGTH / sizeof(ULONG));
566  while(Current < EndPtr){
567 #ifdef LITTLE_ENDIAN
568  Working = *Current++;
569  Sum += ((Working & 0xff) << 24) +
570  ((Working & 0xff00) << 8) +
571  ((Working & 0xff0000) >> 8) +
572  (Working >> 24);
573 #else
574  Sum += *Current++;
575 #endif
576  }
577  free(Data);
578 
579 #ifdef LITTLE_ENDIAN
580  Table[i].offset =
581  ((offset & 0xff) << 24) +
582  ((offset & 0xff00) << 8) +
583  ((offset & 0xff0000) >> 8) +
584  (offset >> 24);
585  Table[i].length =
586  ((length & 0xff) << 24) +
587  ((length & 0xff00) << 8) +
588  ((length & 0xff0000) >> 8) +
589  (length >> 24);
590  Table[i].checkSum =
591  ((Sum & 0xff) << 24) +
592  ((Sum & 0xff00) << 8) +
593  ((Sum & 0xff0000) >> 8) +
594  (Sum >> 24);
595 #else
596  Table[i].checkSum = Sum;
597 #endif
598  }
599 
600  fseek(OutputFile, sizeof(Offset_Table), SEEK_SET);
601  fwrite (&Table, sizeof(TableRecord), 10, OutputFile);
602 
603  fseek(OutputFile, 0, SEEK_SET);
604 
605  for (i=0;i < FileLength / sizeof(long);i++) {
606  fread(&Working, sizeof(long), 1, OutputFile);
607 #ifdef LITTLE_ENDIAN
608  checksum += ((Working & 0xff) << 24) +
609  ((Working & 0xff00) << 8) +
610  ((Working & 0xff0000) >> 8) +
611  (Working >> 24);
612 #else
613  checksum += Working;
614 #endif
615  }
616  checksum = 0xB1B0AFBA - checksum;
617 #ifdef LITTLE_ENDIAN
618  head.checkSumAdjustment =
619  ((checksum & 0xff) << 24) +
620  ((checksum & 0xff00) << 8) +
621  ((checksum & 0xff0000) >> 8) +
622  (checksum >> 24);
623 #else
624  head.checkSumAdjustment = checksum;
625 #endif
626  fseek(OutputFile, HeadTableOffset, SEEK_SET);
627  fwrite (&head, sizeof(head_table), 1, OutputFile);
628  fclose(OutputFile);
629 
630  return 0;
631 }
char Unamestring[]
maxp_table maxp
head_table head
Definition: GlyphLessFont.c:29
post_table post
unsigned short USHORT
Definition: GlyphLessFont.h:14
Offset_Table Offsets
Definition: GlyphLessFont.c:13
ULONG checkSum
Definition: GlyphLessFont.h:42
ULONG checkSumAdjustment
hhea_table hhea
name_table name
cmap_table cmap
char Macnamestring[]
OS2_table OS2
hmtx_table hmtx
#define LENGTH(a)
Definition: vecfuncs.h:70
int main(int argc, char **argv)
unsigned long ULONG
Definition: GlyphLessFont.h:17