Debian Codegraph @

texk/ttfdump/libttf/gasp.c

raw
1 /* gasp.c -- Grid-fitting And Scan-conversion Procedure
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: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
14
15 static void ttfLoadGASP(FILE *fp,GASPPtr gasp,ULONG offset);
16
17 void ttfInitGASP(TTFontPtr font)
18 {
19 ULONG tag = FT_MAKE_TAG ('g', 'a', 's', 'p');
20 TableDirPtr ptd;
21
22 if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
23 {
24 font->gasp = XCALLOC1 (GASP);
25 ttfLoadGASP(font->fp,font->gasp,ptd->offset);
26 }
27 }
28
29 static void ttfLoadGASP (FILE *fp,GASPPtr gasp,ULONG offset)
30 {
31 int i;
32
33 xfseek(fp, offset, SEEK_SET, "ttfLoadGASP");
34
35 gasp->version = ttfGetUSHORT(fp);
36 gasp->numRanges = ttfGetUSHORT(fp);
37
38 gasp->gaspRange = XCALLOC (gasp->numRanges, GASPRANGE);
39
40 for (i=0;i<gasp->numRanges;i++)
41 {
42 gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp);
43 gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp);
44 }
45 }
46
47 void ttfPrintGASP(FILE *fp,GASPPtr gasp)
48 {
49 int i;
50
51 fprintf(fp,"'gasp' Table - Grid-fitting And Scan-conversion Procedure\n");
52 fprintf(fp,"---------------------------------------------------------\n");
53
54 fprintf(fp,"'gasp' version:\t %d\n",gasp->version);
55 fprintf(fp,"numRanges: \t %d\n\n",gasp->numRanges);
56
57 for (i=0;i<gasp->numRanges;i++)
58 {
59 fprintf(fp,"\t gasp Range %d\n",i);
60 fprintf(fp,"\t rangeMaxPPEM:\t %d\n",
61 gasp->gaspRange[i].rangeMaxPPEM);
62 fprintf(fp,"\t rangeGaspBehavior:\t 0x%04x\n\n",
63 gasp->gaspRange[i].rangeGaspBehavior);
64 }
65 fprintf(fp,"\n");
66 }
67
68 void ttfFreeGASP(GASPPtr gasp)
69 {
70 if (gasp != NULL)
71 {
72 free(gasp->gaspRange);
73 free(gasp);
74 }
75 }