1 /***************************************************************************/
2 /* */
3 /* fttypes.h */
4 /* */
5 /* FreeType simple types definitions (specification only). */
6 /* */
7 /* Copyright 1996-2001 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
19 #ifndef __FTTYPES_H__
20 #define __FTTYPES_H__
23 #include <ft2build.h>
24 #include FT_SYSTEM_H
25 #include FT_IMAGE_H
27 #include <stddef.h>
30 FT_BEGIN_HEADER
33 /*************************************************************************/
34 /* */
35 /* <Section> */
36 /* basic_types */
37 /* */
38 /* <Title> */
39 /* Basic Types */
40 /* */
41 /* <Abstract> */
42 /* The basic data types defined by the library. */
43 /* */
44 /* <Description> */
45 /* This section contains the basic data types defined by FreeType 2, */
46 /* ranging from simple scalar types to font specific ones. */
47 /* */
48 /* <Order> */
49 /* FT_Byte */
50 /* FT_Char */
51 /* FT_Int */
52 /* FT_UInt */
53 /* FT_Short */
54 /* FT_UShort */
55 /* FT_Long */
56 /* FT_ULong */
57 /* FT_Bool */
58 /* FT_Offset */
59 /* FT_PtrDist */
60 /* FT_Error */
61 /* FT_Fixed */
62 /* FT_Pointer */
63 /* FT_Pos */
64 /* FT_Vector */
65 /* FT_BBox */
66 /* FT_Matrix */
67 /* */
68 /* FT_Generic */
69 /* FT_Generic_Finalizer */
70 /* */
71 /* FT_Bitmap */
72 /* FT_Pixel_Mode */
73 /* FT_Palette_Mode */
74 /* FT_Glyph_Format */
75 /* FT_IMAGE_TAG */
76 /* FT_Glyph_Format */
77 /* */
78 /*************************************************************************/
81 /*************************************************************************/
82 /* */
83 /* <Type> */
84 /* FT_Bool */
85 /* */
86 /* <Description> */
87 /* A typedef of unsigned char, used for simple booleans. */
88 /* */
89 typedef unsigned char FT_Bool;
92 /*************************************************************************/
93 /* */
94 /* <Type> */
95 /* FT_FWord */
96 /* */
97 /* <Description> */
98 /* A signed 16-bit integer used to store a distance in original font */
99 /* units. */
100 /* */
101 typedef signed short FT_FWord; /* distance in FUnits */
104 /*************************************************************************/
105 /* */
106 /* <Type> */
107 /* FT_UFWord */
108 /* */
109 /* <Description> */
110 /* An unsigned 16-bit integer used to store a distance in original */
111 /* font units. */
112 /* */
113 typedef unsigned short FT_UFWord; /* unsigned distance */
116 /*************************************************************************/
117 /* */
118 /* <Type> */
119 /* FT_Char */
120 /* */
121 /* <Description> */
122 /* A simple typedef for the _signed_ char type. */
123 /* */
124 typedef signed char FT_Char;
127 /*************************************************************************/
128 /* */
129 /* <Type> */
130 /* FT_Byte */
131 /* */
132 /* <Description> */
133 /* A simple typedef for the _unsigned_ char type. */
134 /* */
135 typedef unsigned char FT_Byte;
138 /*************************************************************************/
139 /* */
140 /* <Type> */
141 /* FT_String */
142 /* */
143 /* <Description> */
144 /* A simple typedef for the char type, usually used for strings. */
145 /* */
146 typedef char FT_String;
149 /*************************************************************************/
150 /* */
151 /* <Type> */
152 /* FT_Short */
153 /* */
154 /* <Description> */
155 /* A typedef for signed short. */
156 /* */
157 typedef signed short FT_Short;
160 /*************************************************************************/
161 /* */
162 /* <Type> */
163 /* FT_UShort */
164 /* */
165 /* <Description> */
166 /* A typedef for unsigned short. */
167 /* */
168 typedef unsigned short FT_UShort;
171 /*************************************************************************/
172 /* */
173 /* <Type> */
174 /* FT_Int */
175 /* */
176 /* <Description> */
177 /* A typedef for the int type. */
178 /* */
179 typedef int FT_Int;
182 /*************************************************************************/
183 /* */
184 /* <Type> */
185 /* FT_UInt */
186 /* */
187 /* <Description> */
188 /* A typedef for the unsigned int type. */
189 /* */
190 typedef unsigned int FT_UInt;
193 /*************************************************************************/
194 /* */
195 /* <Type> */
196 /* FT_Long */
197 /* */
198 /* <Description> */
199 /* A typedef for signed long. */
200 /* */
201 typedef signed long FT_Long;
204 /*************************************************************************/
205 /* */
206 /* <Type> */
207 /* FT_ULong */
208 /* */
209 /* <Description> */
210 /* A typedef for unsigned long. */
211 /* */
212 typedef unsigned long FT_ULong;
215 /*************************************************************************/
216 /* */
217 /* <Type> */
218 /* FT_F2Dot14 */
219 /* */
220 /* <Description> */
221 /* A signed 2.14 fixed float type used for unit vectors. */
222 /* */
223 typedef signed short FT_F2Dot14;
226 /*************************************************************************/
227 /* */
228 /* <Type> */
229 /* FT_F26Dot6 */
230 /* */
231 /* <Description> */
232 /* A signed 26.6 fixed float type used for vectorial pixel */
233 /* coordinates. */
234 /* */
235 typedef signed long FT_F26Dot6;
238 /*************************************************************************/
239 /* */
240 /* <Type> */
241 /* FT_Fixed */
242 /* */
243 /* <Description> */
244 /* This type is used to store 16.16 fixed float values, like scales */
245 /* or matrix coefficients. */
246 /* */
247 typedef signed long FT_Fixed;
250 /*************************************************************************/
251 /* */
252 /* <Type> */
253 /* FT_Error */
254 /* */
255 /* <Description> */
256 /* The FreeType error code type. A value of 0 is always interpreted */
257 /* as a successful operation. */
258 /* */
259 typedef int FT_Error;
262 /*************************************************************************/
263 /* */
264 /* <Type> */
265 /* FT_Pointer */
266 /* */
267 /* <Description> */
268 /* A simple typedef for a typeless pointer. */
269 /* */
270 typedef void* FT_Pointer;
273 /*************************************************************************/
274 /* */
275 /* <Type> */
276 /* FT_Offset */
277 /* */
278 /* <Description> */
279 /* This is equivalent to the ANSI C `size_t' type, i.e. the largest */
280 /* _unsigned_ integer type used to express a file size or position, */
281 /* or a memory block size. */
282 /* */
283 typedef size_t FT_Offset;
286 /*************************************************************************/
287 /* */
288 /* <Type> */
289 /* FT_PtrDist */
290 /* */
291 /* <Description> */
292 /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e. the */
293 /* largest _signed_ integer type used to express the distance */
294 /* between two pointers. */
295 /* */
296 typedef size_t FT_PtrDist;
299 /*************************************************************************/
300 /* */
301 /* <Struct> */
302 /* FT_UnitVector */
303 /* */
304 /* <Description> */
305 /* A simple structure used to store a 2D vector unit vector. Uses */
306 /* FT_F2Dot14 types. */
307 /* */
308 /* <Fields> */
309 /* x :: Horizontal coordinate. */
310 /* */
311 /* y :: Vertical coordinate. */
312 /* */
313 typedef struct FT_UnitVector_
314 {
315 FT_F2Dot14 x;
316 FT_F2Dot14 y;
318 } FT_UnitVector;
321 /*************************************************************************/
322 /* */
323 /* <Struct> */
324 /* FT_Matrix */
325 /* */
326 /* <Description> */
327 /* A simple structure used to store a 2x2 matrix. Coefficients are */
328 /* in 16.16 fixed float format. The computation performed is: */
329 /* */
330 /* { */
331 /* x' = x*xx + y*xy */
332 /* y' = x*yx + y*yy */
333 /* } */
334 /* */
335 /* <Fields> */
336 /* xx :: Matrix coefficient. */
337 /* */
338 /* xy :: Matrix coefficient. */
339 /* */
340 /* yx :: Matrix coefficient. */
341 /* */
342 /* yy :: Matrix coefficient. */
343 /* */
344 typedef struct FT_Matrix_
345 {
346 FT_Fixed xx, xy;
347 FT_Fixed yx, yy;
349 } FT_Matrix;
352 /*************************************************************************/
353 /* */
354 /* <FuncType> */
355 /* FT_Generic_Finalizer */
356 /* */
357 /* <Description> */
358 /* Describes a function used to destroy the `client' data of any */
359 /* FreeType object. See the description of the FT_Generic type for */
360 /* details of usage. */
361 /* */
362 /* <Input> */
363 /* The address of the FreeType object which is under finalization. */
364 /* Its client data is accessed through its `generic' field. */
365 /* */
366 typedef void (*FT_Generic_Finalizer)(void* object);
369 /*************************************************************************/
370 /* */
371 /* <Struct> */
372 /* FT_Generic */
373 /* */
374 /* <Description> */
375 /* Client applications often need to associate their own data to a */
376 /* variety of FreeType core objects. For example, a text layout API */
377 /* might want to associate a glyph cache to a given size object. */
378 /* */
379 /* Most FreeType object contains a `generic' field, of type */
380 /* FT_Generic, which usage is left to client applications and font */
381 /* servers. */
382 /* */
383 /* It can be used to store a pointer to client-specific data, as well */
384 /* as the address of a `finalizer' function, which will be called by */
385 /* FreeType when the object is destroyed (for example, the previous */
386 /* client example would put the address of the glyph cache destructor */
387 /* in the `finalizer' field). */
388 /* */
389 /* <Fields> */
390 /* data :: A typeless pointer to any client-specified data. This */
391 /* field is completely ignored by the FreeType library. */
392 /* */
393 /* finalizer :: A pointer to a `generic finalizer' function, which */
394 /* will be called when the object is destroyed. If this */
395 /* field is set to NULL, no code will be called. */
396 /* */
397 typedef struct FT_Generic_
398 {
399 void* data;
400 FT_Generic_Finalizer finalizer;
402 } FT_Generic;
405 /*************************************************************************/
406 /* */
407 /* <Macro> */
408 /* FT_MAKE_TAG */
409 /* */
410 /* <Description> */
411 /* This macro converts four letter tags which are used to label */
412 /* TrueType tables into an unsigned long to be used within FreeType. */
413 /* */
414 #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
415 ( ( (FT_ULong)_x1 << 24 ) | \
416 ( (FT_ULong)_x2 << 16 ) | \
417 ( (FT_ULong)_x3 << 8 ) | \
418 (FT_ULong)_x4 )
421 /*************************************************************************/
422 /*************************************************************************/
423 /* */
424 /* L I S T M A N A G E M E N T */
425 /* */
426 /*************************************************************************/
427 /*************************************************************************/
430 /*************************************************************************/
431 /* */
432 /* <Section> */
433 /* list_processing */
434 /* */
435 /*************************************************************************/
438 /*************************************************************************/
439 /* */
440 /* <Type> */
441 /* FT_ListNode */
442 /* */
443 /* <Description> */
444 /* Many elements and objects in FreeType are listed through a */
445 /* FT_List record (see FT_ListRec). As its name suggests, a */
446 /* FT_ListNode is a handle to a single list element. */
447 /* */
448 typedef struct FT_ListNodeRec_* FT_ListNode;
451 /*************************************************************************/
452 /* */
453 /* <Type> */
454 /* FT_List */
455 /* */
456 /* <Description> */
457 /* A handle to a list record (see FT_ListRec). */
458 /* */
459 typedef struct FT_ListRec_* FT_List;
462 /*************************************************************************/
463 /* */
464 /* <Struct> */
465 /* FT_ListNodeRec */
466 /* */
467 /* <Description> */
468 /* A structure used to hold a single list element. */
469 /* */
470 /* <Fields> */
471 /* prev :: The previous element in the list. NULL if first. */
472 /* */
473 /* next :: The next element in the list. NULL if last. */
474 /* */
475 /* data :: A typeless pointer to the listed object. */
476 /* */
477 typedef struct FT_ListNodeRec_
478 {
479 FT_ListNode prev;
480 FT_ListNode next;
481 void* data;
483 } FT_ListNodeRec;
486 /*************************************************************************/
487 /* */
488 /* <Struct> */
489 /* FT_ListRec */
490 /* */
491 /* <Description> */
492 /* A structure used to hold a simple doubly-linked list. These are */
493 /* used in many parts of FreeType. */
494 /* */
495 /* <Fields> */
496 /* head :: The head (first element) of doubly-linked list. */
497 /* */
498 /* tail :: The tail (last element) of doubly-linked list. */
499 /* */
500 typedef struct FT_ListRec_
501 {
502 FT_ListNode head;
503 FT_ListNode tail;
505 } FT_ListRec;
508 /* */
510 #define FT_IS_EMPTY( list ) ( (list).head == 0 )
512 /* return base error code (without module-specific prefix) */
513 #define FT_ERROR_BASE( x ) ( (x) & 0xFF )
515 /* return module error code */
516 #define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
518 #define FT_BOOL( x ) ( (FT_Bool)( x ) )
520 FT_END_HEADER
522 #endif /* __FTTYPES_H__ */
525 /* END */