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 /***************************************************************************/ 17 18 19 #ifndef __FTTYPES_H__ 20 #define __FTTYPES_H__ 21 22 23 #include <ft2build.h> 24 #include FT_CONFIG_CONFIG_H 25 #include FT_SYSTEM_H 26 #include FT_IMAGE_H 27 28 #include <stddef.h> 29 30 31 FT_BEGIN_HEADER 32 33 34 /*************************************************************************/ 35 /* */ 36 /* <Section> */ 37 /* basic_types */ 38 /* */ 39 /* <Title> */ 40 /* Basic Data Types */ 41 /* */ 42 /* <Abstract> */ 43 /* The basic data types defined by the library. */ 44 /* */ 45 /* <Description> */ 46 /* This section contains the basic data types defined by FreeType 2, */ 47 /* ranging from simple scalar types to bitmap descriptors. More */ 48 /* font-specific structures are defined in a different section. */ 49 /* */ 50 /* <Order> */ 51 /* FT_Byte */ 52 /* FT_Char */ 53 /* FT_Int */ 54 /* FT_UInt */ 55 /* FT_Short */ 56 /* FT_UShort */ 57 /* FT_Long */ 58 /* FT_ULong */ 59 /* FT_Bool */ 60 /* FT_Offset */ 61 /* FT_PtrDist */ 62 /* FT_String */ 63 /* FT_Error */ 64 /* FT_Fixed */ 65 /* FT_Pointer */ 66 /* FT_Pos */ 67 /* FT_Vector */ 68 /* FT_BBox */ 69 /* FT_Matrix */ 70 /* FT_FWord */ 71 /* FT_UFWord */ 72 /* FT_F2Dot14 */ 73 /* FT_UnitVector */ 74 /* FT_F26Dot6 */ 75 /* */ 76 /* */ 77 /* FT_Generic */ 78 /* FT_Generic_Finalizer */ 79 /* */ 80 /* FT_Bitmap */ 81 /* FT_Pixel_Mode */ 82 /* FT_Palette_Mode */ 83 /* FT_Glyph_Format */ 84 /* FT_IMAGE_TAG */ 85 /* */ 86 /*************************************************************************/ 87 88 89 /*************************************************************************/ 90 /* */ 91 /* <Type> */ 92 /* FT_Bool */ 93 /* */ 94 /* <Description> */ 95 /* A typedef of unsigned char, used for simple booleans. */ 96 /* */ 97 typedef unsigned char FT_Bool; 98 99 100 /*************************************************************************/ 101 /* */ 102 /* <Type> */ 103 /* FT_FWord */ 104 /* */ 105 /* <Description> */ 106 /* A signed 16-bit integer used to store a distance in original font */ 107 /* units. */ 108 /* */ 109 typedef signed short FT_FWord; /* distance in FUnits */ 110 111 112 /*************************************************************************/ 113 /* */ 114 /* <Type> */ 115 /* FT_UFWord */ 116 /* */ 117 /* <Description> */ 118 /* An unsigned 16-bit integer used to store a distance in original */ 119 /* font units. */ 120 /* */ 121 typedef unsigned short FT_UFWord; /* unsigned distance */ 122 123 124 /*************************************************************************/ 125 /* */ 126 /* <Type> */ 127 /* FT_Char */ 128 /* */ 129 /* <Description> */ 130 /* A simple typedef for the _signed_ char type. */ 131 /* */ 132 typedef signed char FT_Char; 133 134 135 /*************************************************************************/ 136 /* */ 137 /* <Type> */ 138 /* FT_Byte */ 139 /* */ 140 /* <Description> */ 141 /* A simple typedef for the _unsigned_ char type. */ 142 /* */ 143 typedef unsigned char FT_Byte; 144 145 146 /*************************************************************************/ 147 /* */ 148 /* <Type> */ 149 /* FT_String */ 150 /* */ 151 /* <Description> */ 152 /* A simple typedef for the char type, usually used for strings. */ 153 /* */ 154 typedef char FT_String; 155 156 157 /*************************************************************************/ 158 /* */ 159 /* <Type> */ 160 /* FT_Short */ 161 /* */ 162 /* <Description> */ 163 /* A typedef for signed short. */ 164 /* */ 165 typedef signed short FT_Short; 166 167 168 /*************************************************************************/ 169 /* */ 170 /* <Type> */ 171 /* FT_UShort */ 172 /* */ 173 /* <Description> */ 174 /* A typedef for unsigned short. */ 175 /* */ 176 typedef unsigned short FT_UShort; 177 178 179 /*************************************************************************/ 180 /* */ 181 /* <Type> */ 182 /* FT_Int */ 183 /* */ 184 /* <Description> */ 185 /* A typedef for the int type. */ 186 /* */ 187 typedef int FT_Int; 188 189 190 /*************************************************************************/ 191 /* */ 192 /* <Type> */ 193 /* FT_UInt */ 194 /* */ 195 /* <Description> */ 196 /* A typedef for the unsigned int type. */ 197 /* */ 198 typedef unsigned int FT_UInt; 199 200 201 /*************************************************************************/ 202 /* */ 203 /* <Type> */ 204 /* FT_Long */ 205 /* */ 206 /* <Description> */ 207 /* A typedef for signed long. */ 208 /* */ 209 typedef signed long FT_Long; 210 211 212 /*************************************************************************/ 213 /* */ 214 /* <Type> */ 215 /* FT_ULong */ 216 /* */ 217 /* <Description> */ 218 /* A typedef for unsigned long. */ 219 /* */ 220 typedef unsigned long FT_ULong; 221 222 223 /*************************************************************************/ 224 /* */ 225 /* <Type> */ 226 /* FT_F2Dot14 */ 227 /* */ 228 /* <Description> */ 229 /* A signed 2.14 fixed float type used for unit vectors. */ 230 /* */ 231 typedef signed short FT_F2Dot14; 232 233 234 /*************************************************************************/ 235 /* */ 236 /* <Type> */ 237 /* FT_F26Dot6 */ 238 /* */ 239 /* <Description> */ 240 /* A signed 26.6 fixed float type used for vectorial pixel */ 241 /* coordinates. */ 242 /* */ 243 typedef signed long FT_F26Dot6; 244 245 246 /*************************************************************************/ 247 /* */ 248 /* <Type> */ 249 /* FT_Fixed */ 250 /* */ 251 /* <Description> */ 252 /* This type is used to store 16.16 fixed float values, like scales */ 253 /* or matrix coefficients. */ 254 /* */ 255 typedef signed long FT_Fixed; 256 257 258 /*************************************************************************/ 259 /* */ 260 /* <Type> */ 261 /* FT_Error */ 262 /* */ 263 /* <Description> */ 264 /* The FreeType error code type. A value of 0 is always interpreted */ 265 /* as a successful operation. */ 266 /* */ 267 typedef int FT_Error; 268 269 270 /*************************************************************************/ 271 /* */ 272 /* <Type> */ 273 /* FT_Pointer */ 274 /* */ 275 /* <Description> */ 276 /* A simple typedef for a typeless pointer. */ 277 /* */ 278 typedef void* FT_Pointer; 279 280 281 /*************************************************************************/ 282 /* */ 283 /* <Type> */ 284 /* FT_Offset */ 285 /* */ 286 /* <Description> */ 287 /* This is equivalent to the ANSI C `size_t' type, i.e. the largest */ 288 /* _unsigned_ integer type used to express a file size or position, */ 289 /* or a memory block size. */ 290 /* */ 291 typedef size_t FT_Offset; 292 293 294 /*************************************************************************/ 295 /* */ 296 /* <Type> */ 297 /* FT_PtrDist */ 298 /* */ 299 /* <Description> */ 300 /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e. the */ 301 /* largest _signed_ integer type used to express the distance */ 302 /* between two pointers. */ 303 /* */ 304 typedef size_t FT_PtrDist; 305 306 307 /*************************************************************************/ 308 /* */ 309 /* <Struct> */ 310 /* FT_UnitVector */ 311 /* */ 312 /* <Description> */ 313 /* A simple structure used to store a 2D vector unit vector. Uses */ 314 /* FT_F2Dot14 types. */ 315 /* */ 316 /* <Fields> */ 317 /* x :: Horizontal coordinate. */ 318 /* */ 319 /* y :: Vertical coordinate. */ 320 /* */ 321 typedef struct FT_UnitVector_ 322 { 323 FT_F2Dot14 x; 324 FT_F2Dot14 y; 325 326 } FT_UnitVector; 327 328 329 /*************************************************************************/ 330 /* */ 331 /* <Struct> */ 332 /* FT_Matrix */ 333 /* */ 334 /* <Description> */ 335 /* A simple structure used to store a 2x2 matrix. Coefficients are */ 336 /* in 16.16 fixed float format. The computation performed is: */ 337 /* */ 338 /* { */ 339 /* x' = x*xx + y*xy */ 340 /* y' = x*yx + y*yy */ 341 /* } */ 342 /* */ 343 /* <Fields> */ 344 /* xx :: Matrix coefficient. */ 345 /* */ 346 /* xy :: Matrix coefficient. */ 347 /* */ 348 /* yx :: Matrix coefficient. */ 349 /* */ 350 /* yy :: Matrix coefficient. */ 351 /* */ 352 typedef struct FT_Matrix_ 353 { 354 FT_Fixed xx, xy; 355 FT_Fixed yx, yy; 356 357 } FT_Matrix; 358 359 360 /*************************************************************************/ 361 /* */ 362 /* <Struct> */ 363 /* FT_Data */ 364 /* */ 365 /* <Description> */ 366 /* Read-only binary data represented as a pointer and a length. */ 367 /* */ 368 /* <Fields> */ 369 /* pointer :: The data. */ 370 /* */ 371 /* length :: The length of the data in bytes. */ 372 /* */ 373 typedef struct FT_Data_ 374 { 375 const FT_Byte* pointer; 376 FT_Int length; 377 378 } FT_Data; 379 380 381 /*************************************************************************/ 382 /* */ 383 /* <FuncType> */ 384 /* FT_Generic_Finalizer */ 385 /* */ 386 /* <Description> */ 387 /* Describes a function used to destroy the `client' data of any */ 388 /* FreeType object. See the description of the FT_Generic type for */ 389 /* details of usage. */ 390 /* */ 391 /* <Input> */ 392 /* The address of the FreeType object which is under finalization. */ 393 /* Its client data is accessed through its `generic' field. */ 394 /* */ 395 typedef void (*FT_Generic_Finalizer)(void* object); 396 397 398 /*************************************************************************/ 399 /* */ 400 /* <Struct> */ 401 /* FT_Generic */ 402 /* */ 403 /* <Description> */ 404 /* Client applications often need to associate their own data to a */ 405 /* variety of FreeType core objects. For example, a text layout API */ 406 /* might want to associate a glyph cache to a given size object. */ 407 /* */ 408 /* Most FreeType object contains a `generic' field, of type */ 409 /* FT_Generic, which usage is left to client applications and font */ 410 /* servers. */ 411 /* */ 412 /* It can be used to store a pointer to client-specific data, as well */ 413 /* as the address of a `finalizer' function, which will be called by */ 414 /* FreeType when the object is destroyed (for example, the previous */ 415 /* client example would put the address of the glyph cache destructor */ 416 /* in the `finalizer' field). */ 417 /* */ 418 /* <Fields> */ 419 /* data :: A typeless pointer to any client-specified data. This */ 420 /* field is completely ignored by the FreeType library. */ 421 /* */ 422 /* finalizer :: A pointer to a `generic finalizer' function, which */ 423 /* will be called when the object is destroyed. If this */ 424 /* field is set to NULL, no code will be called. */ 425 /* */ 426 typedef struct FT_Generic_ 427 { 428 void* data; 429 FT_Generic_Finalizer finalizer; 430 431 } FT_Generic; 432 433 434 /*************************************************************************/ 435 /* */ 436 /* <Macro> */ 437 /* FT_MAKE_TAG */ 438 /* */ 439 /* <Description> */ 440 /* This macro converts four letter tags which are used to label */ 441 /* TrueType tables into an unsigned long to be used within FreeType. */ 442 /* */ 443 /* <Note> */ 444 /* The produced values *must* be 32bit integers. Don't redefine this */ 445 /* macro. */ 446 /* */ 447 #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ 448 ( ( (FT_ULong)_x1 << 24 ) | \ 449 ( (FT_ULong)_x2 << 16 ) | \ 450 ( (FT_ULong)_x3 << 8 ) | \ 451 (FT_ULong)_x4 ) 452 453 454 /*************************************************************************/ 455 /*************************************************************************/ 456 /* */ 457 /* L I S T M A N A G E M E N T */ 458 /* */ 459 /*************************************************************************/ 460 /*************************************************************************/ 461 462 463 /*************************************************************************/ 464 /* */ 465 /* <Section> */ 466 /* list_processing */ 467 /* */ 468 /*************************************************************************/ 469 470 471 /*************************************************************************/ 472 /* */ 473 /* <Type> */ 474 /* FT_ListNode */ 475 /* */ 476 /* <Description> */ 477 /* Many elements and objects in FreeType are listed through a */ 478 /* FT_List record (see FT_ListRec). As its name suggests, a */ 479 /* FT_ListNode is a handle to a single list element. */ 480 /* */ 481 typedef struct FT_ListNodeRec_* FT_ListNode; 482 483 484 /*************************************************************************/ 485 /* */ 486 /* <Type> */ 487 /* FT_List */ 488 /* */ 489 /* <Description> */ 490 /* A handle to a list record (see FT_ListRec). */ 491 /* */ 492 typedef struct FT_ListRec_* FT_List; 493 494 495 /*************************************************************************/ 496 /* */ 497 /* <Struct> */ 498 /* FT_ListNodeRec */ 499 /* */ 500 /* <Description> */ 501 /* A structure used to hold a single list element. */ 502 /* */ 503 /* <Fields> */ 504 /* prev :: The previous element in the list. NULL if first. */ 505 /* */ 506 /* next :: The next element in the list. NULL if last. */ 507 /* */ 508 /* data :: A typeless pointer to the listed object. */ 509 /* */ 510 typedef struct FT_ListNodeRec_ 511 { 512 FT_ListNode prev; 513 FT_ListNode next; 514 void* data; 515 516 } FT_ListNodeRec; 517 518 519 /*************************************************************************/ 520 /* */ 521 /* <Struct> */ 522 /* FT_ListRec */ 523 /* */ 524 /* <Description> */ 525 /* A structure used to hold a simple doubly-linked list. These are */ 526 /* used in many parts of FreeType. */ 527 /* */ 528 /* <Fields> */ 529 /* head :: The head (first element) of doubly-linked list. */ 530 /* */ 531 /* tail :: The tail (last element) of doubly-linked list. */ 532 /* */ 533 typedef struct FT_ListRec_ 534 { 535 FT_ListNode head; 536 FT_ListNode tail; 537 538 } FT_ListRec; 539 540 541 /* */ 542 543 #define FT_IS_EMPTY( list ) ( (list).head == 0 ) 544 545 /* return base error code (without module-specific prefix) */ 546 #define FT_ERROR_BASE( x ) ( (x) & 0xFF ) 547 548 /* return module error code */ 549 #define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) 550 551 #define FT_BOOL( x ) ( (FT_Bool)( x ) ) 552 553 FT_END_HEADER 554 555 #endif /* __FTTYPES_H__ */ 556 557 558 /* END */ 559