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