w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ttfread.c
Go to the documentation of this file.
1 /* ttfread.c
2  * read data element form ttf file
3  * swap byte order carefully for MSBFirst
4  * presume that int is 32 bits
5  */
6 #ifdef HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9 
10 #include <stdio.h>
11 
12 #if defined(__GNUC__) && defined(_IBMR2)
13 /* Workaround for missing typedef in gcc (egcs-2.90.27 980315 (egcs-1.0.2 release)) */
14 typedef long blkcnt_t; /* number of blocks in the file */
15 #endif
16 
17 #include "ttf.h"
18 #include "ttfutil.h"
19 
20 /* $Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */
21 
23 {
24  int cc;
25  if ((cc = fgetc(fp)) == EOF)
26  {
27  if (feof(fp) != 0)
28  ttfError("Unexpected EOF\n");
29  else
30  ttfError("Error Getting BYTE\n");
31  }
32  return (BYTE) cc;
33 }
34 
36 {
37  int cc;
38  if ((cc = fgetc(fp)) == EOF)
39  {
40  if (feof(fp) != 0)
41  ttfError("Unexpected EOF\n");
42  else
43  ttfError("Error Getting CHAR\n");
44  }
45  return (CHAR) cc;
46 }
47 
49 {
50  int cc;
51  cc = ttfGetBYTE(fp) << 8;
52  cc |= ttfGetBYTE(fp);
53 
54  return (USHORT) cc;
55 }
56 
58 {
59  int cc;
60  cc = ttfGetBYTE(fp) << 8;
61  cc |= ttfGetBYTE(fp);
62 
63  return (SHORT) cc;
64 }
65 
67 {
68  int cc;
69  cc = ttfGetBYTE(fp) << 24;
70  cc |= ttfGetBYTE(fp) << 16;
71  cc |= ttfGetBYTE(fp) << 8;
72  cc |= ttfGetBYTE(fp);
73 
74  return (ULONG) cc;
75 }
76 
78 {
79  int cc;
80  cc = ttfGetBYTE(fp) << 24;
81  cc |= ttfGetBYTE(fp) << 16;
82  cc |= ttfGetBYTE(fp) << 8;
83  cc |= ttfGetBYTE(fp);
84 
85  return (LONG) cc;
86 }
87 
89 {
90  return (Fixed) ttfGetULONG(fp);
91 }
92 
94 {
95  return (FUnit) ttfGetUSHORT(fp);
96 }
97 
99 {
100  return (FWord) ttfGetSHORT(fp);
101 }
102 
104 {
105  return (uFWord) ttfGetUSHORT(fp);
106 }
107 
109 {
110  return (F2Dot14) ttfGetUSHORT(fp);
111 }
112 
113 /* Read arrays. */
114 void ttfReadUSHORT(USHORT *array, size_t nelem, FILE *fp)
115 {
116  int i;
117  for (i = 0; i < nelem; i++)
118  array[i] = ttfGetUSHORT (fp);
119 }
120 
121 void ttfReadULONG(ULONG *array, size_t nelem, FILE *fp)
122 {
123  int i;
124  for (i = 0; i < nelem; i++)
125  array[i] = ttfGetULONG (fp);
126 }
127 
128 void ttfReadFWord(FWord *array, size_t nelem, FILE *fp)
129 {
130  int i;
131  for (i = 0; i < nelem; i++)
132  array[i] = ttfGetFWord (fp);
133 }
134 
135 /* Allocate and read arrays. */
136 BYTE *ttfMakeBYTE(size_t nelem, FILE *fp)
137 {
138  int i;
139  BYTE *array = XTALLOC (nelem, BYTE);
140  for (i = 0; i < nelem; i++)
141  array[i] = ttfGetBYTE (fp);
142  return array;
143 }
144 
145 USHORT *ttfMakeUSHORT(size_t nelem, FILE *fp)
146 {
147  int i;
148  USHORT *array = XTALLOC (nelem, USHORT);
149  for (i = 0; i < nelem; i++)
150  array[i] = ttfGetUSHORT (fp);
151  return array;
152 }
153 
154 SHORT *ttfMakeSHORT(size_t nelem, FILE *fp)
155 {
156  int i;
157  SHORT *array = XTALLOC (nelem, SHORT);
158  for (i = 0; i < nelem; i++)
159  array[i] = ttfGetSHORT (fp);
160  return array;
161 }
162 
163 ULONG *ttfMakeULONG(size_t nelem, FILE *fp)
164 {
165  int i;
166  ULONG *array = XTALLOC (nelem, ULONG);
167  for (i = 0; i < nelem; i++)
168  array[i] = ttfGetULONG (fp);
169  return array;
170 }
171 
172 LONG *ttfMakeLONG(size_t nelem, FILE *fp)
173 {
174  int i;
175  LONG *array = XTALLOC (nelem, LONG);
176  for (i = 0; i < nelem; i++)
177  array[i] = ttfGetLONG (fp);
178  return array;
179 }
180 
#define fgetc
Definition: xxstdio.h:26
unsigned short CHAR
Definition: hbf.c:169
TT_Int32 Fixed
Definition: tttypes.h:45
small capitals from c petite p scientific i
Definition: afcover.h:80
#define EOF
Definition: afmparse.c:59
#define XTALLOC(n, t)
Definition: writet1.c:32
signed short SHORT
Definition: sfnt.h:37
unsigned char BYTE
Definition: sfnt.h:34
short FWord
Definition: sfnt.h:41
unsigned short USHORT
Definition: sfnt.h:36
unsigned short uFWord
Definition: sfnt.h:42
USHORT FUnit
Definition: ttf.h:28
SHORT F2Dot14
Definition: ttf.h:31
long LONG
Definition: common.h:146
unsigned long ULONG
Definition: pdfgen.h:158
#define fp
#define FILE
Definition: t1stdio.h:34
#define feof(f)
Definition: t1stdio.h:109
uFWord ttfGetuFWord(FILE *fp)
Definition: ttfread.c:103
void ttfReadULONG(ULONG *array, size_t nelem, FILE *fp)
Definition: ttfread.c:121
LONG ttfGetLONG(FILE *fp)
Definition: ttfread.c:77
BYTE ttfGetBYTE(FILE *fp)
Definition: ttfread.c:22
CHAR ttfGetCHAR(FILE *fp)
Definition: ttfread.c:35
ULONG ttfGetULONG(FILE *fp)
Definition: ttfread.c:66
SHORT ttfGetSHORT(FILE *fp)
Definition: ttfread.c:57
ULONG * ttfMakeULONG(size_t nelem, FILE *fp)
Definition: ttfread.c:163
FWord ttfGetFWord(FILE *fp)
Definition: ttfread.c:98
BYTE * ttfMakeBYTE(size_t nelem, FILE *fp)
Definition: ttfread.c:136
USHORT ttfGetUSHORT(FILE *fp)
Definition: ttfread.c:48
Fixed ttfGetFixed(FILE *fp)
Definition: ttfread.c:88
void ttfReadFWord(FWord *array, size_t nelem, FILE *fp)
Definition: ttfread.c:128
USHORT * ttfMakeUSHORT(size_t nelem, FILE *fp)
Definition: ttfread.c:145
FUnit ttfGetFUnit(FILE *fp)
Definition: ttfread.c:93
LONG * ttfMakeLONG(size_t nelem, FILE *fp)
Definition: ttfread.c:172
F2Dot14 ttfGetF2Dot14(FILE *fp)
Definition: ttfread.c:108
SHORT * ttfMakeSHORT(size_t nelem, FILE *fp)
Definition: ttfread.c:154
void ttfReadUSHORT(USHORT *array, size_t nelem, FILE *fp)
Definition: ttfread.c:114
void ttfError(const char *msg)
Definition: ttfutil.c:32