blob: aabad98404198781ef1eca5d7ef7c7d90e6f4348 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* ttfread.c
* read data element form ttf file
* swap byte order carefully for MSBFirst
* presume that int is 32 bits
*/
#include <stdio.h>
#if defined(__GNUC__) && defined(_IBMR2)
/* Workaround for missing typedef in gcc (egcs-2.90.27 980315 (egcs-1.0.2 release)) */
typedef long blkcnt_t; /* number of blocks in the file */
#endif
#include "ttf.h"
#include "ttfutil.h"
/* $Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */
#ifndef lint
static char vcid[] = "$Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $";
#endif /* lint */
BYTE ttfGetBYTE(FILE *fp)
{
int cc;
if ((cc = fgetc(fp)) == EOF)
{
/*if (feof(fp) != 0)
ttfError("Unexpected EOF \n");
else
ttfError("Error Getting BYTE\n");*/
}
return (BYTE) cc;
}
short ttfGetLSB16(FILE *fp)
{
int cc;
cc = ttfGetBYTE(fp);
cc |= ttfGetBYTE(fp) <<8;
return cc;
}
int ttfGetLSB32(FILE *fp)
{
int cc;
cc = ttfGetBYTE(fp);
cc |= ttfGetBYTE(fp) << 8;
cc |= ttfGetBYTE(fp) << 16;
cc |= ttfGetBYTE(fp) << 24;
return cc;
}
CHAR ttfGetCHAR(FILE *fp)
{
int cc;
if ((cc = fgetc(fp)) == EOF)
{
if (feof(fp) != 0)
ttfError("Unexpected EOF \n");
else
ttfError("Error Getting CHAR\n");
}
return (CHAR) cc;
}
USHORT ttfGetUSHORT(FILE *fp)
{
int cc;
cc = ttfGetBYTE(fp) << 8;
cc |= ttfGetBYTE(fp);
return (USHORT) cc;
}
USHORT ttfGetSHORT(FILE *fp)
{
int cc;
cc = ttfGetBYTE(fp) << 8;
cc |= ttfGetBYTE(fp);
return (SHORT) cc;
}
ULONG ttfGetULONG(FILE *fp)
{
int cc;
cc = ttfGetBYTE(fp) << 24;
cc |= ttfGetBYTE(fp) << 16;
cc |= ttfGetBYTE(fp) << 8;
cc |= ttfGetBYTE(fp);
return (ULONG) cc;
}
LONG ttfGetLONG(FILE *fp)
{
int cc;
cc = ttfGetBYTE(fp) << 24;
cc |= ttfGetBYTE(fp) << 16;
cc |= ttfGetBYTE(fp) << 8;
cc |= ttfGetBYTE(fp);
return (LONG) cc;
}
Fixed ttfGetFixed(FILE *fp)
{
return (Fixed) ttfGetULONG(fp);
}
FUnit ttfGetFUnit(FILE *fp)
{
return (FUnit) ttfGetUSHORT(fp);
}
FWord ttfGetFWord(FILE *fp)
{
return (FWord) ttfGetSHORT(fp);
}
uFWord ttfGetuFWord(FILE *fp)
{
return (uFWord) ttfGetUSHORT(fp);
}
F2Dot14 ttfGetF2Dot14(FILE *fp)
{
return (F2Dot14) ttfGetUSHORT(fp);
}
|