Debian Codegraph @

texk/ttfdump/libttf/head.c

raw
1 /* head.c -- Header Table
2 * Copyright (C) 1996 Li-Da Lho, All right reserved
3 */
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "ttf.h"
11 #include "ttfutil.h"
12
13 /* $Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
14
15 static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset);
16
17 void ttfInitHEAD(TTFontPtr font)
18 {
19 ULONG tag = FT_MAKE_TAG ('h', 'e', 'a', 'd');
20 TableDirPtr ptd;
21
22 if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
23 {
24 font->head = XCALLOC1 (HEAD);
25 ttfLoadHEAD(font->fp,font->head,ptd->offset);
26 }
27 }
28
29 static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset)
30 {
31 xfseek(fp, offset, SEEK_SET, "ttfLoadHEAD");
32
33 head->version = ttfGetFixed(fp);
34 head->fontRevision = ttfGetFixed(fp);
35 head->checkSumAdj = ttfGetULONG(fp);
36 head->magicNumber = ttfGetULONG(fp);
37 head->flags = ttfGetUSHORT(fp);
38 head->unitsPerEm = ttfGetUSHORT(fp);
39
40 ttfReadULONG (head->created, 2, fp);
41 ttfReadULONG (head->modified, 2, fp);
42
43 head->xMin = ttfGetFWord(fp);
44 head->yMin = ttfGetFWord(fp);
45 head->xMax = ttfGetFWord(fp);
46 head->yMax = ttfGetFWord(fp);
47
48 head->macStyle = ttfGetUSHORT(fp);
49 head->lowestRecPPEM = ttfGetUSHORT(fp);
50
51 head->fontDirectionHint = ttfGetSHORT(fp);
52 head->indexToLocFormat = ttfGetSHORT(fp);
53 head->glyphDataFormat = ttfGetSHORT(fp);
54 }
55
56 void ttfPrintHEAD(FILE *fp,HEADPtr head)
57 {
58 int b1[2],b2[2];
59
60 FixedSplit(head->version,b1);
61 FixedSplit(head->fontRevision,b2);
62
63 fprintf(fp,"'head' Table - Font Header\n");
64 fprintf(fp,"--------------------------\n");
65 fprintf(fp,"\t 'head' version:\t %d.%d\n",b1[1],b1[0]);
66 fprintf(fp,"\t fontReversion:\t\t %d.%d\n",b2[1],b2[0]);
67 fprintf(fp,"\t checkSumAdjustment:\t 0x%08x\n",head->checkSumAdj);
68 fprintf(fp,"\t magicNumber:\t\t 0x%08x\n",head->magicNumber);
69 fprintf(fp,"\t flags:\t\t\t 0x%04x\n",head->flags);
70 fprintf(fp,"\t unitsPerEm:\t\t %d\n",head->unitsPerEm);
71
72 /* don't know how to compute */
73 fprintf(fp,"\t created:\t\t 0x%08x%08x\n", head->created[0], head->created[1]);
74 fprintf(fp,"\t modified:\t\t 0x%08x%08x\n", head->modified[0], head->modified[1]);
75
76 fprintf(fp,"\t xMin:\t\t\t %d\n",head->xMin);
77 fprintf(fp,"\t yMin:\t\t\t %d\n",head->yMin);
78 fprintf(fp,"\t xMax:\t\t\t %d\n",head->xMax);
79 fprintf(fp,"\t yMax:\t\t\t %d\n",head->yMax);
80 fprintf(fp,"\t macStyle bits:\t\t 0x%04x\n",head->macStyle);
81 fprintf(fp,"\t lowestRecPPEM:\t\t %d\n",head->lowestRecPPEM);
82 fprintf(fp,"\t fontDirectionHint:\t %d\n",head->fontDirectionHint);
83 fprintf(fp,"\t indexToLocFormat:\t %d\n",head->indexToLocFormat);
84 fprintf(fp,"\t glyphDataFormat:\t %d\n",head->glyphDataFormat);
85 fprintf(fp,"\n");
86 }
87
88 void ttfFreeHEAD(HEADPtr head)
89 {
90 free(head);
91 }