Debian Codegraph @

texk/ttfdump/libttf/cvt.c

raw
1 /* cvt.c -- Control Value 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: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
14
15 static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT lenght,ULONG offset);
16
17 void ttfInitCVT(TTFontPtr font)
18 {
19 ULONG tag = FT_MAKE_TAG ('c', 'v', 't', ' ');
20 TableDirPtr ptd;
21
22 if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
23 {
24 font->cvtLength = ptd->length / sizeof(FWord);
25 font->cvt = XCALLOC (font->cvtLength, FWord);
26 ttfLoadCVT(font->fp,font->cvt,font->cvtLength,ptd->offset);
27 }
28 }
29
30 static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT length,ULONG offset)
31 {
32 xfseek(fp, offset, SEEK_SET, "ttfLoadCVT");
33
34 ttfReadFWord (cvt, length, fp);
35 }
36
37 void ttfPrintCVT(FILE *fp, FWord *cvt, USHORT cvtLength)
38 {
39 USHORT i;
40
41 fprintf(fp,"'cvt ' Table - Control Value Table\n");
42 fprintf(fp,"----------------------------------\n");
43 fprintf(fp,"Size = %d bytes, %d entries\n", (int) (cvtLength*sizeof(FWord)),
44 cvtLength);
45
46 for (i=0;i<cvtLength;i++)
47 {
48 fprintf(fp,"\t %4d. \t %d\n",i,cvt[i]);
49 }
50 fprintf(fp,"\n");
51 }
52
53 void ttfFreeCVT(FWord *cvt)
54 {
55 if (cvt != NULL)
56 free(cvt);
57 }