1 /****************************************************************************
5 * FreeType simple types definitions (specification only).
7 * Copyright (C) 1996-2023 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
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.
24 #include FT_CONFIG_CONFIG_H
25 #include <freetype/ftsystem.h>
26 #include <freetype/ftimage.h>
34 /**************************************************************************
43 * The basic data types defined by the library.
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. Note
49 * that FreeType does not use floating-point data types. Fractional
50 * values are represented by fixed-point integers, with lower bits
51 * storing the fractional part.
91 * FT_Generic_Finalizer
102 /**************************************************************************
108 * A typedef of unsigned char, used for simple booleans. As usual,
109 * values 1 and~0 represent true and false, respectively.
111 typedef unsigned char FT_Bool;
114 /**************************************************************************
120 * A signed 16-bit integer used to store a distance in original font
123 typedef signed short FT_FWord; /* distance in FUnits */
126 /**************************************************************************
132 * An unsigned 16-bit integer used to store a distance in original font
135 typedef unsigned short FT_UFWord; /* unsigned distance */
138 /**************************************************************************
144 * A simple typedef for the _signed_ char type.
146 typedef signed char FT_Char;
149 /**************************************************************************
155 * A simple typedef for the _unsigned_ char type.
157 typedef unsigned char FT_Byte;
160 /**************************************************************************
166 * A typedef for constant memory areas.
168 typedef const FT_Byte* FT_Bytes;
171 /**************************************************************************
177 * A typedef for 32-bit tags (as used in the SFNT format).
179 typedef FT_UInt32 FT_Tag;
182 /**************************************************************************
188 * A simple typedef for the char type, usually used for strings.
190 typedef char FT_String;
193 /**************************************************************************
199 * A typedef for signed short.
201 typedef signed short FT_Short;
204 /**************************************************************************
210 * A typedef for unsigned short.
212 typedef unsigned short FT_UShort;
215 /**************************************************************************
221 * A typedef for the int type.
223 typedef signed int FT_Int;
226 /**************************************************************************
232 * A typedef for the unsigned int type.
234 typedef unsigned int FT_UInt;
237 /**************************************************************************
243 * A typedef for signed long.
245 typedef signed long FT_Long;
248 /**************************************************************************
254 * A typedef for unsigned long.
256 typedef unsigned long FT_ULong;
259 /**************************************************************************
265 * A signed 2.14 fixed-point type used for unit vectors.
267 typedef signed short FT_F2Dot14;
270 /**************************************************************************
276 * A signed 26.6 fixed-point type used for vectorial pixel coordinates.
278 typedef signed long FT_F26Dot6;
281 /**************************************************************************
287 * This type is used to store 16.16 fixed-point values, like scaling
288 * values or matrix coefficients.
290 typedef signed long FT_Fixed;
293 /**************************************************************************
299 * The FreeType error code type. A value of~0 is always interpreted as a
300 * successful operation.
302 typedef int FT_Error;
305 /**************************************************************************
311 * A simple typedef for a typeless pointer.
313 typedef void* FT_Pointer;
316 /**************************************************************************
322 * This is equivalent to the ANSI~C `size_t` type, i.e., the largest
323 * _unsigned_ integer type used to express a file size or position, or a
326 typedef size_t FT_Offset;
329 /**************************************************************************
335 * This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest
336 * _signed_ integer type used to express the distance between two
339 typedef ft_ptrdiff_t FT_PtrDist;
342 /**************************************************************************
348 * A simple structure used to store a 2D vector unit vector. Uses
353 * Horizontal coordinate.
356 * Vertical coordinate.
358 typedef struct FT_UnitVector_
366 /**************************************************************************
372 * A simple structure used to store a 2x2 matrix. Coefficients are in
373 * 16.16 fixed-point format. The computation performed is:
382 * Matrix coefficient.
385 * Matrix coefficient.
388 * Matrix coefficient.
391 * Matrix coefficient.
393 typedef struct FT_Matrix_
401 /**************************************************************************
407 * Read-only binary data represented as a pointer and a length.
414 * The length of the data in bytes.
416 typedef struct FT_Data_
418 const FT_Byte* pointer;
424 /**************************************************************************
427 * FT_Generic_Finalizer
430 * Describe a function used to destroy the 'client' data of any FreeType
431 * object. See the description of the @FT_Generic type for details of
435 * The address of the FreeType object that is under finalization. Its
436 * client data is accessed through its `generic` field.
438 typedef void (*FT_Generic_Finalizer)( void* object );
441 /**************************************************************************
447 * Client applications often need to associate their own data to a
448 * variety of FreeType core objects. For example, a text layout API
449 * might want to associate a glyph cache to a given size object.
451 * Some FreeType object contains a `generic` field, of type `FT_Generic`,
452 * which usage is left to client applications and font servers.
454 * It can be used to store a pointer to client-specific data, as well as
455 * the address of a 'finalizer' function, which will be called by
456 * FreeType when the object is destroyed (for example, the previous
457 * client example would put the address of the glyph cache destructor in
458 * the `finalizer` field).
462 * A typeless pointer to any client-specified data. This field is
463 * completely ignored by the FreeType library.
466 * A pointer to a 'generic finalizer' function, which will be called
467 * when the object is destroyed. If this field is set to `NULL`, no
468 * code will be called.
470 typedef struct FT_Generic_
473 FT_Generic_Finalizer finalizer;
478 /**************************************************************************
484 * This macro converts four-letter tags that are used to label TrueType
485 * tables into an `FT_Tag` type, to be used within FreeType.
488 * The produced values **must** be 32-bit integers. Don't redefine this
491 #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
492 ( ( FT_STATIC_BYTE_CAST( FT_Tag, _x1 ) << 24 ) | \
493 ( FT_STATIC_BYTE_CAST( FT_Tag, _x2 ) << 16 ) | \
494 ( FT_STATIC_BYTE_CAST( FT_Tag, _x3 ) << 8 ) | \
495 FT_STATIC_BYTE_CAST( FT_Tag, _x4 ) )
498 /*************************************************************************/
499 /*************************************************************************/
501 /* L I S T M A N A G E M E N T */
503 /*************************************************************************/
504 /*************************************************************************/
507 /**************************************************************************
515 /**************************************************************************
521 * Many elements and objects in FreeType are listed through an @FT_List
522 * record (see @FT_ListRec). As its name suggests, an FT_ListNode is a
523 * handle to a single list element.
525 typedef struct FT_ListNodeRec_* FT_ListNode;
528 /**************************************************************************
534 * A handle to a list record (see @FT_ListRec).
536 typedef struct FT_ListRec_* FT_List;
539 /**************************************************************************
545 * A structure used to hold a single list element.
549 * The previous element in the list. `NULL` if first.
552 * The next element in the list. `NULL` if last.
555 * A typeless pointer to the listed object.
557 typedef struct FT_ListNodeRec_
566 /**************************************************************************
572 * A structure used to hold a simple doubly-linked list. These are used
573 * in many parts of FreeType.
577 * The head (first element) of doubly-linked list.
580 * The tail (last element) of doubly-linked list.
582 typedef struct FT_ListRec_
592 #define FT_IS_EMPTY( list ) ( (list).head == 0 )
593 #define FT_BOOL( x ) FT_STATIC_CAST( FT_Bool, (x) != 0 )
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 )
599 /* see `ftmoderr.h` for descriptions of the following macros */
601 #define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
603 #define FT_ERROR_BASE( x ) ( (x) & 0xFF )
604 #define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
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 ) ) )
614 #endif /* FTTYPES_H_ */