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 :: 351 * Horizontal coordinate. 352 * 353 * y :: 354 * Vertical coordinate. 355 */ 356 typedef struct FT_UnitVector_ 357 { 358 FT_F2Dot14 x; 359 FT_F2Dot14 y; 360 361 } FT_UnitVector; 362 363 364 /************************************************************************** 365 * 366 * @struct: 367 * FT_Matrix 368 * 369 * @description: 370 * A simple structure used to store a 2x2 matrix. Coefficients are 371 * in 16.16 fixed-point format. The computation performed is: 372 * 373 * { 374 * x' = x*xx + y*xy 375 * y' = x*yx + y*yy 376 * } 377 * 378 * @fields: 379 * xx :: 380 * Matrix coefficient. 381 * 382 * xy :: 383 * Matrix coefficient. 384 * 385 * yx :: 386 * Matrix coefficient. 387 * 388 * yy :: 389 * Matrix coefficient. 390 */ 391 typedef struct FT_Matrix_ 392 { 393 FT_Fixed xx, xy; 394 FT_Fixed yx, yy; 395 396 } FT_Matrix; 397 398 399 /************************************************************************** 400 * 401 * @struct: 402 * FT_Data 403 * 404 * @description: 405 * Read-only binary data represented as a pointer and a length. 406 * 407 * @fields: 408 * pointer :: 409 * The data. 410 * 411 * length :: 412 * The length of the data in bytes. 413 */ 414 typedef struct FT_Data_ 415 { 416 const FT_Byte* pointer; 417 FT_Int length; 418 419 } FT_Data; 420 421 422 /************************************************************************** 423 * 424 * @functype: 425 * FT_Generic_Finalizer 426 * 427 * @description: 428 * Describe a function used to destroy the `client' data of any 429 * FreeType object. See the description of the @FT_Generic type for 430 * details of usage. 431 * 432 * @input: 433 * The address of the FreeType object that is under finalization. 434 * Its client data is accessed through its `generic' field. 435 */ 436 typedef void (*FT_Generic_Finalizer)( void* object ); 437 438 439 /************************************************************************** 440 * 441 * @struct: 442 * FT_Generic 443 * 444 * @description: 445 * Client applications often need to associate their own data to a 446 * variety of FreeType core objects. For example, a text layout API 447 * might want to associate a glyph cache to a given size object. 448 * 449 * Some FreeType object contains a `generic' field, of type 450 * FT_Generic, which usage is left to client applications and font 451 * servers. 452 * 453 * It can be used to store a pointer to client-specific data, as well 454 * as the address of a `finalizer' function, which will be called by 455 * FreeType when the object is destroyed (for example, the previous 456 * client example would put the address of the glyph cache destructor 457 * in the `finalizer' field). 458 * 459 * @fields: 460 * data :: 461 * A typeless pointer to any client-specified data. This 462 * field is completely ignored by the FreeType library. 463 * 464 * finalizer :: 465 * A pointer to a `generic finalizer' function, which 466 * will be called when the object is destroyed. If this 467 * field is set to NULL, no code will be called. 468 */ 469 typedef struct FT_Generic_ 470 { 471 void* data; 472 FT_Generic_Finalizer finalizer; 473 474 } FT_Generic; 475 476 477 /************************************************************************** 478 * 479 * @macro: 480 * FT_MAKE_TAG 481 * 482 * @description: 483 * This macro converts four-letter tags that are used to label 484 * TrueType tables into an unsigned long, to be used within FreeType. 485 * 486 * @note: 487 * The produced values *must* be 32-bit integers. Don't redefine 488 * this macro. 489 */ 490 #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ 491 (FT_Tag) \ 492 ( ( (FT_ULong)_x1 << 24 ) | \ 493 ( (FT_ULong)_x2 << 16 ) | \ 494 ( (FT_ULong)_x3 << 8 ) | \ 495 (FT_ULong)_x4 ) 496 497 498 /*************************************************************************/ 499 /*************************************************************************/ 500 /* */ 501 /* L I S T M A N A G E M E N T */ 502 /* */ 503 /*************************************************************************/ 504 /*************************************************************************/ 505 506 507 /************************************************************************** 508 * 509 * @section: 510 * list_processing 511 * 512 */ 513 514 515 /************************************************************************** 516 * 517 * @type: 518 * FT_ListNode 519 * 520 * @description: 521 * Many elements and objects in FreeType are listed through an 522 * @FT_List record (see @FT_ListRec). As its name suggests, an 523 * FT_ListNode is a handle to a single list element. 524 */ 525 typedef struct FT_ListNodeRec_* FT_ListNode; 526 527 528 /************************************************************************** 529 * 530 * @type: 531 * FT_List 532 * 533 * @description: 534 * A handle to a list record (see @FT_ListRec). 535 */ 536 typedef struct FT_ListRec_* FT_List; 537 538 539 /************************************************************************** 540 * 541 * @struct: 542 * FT_ListNodeRec 543 * 544 * @description: 545 * A structure used to hold a single list element. 546 * 547 * @fields: 548 * prev :: 549 * The previous element in the list. NULL if first. 550 * 551 * next :: 552 * The next element in the list. NULL if last. 553 * 554 * data :: 555 * A typeless pointer to the listed object. 556 */ 557 typedef struct FT_ListNodeRec_ 558 { 559 FT_ListNode prev; 560 FT_ListNode next; 561 void* data; 562 563 } FT_ListNodeRec; 564 565 566 /************************************************************************** 567 * 568 * @struct: 569 * FT_ListRec 570 * 571 * @description: 572 * A structure used to hold a simple doubly-linked list. These are 573 * used in many parts of FreeType. 574 * 575 * @fields: 576 * head :: 577 * The head (first element) of doubly-linked list. 578 * 579 * tail :: 580 * The tail (last element) of doubly-linked list. 581 */ 582 typedef struct FT_ListRec_ 583 { 584 FT_ListNode head; 585 FT_ListNode tail; 586 587 } FT_ListRec; 588 589 /* */ 590 591 592 #define FT_IS_EMPTY( list ) ( (list).head == 0 ) 593 #define FT_BOOL( x ) ( (FT_Bool)( x ) ) 594 595 /* concatenate C tokens */ 596 #define FT_ERR_XCAT( x, y ) x ## y 597 #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) 598 599 /* see `ftmoderr.h' for descriptions of the following macros */ 600 601 #define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) 602 603 #define FT_ERROR_BASE( x ) ( (x) & 0xFF ) 604 #define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) 605 606 #define FT_ERR_EQ( x, e ) \ 607 ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) 608 #define FT_ERR_NEQ( x, e ) \ 609 ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) 610 611 612 FT_END_HEADER 613 614 #endif /* FTTYPES_H_ */ 615 616 617 /* END */ 618