modules/freetype2/include/fttypes.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial