Debian Codegraph @

texk/ttfdump/libttf/vhea.c

raw
1 /* vhea.c -- Vertical Header Table
2 * Copyright (C) 1997 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: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
14
15 static void ttfLoadVHEA(FILE *fp,VHEAPtr vhea,ULONG offset);
16
17 void ttfInitVHEA(TTFontPtr font)
18 {
19 ULONG tag = FT_MAKE_TAG ('v', 'h', 'e', 'a');
20 TableDirPtr ptd;
21
22 if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
23 {
24 font->vhea = XCALLOC1 (VHEA);
25 ttfLoadVHEA(font->fp,font->vhea,ptd->offset);
26 }
27 }
28
29 static void ttfLoadVHEA (FILE *fp,VHEAPtr vhea,ULONG offset)
30 {
31 int i;
32
33 xfseek(fp, offset, SEEK_SET, "ttfLoadVHEA");
34
35 vhea->version = ttfGetFixed(fp);
36 vhea->ascent = ttfGetSHORT(fp);
37 vhea->descent = ttfGetSHORT(fp);
38 vhea->lineGap = ttfGetSHORT(fp);
39 vhea->advanceHeightMax = ttfGetSHORT(fp);
40 vhea->minTopSideBearing = ttfGetSHORT(fp);
41 vhea->minBottomSideBearing = ttfGetSHORT(fp);
42 vhea->yMaxExtent = ttfGetSHORT(fp);
43 vhea->caretSlopeRise = ttfGetSHORT(fp);
44 vhea->caretSlopeRun = ttfGetSHORT(fp);
45 vhea->caretOffset = ttfGetSHORT(fp);
46 for(i=0;i<4;i++)
47 (vhea->reserved)[i] = ttfGetSHORT(fp);
48 vhea->metricDataFormat = ttfGetSHORT(fp);
49 vhea->numOfLongVerMetrics = ttfGetUSHORT(fp);
50 }
51
52 void ttfPrintVHEA(FILE *fp,VHEAPtr vhea)
53 {
54 int i,b[2];
55
56 fprintf(fp,"'VHEA' - Vertical Header Table\n");
57 fprintf(fp,"------------------------------\n");
58
59 FixedSplit(vhea->version,b);
60
61 fprintf(fp,"\t version:\t %d.%d\n",b[1],b[0]);
62 fprintf(fp,"\t ascent:\t %d\n",vhea->ascent);
63 fprintf(fp,"\t descent:\t %d\n",vhea->descent);
64 fprintf(fp,"\t lineGap:\t %d\n",vhea->lineGap);
65 fprintf(fp,"\t advanceHeightMax: %d\n",vhea->advanceHeightMax);
66 fprintf(fp,"\t minTopSideBearing: %d\n",vhea->minTopSideBearing);
67 fprintf(fp,"\t minBottomBearing: %d\n",vhea->minBottomSideBearing);
68 fprintf(fp,"\t yMaxExtent:\t %d\n",vhea->yMaxExtent);
69 fprintf(fp,"\t caretSlopeRise: %d\n", vhea->caretSlopeRise);
70 fprintf(fp,"\t caretSlopeRun: %d\n", vhea->caretSlopeRun);
71 fprintf(fp,"\t caretOffset:\t %d\n", vhea->caretOffset);
72 for(i=0;i<4;i++)
73 fprintf(fp,"\t reserved %d:\t %d\n",i,(vhea->reserved)[i]);
74 fprintf(fp,"\t metricDataFormat:\t %d\n", vhea->metricDataFormat);
75 fprintf(fp,"\t numOfLongVerMetrics: %d\n",vhea->numOfLongVerMetrics);
76 }
77
78 void ttfFreeVHEA(VHEAPtr vhea)
79 {
80 if (vhea != NULL)
81 {
82 free(vhea);
83 }
84 }