Skip to content
/****************************************************************************
*
* fttypes.h
*
* FreeType simple types definitions (specification only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTTYPES_H_
#define FTTYPES_H_
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include <freetype/ftsystem.h>
#include <freetype/ftimage.h>
#include <stddef.h>
FT_BEGIN_HEADER
/**************************************************************************
*
* @section:
* basic_types
*
* @title:
* Basic Data Types
*
* @abstract:
* The basic data types defined by the library.
*
* @description:
* This section contains the basic data types defined by FreeType~2,
* ranging from simple scalar types to bitmap descriptors. More
* font-specific structures are defined in a different section. Note
* that FreeType does not use floating-point data types. Fractional
* values are represented by fixed-point integers, with lower bits
* storing the fractional part.
*
* @order:
* FT_Byte
* FT_Bytes
* FT_Char
* FT_Int
* FT_UInt
* FT_Int16
* FT_UInt16
* FT_Int32
* FT_UInt32
* FT_Int64
* FT_UInt64
* FT_Short
* FT_UShort
* FT_Long
* FT_ULong
* FT_Bool
* FT_Offset
* FT_PtrDist
* FT_String
* FT_Tag
* FT_Error
* FT_Fixed
* FT_Pointer
* FT_Pos
* FT_Vector
* FT_BBox
* FT_Matrix
* FT_FWord
* FT_UFWord
* FT_F2Dot14
* FT_UnitVector
* FT_F26Dot6
* FT_Data
*
* FT_MAKE_TAG
*
* FT_Generic
* FT_Generic_Finalizer
*
* FT_Bitmap
* FT_Pixel_Mode
* FT_Palette_Mode
* FT_Glyph_Format
* FT_IMAGE_TAG
*
*/
/**************************************************************************
*
* @type:
* FT_Bool
*
* @description:
* A typedef of unsigned char, used for simple booleans. As usual,
* values 1 and~0 represent true and false, respectively.
*/
typedef unsigned char FT_Bool;
/**************************************************************************
*
* @type:
* FT_FWord
*
* @description:
* A signed 16-bit integer used to store a distance in original font
* units.
*/
typedef signed short FT_FWord; /* distance in FUnits */
/**************************************************************************
*
* @type:
* FT_UFWord
*
* @description:
* An unsigned 16-bit integer used to store a distance in original font
* units.
*/
typedef unsigned short FT_UFWord; /* unsigned distance */
/**************************************************************************
*
* @type:
* FT_Char
*
* @description:
* A simple typedef for the _signed_ char type.
*/
typedef signed char FT_Char;
/**************************************************************************
*
* @type:
* FT_Byte
*
* @description:
* A simple typedef for the _unsigned_ char type.
*/
typedef unsigned char FT_Byte;
/**************************************************************************
*
* @type:
* FT_Bytes
*
* @description:
* A typedef for constant memory areas.
*/
typedef const FT_Byte* FT_Bytes;
/**************************************************************************
*
* @type:
* FT_Tag
*
* @description:
* A typedef for 32-bit tags (as used in the SFNT format).
*/
typedef FT_UInt32 FT_Tag;
/**************************************************************************
*
* @type:
* FT_String
*
* @description:
* A simple typedef for the char type, usually used for strings.
*/
typedef char FT_String;
/**************************************************************************
*
* @type:
* FT_Short
*
* @description:
* A typedef for signed short.
*/
typedef signed short FT_Short;
/**************************************************************************
*
* @type:
* FT_UShort
*
* @description:
* A typedef for unsigned short.
*/
typedef unsigned short FT_UShort;
/**************************************************************************
*
* @type:
* FT_Int
*
* @description:
* A typedef for the int type.
*/
typedef signed int FT_Int;
/**************************************************************************
*
* @type:
* FT_UInt
*
* @description:
* A typedef for the unsigned int type.
*/
typedef unsigned int FT_UInt;
/**************************************************************************
*
* @type:
* FT_Long
*
* @description:
* A typedef for signed long.
*/
typedef signed long FT_Long;
/**************************************************************************
*
* @type:
* FT_ULong
*
* @description:
* A typedef for unsigned long.
*/
typedef unsigned long FT_ULong;
/**************************************************************************
*
* @type:
* FT_F2Dot14
*
* @description:
* A signed 2.14 fixed-point type used for unit vectors.
*/
typedef signed short FT_F2Dot14;
/**************************************************************************
*
* @type:
* FT_F26Dot6
*
* @description:
* A signed 26.6 fixed-point type used for vectorial pixel coordinates.
*/
typedef signed long FT_F26Dot6;
/**************************************************************************
*
* @type:
* FT_Fixed
*
* @description:
* This type is used to store 16.16 fixed-point values, like scaling
* values or matrix coefficients.
*/
typedef signed long FT_Fixed;
/**************************************************************************
*
* @type:
* FT_Error
*
* @description:
* The FreeType error code type. A value of~0 is always interpreted as a
* successful operation.
*/
typedef int FT_Error;
/**************************************************************************
*
* @type:
* FT_Pointer
*
* @description:
* A simple typedef for a typeless pointer.
*/
typedef void* FT_Pointer;
/**************************************************************************
*
* @type:
* FT_Offset
*
* @description:
* This is equivalent to the ANSI~C `size_t` type, i.e., the largest
* _unsigned_ integer type used to express a file size or position, or a
* memory block size.
*/
typedef size_t FT_Offset;
/**************************************************************************
*
* @type:
* FT_PtrDist
*
* @description:
* This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest
* _signed_ integer type used to express the distance between two
* pointers.
*/
typedef ft_ptrdiff_t FT_PtrDist;
/**************************************************************************
*
* @struct:
* FT_UnitVector
*
* @description:
* A simple structure used to store a 2D vector unit vector. Uses
* FT_F2Dot14 types.
*
* @fields:
* x ::
* Horizontal coordinate.
*
* y ::
* Vertical coordinate.
*/
typedef struct FT_UnitVector_
{
FT_F2Dot14 x;
FT_F2Dot14 y;
} FT_UnitVector;
/**************************************************************************
*
* @struct:
* FT_Matrix
*
* @description:
* A simple structure used to store a 2x2 matrix. Coefficients are in
* 16.16 fixed-point format. The computation performed is:
*
* ```
* x' = x*xx + y*xy
* y' = x*yx + y*yy
* ```
*
* @fields:
* xx ::
* Matrix coefficient.
*
* xy ::
* Matrix coefficient.
*
* yx ::
* Matrix coefficient.
*
* yy ::
* Matrix coefficient.
*/
typedef struct FT_Matrix_
{
FT_Fixed xx, xy;
FT_Fixed yx, yy;
} FT_Matrix;
/**************************************************************************
*
* @struct:
* FT_Data
*
* @description:
* Read-only binary data represented as a pointer and a length.
*
* @fields:
* pointer ::
* The data.
*
* length ::
* The length of the data in bytes.
*/
typedef struct FT_Data_
{
const FT_Byte* pointer;
FT_UInt length;
} FT_Data;
/**************************************************************************
*
* @functype:
* FT_Generic_Finalizer
*
* @description:
* Describe a function used to destroy the 'client' data of any FreeType
* object. See the description of the @FT_Generic type for details of
* usage.
*
* @input:
* The address of the FreeType object that is under finalization. Its
* client data is accessed through its `generic` field.
*/
typedef void (*FT_Generic_Finalizer)( void* object );
/**************************************************************************
*
* @struct:
* FT_Generic
*
* @description:
* Client applications often need to associate their own data to a
* variety of FreeType core objects. For example, a text layout API
* might want to associate a glyph cache to a given size object.
*
* Some FreeType object contains a `generic` field, of type `FT_Generic`,
* which usage is left to client applications and font servers.
*
* It can be used to store a pointer to client-specific data, as well as
* the address of a 'finalizer' function, which will be called by
* FreeType when the object is destroyed (for example, the previous
* client example would put the address of the glyph cache destructor in
* the `finalizer` field).
*
* @fields:
* data ::
* A typeless pointer to any client-specified data. This field is
* completely ignored by the FreeType library.
*
* finalizer ::
* A pointer to a 'generic finalizer' function, which will be called
* when the object is destroyed. If this field is set to `NULL`, no
* code will be called.
*/
typedef struct FT_Generic_
{
void* data;
FT_Generic_Finalizer finalizer;
} FT_Generic;
/**************************************************************************
*
* @macro:
* FT_MAKE_TAG
*
* @description:
* This macro converts four-letter tags that are used to label TrueType
* tables into an `FT_Tag` type, to be used within FreeType.
*
* @note:
* The produced values **must** be 32-bit integers. Don't redefine this
* macro.
*/
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
( ( FT_STATIC_BYTE_CAST( FT_Tag, _x1 ) << 24 ) | \
( FT_STATIC_BYTE_CAST( FT_Tag, _x2 ) << 16 ) | \
( FT_STATIC_BYTE_CAST( FT_Tag, _x3 ) << 8 ) | \
FT_STATIC_BYTE_CAST( FT_Tag, _x4 ) )
/*************************************************************************/
/*************************************************************************/
/* */
/* L I S T M A N A G E M E N T */
/* */
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @section:
* list_processing
*
*/
/**************************************************************************
*
* @type:
* FT_ListNode
*
* @description:
* Many elements and objects in FreeType are listed through an @FT_List
* record (see @FT_ListRec). As its name suggests, an FT_ListNode is a
* handle to a single list element.
*/
typedef struct FT_ListNodeRec_* FT_ListNode;
/**************************************************************************
*
* @type:
* FT_List
*
* @description:
* A handle to a list record (see @FT_ListRec).
*/
typedef struct FT_ListRec_* FT_List;
/**************************************************************************
*
* @struct:
* FT_ListNodeRec
*
* @description:
* A structure used to hold a single list element.
*
* @fields:
* prev ::
* The previous element in the list. `NULL` if first.
*
* next ::
* The next element in the list. `NULL` if last.
*
* data ::
* A typeless pointer to the listed object.
*/
typedef struct FT_ListNodeRec_
{
FT_ListNode prev;
FT_ListNode next;
void* data;
} FT_ListNodeRec;
/**************************************************************************
*
* @struct:
* FT_ListRec
*
* @description:
* A structure used to hold a simple doubly-linked list. These are used
* in many parts of FreeType.
*
* @fields:
* head ::
* The head (first element) of doubly-linked list.
*
* tail ::
* The tail (last element) of doubly-linked list.
*/
typedef struct FT_ListRec_
{
FT_ListNode head;
FT_ListNode tail;
} FT_ListRec;
/* */
#define FT_IS_EMPTY( list ) ( (list).head == 0 )
#define FT_BOOL( x ) FT_STATIC_CAST( FT_Bool, (x) != 0 )
/* concatenate C tokens */
#define FT_ERR_XCAT( x, y ) x ## y
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
/* see `ftmoderr.h` for descriptions of the following macros */
#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
#define FT_ERROR_BASE( x ) ( (x) & 0xFF )
#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
#define FT_ERR_EQ( x, e ) \
( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) )
#define FT_ERR_NEQ( x, e ) \
( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) )
FT_END_HEADER
#endif /* FTTYPES_H_ */
/* END */
/****************************************************************************
*
* ftwinfnt.h
*
* FreeType API for accessing Windows fnt-specific data.
*
* Copyright (C) 2003-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTWINFNT_H_
#define FTWINFNT_H_
#include <freetype/freetype.h>
#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif
FT_BEGIN_HEADER
/**************************************************************************
*
* @section:
* winfnt_fonts
*
* @title:
* Window FNT Files
*
* @abstract:
* Windows FNT-specific API.
*
* @description:
* This section contains the declaration of Windows FNT-specific
* functions.
*
*/
/**************************************************************************
*
* @enum:
* FT_WinFNT_ID_XXX
*
* @description:
* A list of valid values for the `charset` byte in @FT_WinFNT_HeaderRec.
* Exact mapping tables for the various 'cpXXXX' encodings (except for
* 'cp1361') can be found at 'ftp://ftp.unicode.org/Public/' in the
* `MAPPINGS/VENDORS/MICSFT/WINDOWS` subdirectory. 'cp1361' is roughly a
* superset of `MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT`.
*
* @values:
* FT_WinFNT_ID_DEFAULT ::
* This is used for font enumeration and font creation as a 'don't
* care' value. Valid font files don't contain this value. When
* querying for information about the character set of the font that is
* currently selected into a specified device context, this return
* value (of the related Windows API) simply denotes failure.
*
* FT_WinFNT_ID_SYMBOL ::
* There is no known mapping table available.
*
* FT_WinFNT_ID_MAC ::
* Mac Roman encoding.
*
* FT_WinFNT_ID_OEM ::
* From Michael Poettgen <michael@poettgen.de>:
*
* The 'Windows Font Mapping' article says that `FT_WinFNT_ID_OEM` is
* used for the charset of vector fonts, like `modern.fon`,
* `roman.fon`, and `script.fon` on Windows.
*
* The 'CreateFont' documentation says: The `FT_WinFNT_ID_OEM` value
* specifies a character set that is operating-system dependent.
*
* The 'IFIMETRICS' documentation from the 'Windows Driver Development
* Kit' says: This font supports an OEM-specific character set. The
* OEM character set is system dependent.
*
* In general OEM, as opposed to ANSI (i.e., 'cp1252'), denotes the
* second default codepage that most international versions of Windows
* have. It is one of the OEM codepages from
*
* https://docs.microsoft.com/en-us/windows/desktop/intl/code-page-identifiers
* ,
*
* and is used for the 'DOS boxes', to support legacy applications. A
* German Windows version for example usually uses ANSI codepage 1252
* and OEM codepage 850.
*
* FT_WinFNT_ID_CP874 ::
* A superset of Thai TIS 620 and ISO 8859-11.
*
* FT_WinFNT_ID_CP932 ::
* A superset of Japanese Shift-JIS (with minor deviations).
*
* FT_WinFNT_ID_CP936 ::
* A superset of simplified Chinese GB 2312-1980 (with different
* ordering and minor deviations).
*
* FT_WinFNT_ID_CP949 ::
* A superset of Korean Hangul KS~C 5601-1987 (with different ordering
* and minor deviations).
*
* FT_WinFNT_ID_CP950 ::
* A superset of traditional Chinese Big~5 ETen (with different
* ordering and minor deviations).
*
* FT_WinFNT_ID_CP1250 ::
* A superset of East European ISO 8859-2 (with slightly different
* ordering).
*
* FT_WinFNT_ID_CP1251 ::
* A superset of Russian ISO 8859-5 (with different ordering).
*
* FT_WinFNT_ID_CP1252 ::
* ANSI encoding. A superset of ISO 8859-1.
*
* FT_WinFNT_ID_CP1253 ::
* A superset of Greek ISO 8859-7 (with minor modifications).
*
* FT_WinFNT_ID_CP1254 ::
* A superset of Turkish ISO 8859-9.
*
* FT_WinFNT_ID_CP1255 ::
* A superset of Hebrew ISO 8859-8 (with some modifications).
*
* FT_WinFNT_ID_CP1256 ::
* A superset of Arabic ISO 8859-6 (with different ordering).
*
* FT_WinFNT_ID_CP1257 ::
* A superset of Baltic ISO 8859-13 (with some deviations).
*
* FT_WinFNT_ID_CP1258 ::
* For Vietnamese. This encoding doesn't cover all necessary
* characters.
*
* FT_WinFNT_ID_CP1361 ::
* Korean (Johab).
*/
#define FT_WinFNT_ID_CP1252 0
#define FT_WinFNT_ID_DEFAULT 1
#define FT_WinFNT_ID_SYMBOL 2
#define FT_WinFNT_ID_MAC 77
#define FT_WinFNT_ID_CP932 128
#define FT_WinFNT_ID_CP949 129
#define FT_WinFNT_ID_CP1361 130
#define FT_WinFNT_ID_CP936 134
#define FT_WinFNT_ID_CP950 136
#define FT_WinFNT_ID_CP1253 161
#define FT_WinFNT_ID_CP1254 162
#define FT_WinFNT_ID_CP1258 163
#define FT_WinFNT_ID_CP1255 177
#define FT_WinFNT_ID_CP1256 178
#define FT_WinFNT_ID_CP1257 186
#define FT_WinFNT_ID_CP1251 204
#define FT_WinFNT_ID_CP874 222
#define FT_WinFNT_ID_CP1250 238
#define FT_WinFNT_ID_OEM 255
/**************************************************************************
*
* @struct:
* FT_WinFNT_HeaderRec
*
* @description:
* Windows FNT Header info.
*/
typedef struct FT_WinFNT_HeaderRec_
{
FT_UShort version;
FT_ULong file_size;
FT_Byte copyright[60];
FT_UShort file_type;
FT_UShort nominal_point_size;
FT_UShort vertical_resolution;
FT_UShort horizontal_resolution;
FT_UShort ascent;
FT_UShort internal_leading;
FT_UShort external_leading;
FT_Byte italic;
FT_Byte underline;
FT_Byte strike_out;
FT_UShort weight;
FT_Byte charset;
FT_UShort pixel_width;
FT_UShort pixel_height;
FT_Byte pitch_and_family;
FT_UShort avg_width;
FT_UShort max_width;
FT_Byte first_char;
FT_Byte last_char;
FT_Byte default_char;
FT_Byte break_char;
FT_UShort bytes_per_row;
FT_ULong device_offset;
FT_ULong face_name_offset;
FT_ULong bits_pointer;
FT_ULong bits_offset;
FT_Byte reserved;
FT_ULong flags;
FT_UShort A_space;
FT_UShort B_space;
FT_UShort C_space;
FT_UShort color_table_offset;
FT_ULong reserved1[4];
} FT_WinFNT_HeaderRec;
/**************************************************************************
*
* @struct:
* FT_WinFNT_Header
*
* @description:
* A handle to an @FT_WinFNT_HeaderRec structure.
*/
typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header;
/**************************************************************************
*
* @function:
* FT_Get_WinFNT_Header
*
* @description:
* Retrieve a Windows FNT font info header.
*
* @input:
* face ::
* A handle to the input face.
*
* @output:
* aheader ::
* The WinFNT header.
*
* @return:
* FreeType error code. 0~means success.
*
* @note:
* This function only works with Windows FNT faces, returning an error
* otherwise.
*/
FT_EXPORT( FT_Error )
FT_Get_WinFNT_Header( FT_Face face,
FT_WinFNT_HeaderRec *aheader );
/* */
FT_END_HEADER
#endif /* FTWINFNT_H_ */
/* END */
/* Local Variables: */
/* coding: utf-8 */
/* End: */
/****************************************************************************
*
* autohint.h
*
* High-level 'autohint' module-specific interface (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
/**************************************************************************
*
* The auto-hinter is used to load and automatically hint glyphs if a
* format-specific hinter isn't available.
*
*/
#ifndef AUTOHINT_H_
#define AUTOHINT_H_
/**************************************************************************
*
* A small technical note regarding automatic hinting in order to clarify
* this module interface.
*
* An automatic hinter might compute two kinds of data for a given face:
*
* - global hints: Usually some metrics that describe global properties
* of the face. It is computed by scanning more or less
* aggressively the glyphs in the face, and thus can be
* very slow to compute (even if the size of global hints
* is really small).
*
* - glyph hints: These describe some important features of the glyph
* outline, as well as how to align them. They are
* generally much faster to compute than global hints.
*
* The current FreeType auto-hinter does a pretty good job while performing
* fast computations for both global and glyph hints. However, we might be
* interested in introducing more complex and powerful algorithms in the
* future, like the one described in the John D. Hobby paper, which
* unfortunately requires a lot more horsepower.
*
* Because a sufficiently sophisticated font management system would
* typically implement an LRU cache of opened face objects to reduce memory
* usage, it is a good idea to be able to avoid recomputing global hints
* every time the same face is re-opened.
*
* We thus provide the ability to cache global hints outside of the face
* object, in order to speed up font re-opening time. Of course, this
* feature is purely optional, so most client programs won't even notice
* it.
*
* I initially thought that it would be a good idea to cache the glyph
* hints too. However, my general idea now is that if you really need to
* cache these too, you are simply in need of a new font format, where all
* this information could be stored within the font file and decoded on the
* fly.
*
*/
#include <freetype/freetype.h>
FT_BEGIN_HEADER
typedef struct FT_AutoHinterRec_ *FT_AutoHinter;
/**************************************************************************
*
* @functype:
* FT_AutoHinter_GlobalGetFunc
*
* @description:
* Retrieve the global hints computed for a given face object. The
* resulting data is dissociated from the face and will survive a call to
* FT_Done_Face(). It must be discarded through the API
* FT_AutoHinter_GlobalDoneFunc().
*
* @input:
* hinter ::
* A handle to the source auto-hinter.
*
* face ::
* A handle to the source face object.
*
* @output:
* global_hints ::
* A typeless pointer to the global hints.
*
* global_len ::
* The size in bytes of the global hints.
*/
typedef void
(*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter,
FT_Face face,
void** global_hints,
long* global_len );
/**************************************************************************
*
* @functype:
* FT_AutoHinter_GlobalDoneFunc
*
* @description:
* Discard the global hints retrieved through
* FT_AutoHinter_GlobalGetFunc(). This is the only way these hints are
* freed from memory.
*
* @input:
* hinter ::
* A handle to the auto-hinter module.
*
* global ::
* A pointer to retrieved global hints to discard.
*/
typedef void
(*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter,
void* global );
/**************************************************************************
*
* @functype:
* FT_AutoHinter_GlobalResetFunc
*
* @description:
* This function is used to recompute the global metrics in a given font.
* This is useful when global font data changes (e.g. Multiple Masters
* fonts where blend coordinates change).
*
* @input:
* hinter ::
* A handle to the source auto-hinter.
*
* face ::
* A handle to the face.
*/
typedef void
(*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter,
FT_Face face );
/**************************************************************************
*
* @functype:
* FT_AutoHinter_GlyphLoadFunc
*
* @description:
* This function is used to load, scale, and automatically hint a glyph
* from a given face.
*
* @input:
* face ::
* A handle to the face.
*
* glyph_index ::
* The glyph index.
*
* load_flags ::
* The load flags.
*
* @note:
* This function is capable of loading composite glyphs by hinting each
* sub-glyph independently (which improves quality).
*
* It will call the font driver with @FT_Load_Glyph, with
* @FT_LOAD_NO_SCALE set.
*/
typedef FT_Error
(*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter,
FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags );
/**************************************************************************
*
* @struct:
* FT_AutoHinter_InterfaceRec
*
* @description:
* The auto-hinter module's interface.
*/
typedef struct FT_AutoHinter_InterfaceRec_
{
FT_AutoHinter_GlobalResetFunc reset_face;
FT_AutoHinter_GlobalGetFunc get_global_hints;
FT_AutoHinter_GlobalDoneFunc done_global_hints;
FT_AutoHinter_GlyphLoadFunc load_glyph;
} FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface;
#define FT_DECLARE_AUTOHINTER_INTERFACE( class_ ) \
FT_CALLBACK_TABLE const FT_AutoHinter_InterfaceRec class_;
#define FT_DEFINE_AUTOHINTER_INTERFACE( \
class_, \
reset_face_, \
get_global_hints_, \
done_global_hints_, \
load_glyph_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_AutoHinter_InterfaceRec class_ = \
{ \
reset_face_, \
get_global_hints_, \
done_global_hints_, \
load_glyph_ \
};
FT_END_HEADER
#endif /* AUTOHINT_H_ */
/* END */
/****************************************************************************
*
* cffotypes.h
*
* Basic OpenType/CFF object type definitions (specification).
*
* Copyright (C) 2017-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef CFFOTYPES_H_
#define CFFOTYPES_H_
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/cfftypes.h>
#include <freetype/internal/tttypes.h>
#include <freetype/internal/services/svpscmap.h>
#include <freetype/internal/pshints.h>
FT_BEGIN_HEADER
typedef TT_Face CFF_Face;
/**************************************************************************
*
* @type:
* CFF_Size
*
* @description:
* A handle to an OpenType size object.
*/
typedef struct CFF_SizeRec_
{
FT_SizeRec root;
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
} CFF_SizeRec, *CFF_Size;
/**************************************************************************
*
* @type:
* CFF_GlyphSlot
*
* @description:
* A handle to an OpenType glyph slot object.
*/
typedef struct CFF_GlyphSlotRec_
{
FT_GlyphSlotRec root;
FT_Bool hint;
FT_Bool scaled;
FT_Fixed x_scale;
FT_Fixed y_scale;
} CFF_GlyphSlotRec, *CFF_GlyphSlot;
/**************************************************************************
*
* @type:
* CFF_Internal
*
* @description:
* The interface to the 'internal' field of `FT_Size`.
*/
typedef struct CFF_InternalRec_
{
PSH_Globals topfont;
PSH_Globals subfonts[CFF_MAX_CID_FONTS];
} CFF_InternalRec, *CFF_Internal;
/**************************************************************************
*
* Subglyph transformation record.
*/
typedef struct CFF_Transform_
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
FT_Fixed yx, yy;
FT_F26Dot6 ox, oy; /* offsets */
} CFF_Transform;
FT_END_HEADER
#endif /* CFFOTYPES_H_ */
/* END */
/****************************************************************************
*
* cfftypes.h
*
* Basic OpenType/CFF type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef CFFTYPES_H_
#define CFFTYPES_H_
#include <freetype/freetype.h>
#include <freetype/t1tables.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/services/svpscmap.h>
#include <freetype/internal/pshints.h>
#include <freetype/internal/t1types.h>
FT_BEGIN_HEADER
/**************************************************************************
*
* @struct:
* CFF_IndexRec
*
* @description:
* A structure used to model a CFF Index table.
*
* @fields:
* stream ::
* The source input stream.
*
* start ::
* The position of the first index byte in the input stream.
*
* count ::
* The number of elements in the index.
*
* off_size ::
* The size in bytes of object offsets in index.
*
* data_offset ::
* The position of first data byte in the index's bytes.
*
* data_size ::
* The size of the data table in this index.
*
* offsets ::
* A table of element offsets in the index. Must be loaded explicitly.
*
* bytes ::
* If the index is loaded in memory, its bytes.
*/
typedef struct CFF_IndexRec_
{
FT_Stream stream;
FT_ULong start;
FT_UInt hdr_size;
FT_UInt count;
FT_Byte off_size;
FT_ULong data_offset;
FT_ULong data_size;
FT_ULong* offsets;
FT_Byte* bytes;
} CFF_IndexRec, *CFF_Index;
typedef struct CFF_EncodingRec_
{
FT_UInt format;
FT_ULong offset;
FT_UInt count;
FT_UShort sids [256]; /* avoid dynamic allocations */
FT_UShort codes[256];
} CFF_EncodingRec, *CFF_Encoding;
typedef struct CFF_CharsetRec_
{
FT_UInt format;
FT_ULong offset;
FT_UShort* sids;
FT_UShort* cids; /* the inverse mapping of `sids'; only needed */
/* for CID-keyed fonts */
FT_UInt max_cid;
FT_UInt num_glyphs;
} CFF_CharsetRec, *CFF_Charset;
/* cf. similar fields in file `ttgxvar.h' from the `truetype' module */
typedef struct CFF_VarData_
{
#if 0
FT_UInt itemCount; /* not used; always zero */
FT_UInt shortDeltaCount; /* not used; always zero */
#endif
FT_UInt regionIdxCount; /* number of region indexes */
FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */
/* these index `varRegionList' */
} CFF_VarData;
/* contribution of one axis to a region */
typedef struct CFF_AxisCoords_
{
FT_Fixed startCoord;
FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */
FT_Fixed endCoord;
} CFF_AxisCoords;
typedef struct CFF_VarRegion_
{
CFF_AxisCoords* axisList; /* array of axisCount records */
} CFF_VarRegion;
typedef struct CFF_VStoreRec_
{
FT_UInt dataCount;
CFF_VarData* varData; /* array of dataCount records */
/* vsindex indexes this array */
FT_UShort axisCount;
FT_UInt regionCount; /* total number of regions defined */
CFF_VarRegion* varRegionList;
} CFF_VStoreRec, *CFF_VStore;
/* forward reference */
typedef struct CFF_FontRec_* CFF_Font;
/* This object manages one cached blend vector. */
/* */
/* There is a BlendRec for Private DICT parsing in each subfont */
/* and a BlendRec for charstrings in CF2_Font instance data. */
/* A cached BV may be used across DICTs or Charstrings if inputs */
/* have not changed. */
/* */
/* `usedBV' is reset at the start of each parse or charstring. */
/* vsindex cannot be changed after a BV is used. */
/* */
/* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */
typedef struct CFF_BlendRec_
{
FT_Bool builtBV; /* blendV has been built */
FT_Bool usedBV; /* blendV has been used */
CFF_Font font; /* top level font struct */
FT_UInt lastVsindex; /* last vsindex used */
FT_UInt lenNDV; /* normDV length (aka numAxes) */
FT_Fixed* lastNDV; /* last NDV used */
FT_UInt lenBV; /* BlendV length (aka numMasters) */
FT_Int32* BV; /* current blendV (per DICT/glyph) */
} CFF_BlendRec, *CFF_Blend;
typedef struct CFF_FontRecDictRec_
{
FT_UInt version;
FT_UInt notice;
FT_UInt copyright;
FT_UInt full_name;
FT_UInt family_name;
FT_UInt weight;
FT_Bool is_fixed_pitch;
FT_Fixed italic_angle;
FT_Fixed underline_position;
FT_Fixed underline_thickness;
FT_Int paint_type;
FT_Int charstring_type;
FT_Matrix font_matrix;
FT_Bool has_font_matrix;
FT_ULong units_per_em; /* temporarily used as scaling value also */
FT_Vector font_offset;
FT_ULong unique_id;
FT_BBox font_bbox;
FT_Pos stroke_width;
FT_ULong charset_offset;
FT_ULong encoding_offset;
FT_ULong charstrings_offset;
FT_ULong private_offset;
FT_ULong private_size;
FT_Long synthetic_base;
FT_UInt embedded_postscript;
/* these should only be used for the top-level font dictionary */
FT_UInt cid_registry;
FT_UInt cid_ordering;
FT_Long cid_supplement;
FT_Long cid_font_version;
FT_Long cid_font_revision;
FT_Long cid_font_type;
FT_ULong cid_count;
FT_ULong cid_uid_base;
FT_ULong cid_fd_array_offset;
FT_ULong cid_fd_select_offset;
FT_UInt cid_font_name;
/* the next fields come from the data of the deprecated */
/* `MultipleMaster' operator; they are needed to parse the (also */
/* deprecated) `blend' operator in Type 2 charstrings */
FT_UShort num_designs;
FT_UShort num_axes;
/* fields for CFF2 */
FT_ULong vstore_offset;
FT_UInt maxstack;
} CFF_FontRecDictRec, *CFF_FontRecDict;
/* forward reference */
typedef struct CFF_SubFontRec_* CFF_SubFont;
typedef struct CFF_PrivateRec_
{
FT_Byte num_blue_values;
FT_Byte num_other_blues;
FT_Byte num_family_blues;
FT_Byte num_family_other_blues;
FT_Fixed blue_values[14];
FT_Fixed other_blues[10];
FT_Fixed family_blues[14];
FT_Fixed family_other_blues[10];
FT_Fixed blue_scale;
FT_Pos blue_shift;
FT_Pos blue_fuzz;
FT_Pos standard_width;
FT_Pos standard_height;
FT_Byte num_snap_widths;
FT_Byte num_snap_heights;
FT_Pos snap_widths[13];
FT_Pos snap_heights[13];
FT_Bool force_bold;
FT_Fixed force_bold_threshold;
FT_Int lenIV;
FT_Int language_group;
FT_Fixed expansion_factor;
FT_Long initial_random_seed;
FT_ULong local_subrs_offset;
FT_Pos default_width;
FT_Pos nominal_width;
/* fields for CFF2 */
FT_UInt vsindex;
CFF_SubFont subfont;
} CFF_PrivateRec, *CFF_Private;
typedef struct CFF_FDSelectRec_
{
FT_Byte format;
FT_UInt range_count;
/* that's the table, taken from the file `as is' */
FT_Byte* data;
FT_UInt data_size;
/* small cache for format 3 only */
FT_UInt cache_first;
FT_UInt cache_count;
FT_Byte cache_fd;
} CFF_FDSelectRec, *CFF_FDSelect;
/* A SubFont packs a font dict and a private dict together. They are */
/* needed to support CID-keyed CFF fonts. */
typedef struct CFF_SubFontRec_
{
CFF_FontRecDictRec font_dict;
CFF_PrivateRec private_dict;
/* fields for CFF2 */
CFF_BlendRec blend; /* current blend vector */
FT_UInt lenNDV; /* current length NDV or zero */
FT_Fixed* NDV; /* ptr to current NDV or NULL */
/* `blend_stack' is a writable buffer to hold blend results. */
/* This buffer is to the side of the normal cff parser stack; */
/* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */
/* The normal stack then points to these values instead of the DICT */
/* because all other operators in Private DICT clear the stack. */
/* `blend_stack' could be cleared at each operator other than blend. */
/* Blended values are stored as 5-byte fixed-point values. */
FT_Byte* blend_stack; /* base of stack allocation */
FT_Byte* blend_top; /* first empty slot */
FT_UInt blend_used; /* number of bytes in use */
FT_UInt blend_alloc; /* number of bytes allocated */
CFF_IndexRec local_subrs_index;
FT_Byte** local_subrs; /* array of pointers */
/* into Local Subrs INDEX data */
FT_UInt32 random;
} CFF_SubFontRec;
#define CFF_MAX_CID_FONTS 256
typedef struct CFF_FontRec_
{
FT_Library library;
FT_Stream stream;
FT_Memory memory; /* TODO: take this from stream->memory? */
FT_ULong base_offset; /* offset to start of CFF */
FT_UInt num_faces;
FT_UInt num_glyphs;
FT_Byte version_major;
FT_Byte version_minor;
FT_Byte header_size;
FT_UInt top_dict_length; /* cff2 only */
FT_Bool cff2;
CFF_IndexRec name_index;
CFF_IndexRec top_dict_index;
CFF_IndexRec global_subrs_index;
CFF_EncodingRec encoding;
CFF_CharsetRec charset;
CFF_IndexRec charstrings_index;
CFF_IndexRec font_dict_index;
CFF_IndexRec private_index;
CFF_IndexRec local_subrs_index;
FT_String* font_name;
/* array of pointers into Global Subrs INDEX data */
FT_Byte** global_subrs;
/* array of pointers into String INDEX data stored at string_pool */
FT_UInt num_strings;
FT_Byte** strings;
FT_Byte* string_pool;
FT_ULong string_pool_size;
CFF_SubFontRec top_font;
FT_UInt num_subfonts;
CFF_SubFont subfonts[CFF_MAX_CID_FONTS];
CFF_FDSelectRec fd_select;
/* interface to PostScript hinter */
PSHinter_Service pshinter;
/* interface to Postscript Names service */
FT_Service_PsCMaps psnames;
/* interface to CFFLoad service */
const void* cffload;
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */
/* since version 2.3.6 */
FT_String* registry;
FT_String* ordering;
/* since version 2.4.12 */
FT_Generic cf2_instance;
/* since version 2.7.1 */
CFF_VStoreRec vstore; /* parsed vstore structure */
/* since version 2.9 */
PS_FontExtraRec* font_extra;
} CFF_FontRec;
FT_END_HEADER
#endif /* CFFTYPES_H_ */
/* END */
/****************************************************************************
*
* internal/compiler-macros.h
*
* Compiler-specific macro definitions used internally by FreeType.
*
* Copyright (C) 2020-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef INTERNAL_COMPILER_MACROS_H_
#define INTERNAL_COMPILER_MACROS_H_
#include <freetype/config/public-macros.h>
FT_BEGIN_HEADER
/* Fix compiler warning with sgi compiler. */
#if defined( __sgi ) && !defined( __GNUC__ )
# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
# pragma set woff 3505
# endif
#endif
/* Fix compiler warning with sgi compiler. */
#if defined( __sgi ) && !defined( __GNUC__ )
# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
# pragma set woff 3505
# endif
#endif
/* Newer compilers warn for fall-through case statements. */
#ifndef FALL_THROUGH
# if ( defined( __STDC_VERSION__ ) && __STDC_VERSION__ > 201710L ) || \
( defined( __cplusplus ) && __cplusplus > 201402L )
# define FALL_THROUGH [[__fallthrough__]]
# elif ( defined( __GNUC__ ) && __GNUC__ >= 7 ) || \
( defined( __clang__ ) && \
( defined( __apple_build_version__ ) \
? __apple_build_version__ >= 12000000 \
: __clang_major__ >= 10 ) )
# define FALL_THROUGH __attribute__(( __fallthrough__ ))
# else
# define FALL_THROUGH ( (void)0 )
# endif
#endif
/*
* When defining a macro that expands to a non-trivial C statement, use
* FT_BEGIN_STMNT and FT_END_STMNT to enclose the macro's body. This
* ensures there are no surprises when the macro is invoked in conditional
* branches.
*
* Example:
*
* #define LOG( ... ) \
* FT_BEGIN_STMNT \
* if ( logging_enabled ) \
* log( __VA_ARGS__ ); \
* FT_END_STMNT
*/
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
/*
* FT_DUMMY_STMNT expands to an empty C statement. Useful for
* conditionally defined statement macros.
*
* Example:
*
* #ifdef BUILD_CONFIG_LOGGING
* #define LOG( ... ) \
* FT_BEGIN_STMNT \
* if ( logging_enabled ) \
* log( __VA_ARGS__ ); \
* FT_END_STMNT
* #else
* # define LOG( ... ) FT_DUMMY_STMNT
* #endif
*/
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
#ifdef __UINTPTR_TYPE__
/*
* GCC and Clang both provide a `__UINTPTR_TYPE__` that can be used to
* avoid a dependency on `stdint.h`.
*/
# define FT_UINT_TO_POINTER( x ) (void *)(__UINTPTR_TYPE__)(x)
#elif defined( _WIN64 )
/* only 64bit Windows uses the LLP64 data model, i.e., */
/* 32-bit integers, 64-bit pointers. */
# define FT_UINT_TO_POINTER( x ) (void *)(unsigned __int64)(x)
#else
# define FT_UINT_TO_POINTER( x ) (void *)(unsigned long)(x)
#endif
/*
* Use `FT_TYPEOF( type )` to cast a value to `type`. This is useful to
* suppress signedness compilation warnings in macros.
*
* Example:
*
* #define PAD_( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
*
* (The `typeof` condition is taken from gnulib's `intprops.h` header
* file.)
*/
#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \
( defined( __IBMC__ ) && __IBMC__ >= 1210 && \
defined( __IBM__TYPEOF__ ) ) || \
( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
#define FT_TYPEOF( type ) ( __typeof__ ( type ) )
#else
#define FT_TYPEOF( type ) /* empty */
#endif
/*
* Mark a function declaration as internal to the library. This ensures
* that it will not be exposed by default to client code, and helps
* generate smaller and faster code on ELF-based platforms. Place this
* before a function declaration.
*/
/* Visual C, mingw */
#if defined( _WIN32 )
#define FT_INTERNAL_FUNCTION_ATTRIBUTE /* empty */
/* gcc, clang */
#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ )
#define FT_INTERNAL_FUNCTION_ATTRIBUTE \
__attribute__(( visibility( "hidden" ) ))
/* Sun */
#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550
#define FT_INTERNAL_FUNCTION_ATTRIBUTE __hidden
#else
#define FT_INTERNAL_FUNCTION_ATTRIBUTE /* empty */
#endif
/*
* FreeType supports compilation of its C sources with a C++ compiler (in
* C++ mode); this introduces a number of subtle issues.
*
* The main one is that a C++ function declaration and its definition must
* have the same 'linkage'. Because all FreeType headers declare their
* functions with C linkage (i.e., within an `extern "C" { ... }` block
* due to the magic of FT_BEGIN_HEADER and FT_END_HEADER), their
* definition in FreeType sources should also be prefixed with `extern
* "C"` when compiled in C++ mode.
*
* The `FT_FUNCTION_DECLARATION` and `FT_FUNCTION_DEFINITION` macros are
* provided to deal with this case, as well as `FT_CALLBACK_DEF` and its
* siblings below.
*/
/*
* `FT_FUNCTION_DECLARATION( type )` can be used to write a C function
* declaration to ensure it will have C linkage when the library is built
* with a C++ compiler. The parameter is the function's return type, so a
* declaration would look like
*
* FT_FUNCTION_DECLARATION( int )
* foo( int x );
*
* NOTE: This requires that all uses are inside of `FT_BEGIN_HEADER ...
* FT_END_HEADER` blocks, which guarantees that the declarations have C
* linkage when the headers are included by C++ sources.
*
* NOTE: Do not use directly. Use `FT_LOCAL`, `FT_BASE`, and `FT_EXPORT`
* instead.
*/
#define FT_FUNCTION_DECLARATION( x ) extern x
/*
* Same as `FT_FUNCTION_DECLARATION`, but for function definitions instead.
*
* NOTE: Do not use directly. Use `FT_LOCAL_DEF`, `FT_BASE_DEF`, and
* `FT_EXPORT_DEF` instead.
*/
#ifdef __cplusplus
#define FT_FUNCTION_DEFINITION( x ) extern "C" x
#else
#define FT_FUNCTION_DEFINITION( x ) x
#endif
/*
* Use `FT_LOCAL` and `FT_LOCAL_DEF` to declare and define, respectively,
* an internal FreeType function that is only used by the sources of a
* single `src/module/` directory. This ensures that the functions are
* turned into static ones at build time, resulting in smaller and faster
* code.
*/
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
#define FT_LOCAL( x ) static x
#define FT_LOCAL_DEF( x ) static x
#else
#define FT_LOCAL( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \
FT_FUNCTION_DECLARATION( x )
#define FT_LOCAL_DEF( x ) FT_FUNCTION_DEFINITION( x )
#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
/*
* Use `FT_LOCAL_ARRAY` and `FT_LOCAL_ARRAY_DEF` to declare and define,
* respectively, a constant array that must be accessed from several
* sources in the same `src/module/` sub-directory, and which are internal
* to the library.
*/
#define FT_LOCAL_ARRAY( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \
extern const x
#define FT_LOCAL_ARRAY_DEF( x ) FT_FUNCTION_DEFINITION( const x )
/*
* `Use FT_BASE` and `FT_BASE_DEF` to declare and define, respectively, an
* internal library function that is used by more than a single module.
*/
#define FT_BASE( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \
FT_FUNCTION_DECLARATION( x )
#define FT_BASE_DEF( x ) FT_FUNCTION_DEFINITION( x )
/*
* NOTE: Conditionally define `FT_EXPORT_VAR` due to its definition in
* `src/smooth/ftgrays.h` to make the header more portable.
*/
#ifndef FT_EXPORT_VAR
#define FT_EXPORT_VAR( x ) FT_FUNCTION_DECLARATION( x )
#endif
/*
* When compiling FreeType as a DLL or DSO with hidden visibility,
* some systems/compilers need a special attribute in front OR after
* the return type of function declarations.
*
* Two macros are used within the FreeType source code to define
* exported library functions: `FT_EXPORT` and `FT_EXPORT_DEF`.
*
* - `FT_EXPORT( return_type )`
*
* is used in a function declaration, as in
*
* ```
* FT_EXPORT( FT_Error )
* FT_Init_FreeType( FT_Library* alibrary );
* ```
*
* - `FT_EXPORT_DEF( return_type )`
*
* is used in a function definition, as in
*
* ```
* FT_EXPORT_DEF( FT_Error )
* FT_Init_FreeType( FT_Library* alibrary )
* {
* ... some code ...
* return FT_Err_Ok;
* }
* ```
*
* You can provide your own implementation of `FT_EXPORT` and
* `FT_EXPORT_DEF` here if you want.
*
* To export a variable, use `FT_EXPORT_VAR`.
*/
/* See `freetype/config/public-macros.h` for the `FT_EXPORT` definition */
#define FT_EXPORT_DEF( x ) FT_FUNCTION_DEFINITION( x )
/*
* The following macros are needed to compile the library with a
* C++ compiler and with 16bit compilers.
*/
/*
* This is special. Within C++, you must specify `extern "C"` for
* functions which are used via function pointers, and you also
* must do that for structures which contain function pointers to
* assure C linkage -- it's not possible to have (local) anonymous
* functions which are accessed by (global) function pointers.
*
*
* FT_CALLBACK_DEF is used to _define_ a callback function,
* located in the same source code file as the structure that uses
* it. FT_COMPARE_DEF, in addition, ensures the `cdecl` calling
* convention on x86, required by the C library function `qsort`.
*
* FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare
* and define a callback function, respectively, in a similar way
* as FT_BASE and FT_BASE_DEF work.
*
* FT_CALLBACK_TABLE is used to _declare_ a constant variable that
* contains pointers to callback functions.
*
* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable
* that contains pointers to callback functions.
*
*
* Some 16bit compilers have to redefine these macros to insert
* the infamous `_cdecl` or `__fastcall` declarations.
*/
#ifdef __cplusplus
#define FT_CALLBACK_DEF( x ) extern "C" x
#else
#define FT_CALLBACK_DEF( x ) static x
#endif
#if defined( __GNUC__ ) && defined( __i386__ )
#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __attribute__(( cdecl ))
#elif defined( _MSC_VER ) && defined( _M_IX86 )
#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __cdecl
#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1240
#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __watcall
#else
#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x )
#endif
#define FT_BASE_CALLBACK( x ) FT_FUNCTION_DECLARATION( x )
#define FT_BASE_CALLBACK_DEF( x ) FT_FUNCTION_DEFINITION( x )
#ifndef FT_CALLBACK_TABLE
#ifdef __cplusplus
#define FT_CALLBACK_TABLE extern "C"
#define FT_CALLBACK_TABLE_DEF extern "C"
#else
#define FT_CALLBACK_TABLE extern
#define FT_CALLBACK_TABLE_DEF /* nothing */
#endif
#endif /* FT_CALLBACK_TABLE */
FT_END_HEADER
#endif /* INTERNAL_COMPILER_MACROS_H_ */
/****************************************************************************
*
* ftcalc.h
*
* Arithmetic computations (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTCALC_H_
#define FTCALC_H_
#include <freetype/freetype.h>
#include "compiler-macros.h"
FT_BEGIN_HEADER
/**************************************************************************
*
* FT_MulDiv() and FT_MulFix() are declared in freetype.h.
*
*/
#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
/* Provide assembler fragments for performance-critical functions. */
/* These must be defined `static __inline__' with GCC. */
#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */
#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
/* documentation is in freetype.h */
static __inline FT_Int32
FT_MulFix_arm( FT_Int32 a,
FT_Int32 b )
{
FT_Int32 t, t2;
__asm
{
smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
mov a, t, asr #31 /* a = (hi >> 31) */
add a, a, #0x8000 /* a += 0x8000 */
adds t2, t2, a /* t2 += a */
adc t, t, #0 /* t += carry */
mov a, t2, lsr #16 /* a = t2 >> 16 */
orr a, a, t, lsl #16 /* a |= t << 16 */
}
return a;
}
#endif /* __CC_ARM || __ARMCC__ */
#ifdef __GNUC__
#if defined( __arm__ ) && \
( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \
!( defined( __CC_ARM ) || defined( __ARMCC__ ) )
#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
/* documentation is in freetype.h */
static __inline__ FT_Int32
FT_MulFix_arm( FT_Int32 a,
FT_Int32 b )
{
FT_Int32 t, t2;
__asm__ __volatile__ (
"smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
"mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
#if defined( __clang__ ) && defined( __thumb2__ )
"add.w %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
#else
"add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */
#endif
"adds %1, %1, %0\n\t" /* %1 += %0 */
"adc %2, %2, #0\n\t" /* %2 += carry */
"mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */
"orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
: "=r"(a), "=&r"(t2), "=&r"(t)
: "r"(a), "r"(b)
: "cc" );
return a;
}
#endif /* __arm__ && */
/* ( __thumb2__ || !__thumb__ ) && */
/* !( __CC_ARM || __ARMCC__ ) */
#if defined( __i386__ )
#define FT_MULFIX_ASSEMBLER FT_MulFix_i386
/* documentation is in freetype.h */
static __inline__ FT_Int32
FT_MulFix_i386( FT_Int32 a,
FT_Int32 b )
{
FT_Int32 result;
__asm__ __volatile__ (
"imul %%edx\n"
"movl %%edx, %%ecx\n"
"sarl $31, %%ecx\n"
"addl $0x8000, %%ecx\n"
"addl %%ecx, %%eax\n"
"adcl $0, %%edx\n"
"shrl $16, %%eax\n"
"shll $16, %%edx\n"
"addl %%edx, %%eax\n"
: "=a"(result), "=d"(b)
: "a"(a), "d"(b)
: "%ecx", "cc" );
return result;
}
#endif /* i386 */
#endif /* __GNUC__ */
#ifdef _MSC_VER /* Visual C++ */
#ifdef _M_IX86
#define FT_MULFIX_ASSEMBLER FT_MulFix_i386
/* documentation is in freetype.h */
static __inline FT_Int32
FT_MulFix_i386( FT_Int32 a,
FT_Int32 b )
{
FT_Int32 result;
__asm
{
mov eax, a
mov edx, b
imul edx
mov ecx, edx
sar ecx, 31
add ecx, 8000h
add eax, ecx
adc edx, 0
shr eax, 16
shl edx, 16
add eax, edx
mov result, eax
}
return result;
}
#endif /* _M_IX86 */
#endif /* _MSC_VER */
#if defined( __GNUC__ ) && defined( __x86_64__ )
#define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64
static __inline__ FT_Int32
FT_MulFix_x86_64( FT_Int32 a,
FT_Int32 b )
{
/* Temporarily disable the warning that C90 doesn't support */
/* `long long'. */
#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlong-long"
#endif
#if 1
/* Technically not an assembly fragment, but GCC does a really good */
/* job at inlining it and generating good machine code for it. */
long long ret, tmp;
ret = (long long)a * b;
tmp = ret >> 63;
ret += 0x8000 + tmp;
return (FT_Int32)( ret >> 16 );
#else
/* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */
/* code from the lines below. The main issue is that `wide_a' is not */
/* properly initialized by sign-extending `a'. Instead, the generated */
/* machine code assumes that the register that contains `a' on input */
/* can be used directly as a 64-bit value, which is wrong most of the */
/* time. */
long long wide_a = (long long)a;
long long wide_b = (long long)b;
long long result;
__asm__ __volatile__ (
"imul %2, %1\n"
"mov %1, %0\n"
"sar $63, %0\n"
"lea 0x8000(%1, %0), %0\n"
"sar $16, %0\n"
: "=&r"(result), "=&r"(wide_a)
: "r"(wide_b)
: "cc" );
return (FT_Int32)result;
#endif
#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
#pragma GCC diagnostic pop
#endif
}
#endif /* __GNUC__ && __x86_64__ */
#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
#ifdef FT_MULFIX_ASSEMBLER
#define FT_MulFix( a, b ) FT_MULFIX_ASSEMBLER( (FT_Int32)(a), (FT_Int32)(b) )
#endif
#endif
/**************************************************************************
*
* @function:
* FT_MulDiv_No_Round
*
* @description:
* A very simple function used to perform the computation '(a*b)/c'
* (without rounding) with maximum accuracy (it uses a 64-bit
* intermediate integer whenever necessary).
*
* This function isn't necessarily as fast as some processor-specific
* operations, but is at least completely portable.
*
* @input:
* a ::
* The first multiplier.
* b ::
* The second multiplier.
* c ::
* The divisor.
*
* @return:
* The result of '(a*b)/c'. This function never traps when trying to
* divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on
* the signs of 'a' and 'b'.
*/
FT_BASE( FT_Long )
FT_MulDiv_No_Round( FT_Long a,
FT_Long b,
FT_Long c );
/**************************************************************************
*
* @function:
* FT_MulAddFix
*
* @description:
* Compute `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`, where `s[n]` is
* usually a 16.16 scalar.
*
* @input:
* s ::
* The array of scalars.
* f ::
* The array of factors.
* count ::
* The number of entries in the array.
*
* @return:
* The result of `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`.
*
* @note:
* This function is currently used for the scaled delta computation of
* variation stores. It internally uses 64-bit data types when
* available, otherwise it emulates 64-bit math by using 32-bit
* operations, which produce a correct result but most likely at a slower
* performance in comparison to the implementation base on `int64_t`.
*
*/
FT_BASE( FT_Int32 )
FT_MulAddFix( FT_Fixed* s,
FT_Int32* f,
FT_UInt count );
/*
* A variant of FT_Matrix_Multiply which scales its result afterwards. The
* idea is that both `a' and `b' are scaled by factors of 10 so that the
* values are as precise as possible to get a correct result during the
* 64bit multiplication. Let `sa' and `sb' be the scaling factors of `a'
* and `b', respectively, then the scaling factor of the result is `sa*sb'.
*/
FT_BASE( void )
FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
FT_Matrix *b,
FT_Long scaling );
/*
* Check a matrix. If the transformation would lead to extreme shear or
* extreme scaling, for example, return 0. If everything is OK, return 1.
*
* Based on geometric considerations we use the following inequality to
* identify a degenerate matrix.
*
* 32 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2
*
* Value 32 is heuristic.
*/
FT_BASE( FT_Bool )
FT_Matrix_Check( const FT_Matrix* matrix );
/*
* A variant of FT_Vector_Transform. See comments for
* FT_Matrix_Multiply_Scaled.
*/
FT_BASE( void )
FT_Vector_Transform_Scaled( FT_Vector* vector,
const FT_Matrix* matrix,
FT_Long scaling );
/*
* This function normalizes a vector and returns its original length. The
* normalized vector is a 16.16 fixed-point unit vector with length close
* to 0x10000. The accuracy of the returned length is limited to 16 bits
* also. The function utilizes quick inverse square root approximation
* without divisions and square roots relying on Newton's iterations
* instead.
*/
FT_BASE( FT_UInt32 )
FT_Vector_NormLen( FT_Vector* vector );
/*
* Return -1, 0, or +1, depending on the orientation of a given corner. We
* use the Cartesian coordinate system, with positive vertical values going
* upwards. The function returns +1 if the corner turns to the left, -1 to
* the right, and 0 for undecidable cases.
*/
FT_BASE( FT_Int )
ft_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y );
/*
* Return TRUE if a corner is flat or nearly flat. This is equivalent to
* saying that the corner point is close to its neighbors, or inside an
* ellipse defined by the neighbor focal points to be more precise.
*/
FT_BASE( FT_Int )
ft_corner_is_flat( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y );
/*
* Return the most significant bit index.
*/
#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
#if defined( __clang__ ) || ( defined( __GNUC__ ) && \
( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) ) )
#if FT_SIZEOF_INT == 4
#define FT_MSB( x ) ( 31 - __builtin_clz( x ) )
#elif FT_SIZEOF_LONG == 4
#define FT_MSB( x ) ( 31 - __builtin_clzl( x ) )
#endif
#elif defined( _MSC_VER ) && _MSC_VER >= 1400
#if defined( _WIN32_WCE )
#include <cmnintrin.h>
#pragma intrinsic( _CountLeadingZeros )
#define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) )
#elif defined( _M_ARM64 ) || defined( _M_ARM ) || defined( _M_ARM64EC )
#include <intrin.h>
#pragma intrinsic( _CountLeadingZeros )
#define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) )
#elif defined( _M_IX86 ) || defined( _M_AMD64 ) || defined( _M_IA64 )
#include <intrin.h>
#pragma intrinsic( _BitScanReverse )
static __inline FT_Int32
FT_MSB_i386( FT_UInt32 x )
{
unsigned long where;
_BitScanReverse( &where, x );
return (FT_Int32)where;
}
#define FT_MSB( x ) FT_MSB_i386( x )
#endif
#elif defined( __WATCOMC__ ) && defined( __386__ )
extern __inline FT_Int32
FT_MSB_i386( FT_UInt32 x );
#pragma aux FT_MSB_i386 = \
"bsr eax, eax" \
__parm [__eax] __nomemory \
__value [__eax] \
__modify __exact [__eax] __nomemory;
#define FT_MSB( x ) FT_MSB_i386( x )
#elif defined( __SunOS_5_11 )
#include <string.h>
#define FT_MSB( x ) ( fls( x ) - 1 )
#elif defined( __DECC ) || defined( __DECCXX )
#include <builtins.h>
#define FT_MSB( x ) (FT_Int)( 63 - _leadz( x ) )
#elif defined( _CRAYC )
#include <intrinsics.h>
#define FT_MSB( x ) (FT_Int)( 31 - _leadz32( x ) )
#endif /* FT_MSB macro definitions */
#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
#ifndef FT_MSB
FT_BASE( FT_Int )
FT_MSB( FT_UInt32 z );
#endif
/*
* Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
* two fixed-point arguments instead.
*/
FT_BASE( FT_Fixed )
FT_Hypot( FT_Fixed x,
FT_Fixed y );
/**************************************************************************
*
* @function:
* FT_SqrtFixed
*
* @description:
* Computes the square root of a 16.16 fixed-point value.
*
* @input:
* x ::
* The value to compute the root for.
*
* @return:
* The result of 'sqrt(x)'.
*
* @note:
* This function is slow and should be avoided. Consider @FT_Hypot or
* @FT_Vector_NormLen instead.
*/
FT_BASE( FT_UInt32 )
FT_SqrtFixed( FT_UInt32 x );
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) * 16384 ) /* << 14 */
#define INT_TO_FIXED( x ) ( (FT_Long)(x) * 65536 ) /* << 16 */
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) * 4 ) /* << 2 */
#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
#define ROUND_F26DOT6( x ) ( ( (x) + 32 - ( x < 0 ) ) & -64 )
/*
* The following macros have two purposes.
*
* - Tag places where overflow is expected and harmless.
*
* - Avoid run-time sanitizer errors.
*
* Use with care!
*/
#define ADD_INT( a, b ) \
(FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) )
#define SUB_INT( a, b ) \
(FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) )
#define MUL_INT( a, b ) \
(FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) )
#define NEG_INT( a ) \
(FT_Int)( (FT_UInt)0 - (FT_UInt)(a) )
#define ADD_LONG( a, b ) \
(FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) )
#define SUB_LONG( a, b ) \
(FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) )
#define MUL_LONG( a, b ) \
(FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) )
#define NEG_LONG( a ) \
(FT_Long)( (FT_ULong)0 - (FT_ULong)(a) )
#define ADD_INT32( a, b ) \
(FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) )
#define SUB_INT32( a, b ) \
(FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) )
#define MUL_INT32( a, b ) \
(FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) )
#define NEG_INT32( a ) \
(FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) )
#ifdef FT_INT64
#define ADD_INT64( a, b ) \
(FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) )
#define SUB_INT64( a, b ) \
(FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) )
#define MUL_INT64( a, b ) \
(FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) )
#define NEG_INT64( a ) \
(FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) )
#endif /* FT_INT64 */
FT_END_HEADER
#endif /* FTCALC_H_ */
/* END */
/****************************************************************************
*
* ftdebug.h
*
* Debugging and logging component (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*
* IMPORTANT: A description of FreeType's debugging support can be
* found in 'docs/DEBUG.TXT'. Read it if you need to use or
* understand this code.
*
*/
#ifndef FTDEBUG_H_
#define FTDEBUG_H_
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include <freetype/freetype.h>
#include "compiler-macros.h"
#ifdef FT_DEBUG_LOGGING
#define DLG_STATIC
#include <dlg/output.h>
#include <dlg/dlg.h>
#include <freetype/ftlogging.h>
#endif /* FT_DEBUG_LOGGING */
FT_BEGIN_HEADER
/* force the definition of FT_DEBUG_LEVEL_TRACE if FT_DEBUG_LOGGING is */
/* already defined. */
/* */
#ifdef FT_DEBUG_LOGGING
#undef FT_DEBUG_LEVEL_TRACE
#define FT_DEBUG_LEVEL_TRACE
#endif
/* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
/* is already defined; this simplifies the following #ifdefs */
/* */
#ifdef FT_DEBUG_LEVEL_TRACE
#undef FT_DEBUG_LEVEL_ERROR
#define FT_DEBUG_LEVEL_ERROR
#endif
/**************************************************************************
*
* Define the trace enums as well as the trace levels array when they are
* needed.
*
*/
#ifdef FT_DEBUG_LEVEL_TRACE
#define FT_TRACE_DEF( x ) trace_ ## x ,
/* defining the enumeration */
typedef enum FT_Trace_
{
#include <freetype/internal/fttrace.h>
trace_count
} FT_Trace;
/* a pointer to the array of trace levels, */
/* provided by `src/base/ftdebug.c' */
extern int* ft_trace_levels;
#undef FT_TRACE_DEF
#endif /* FT_DEBUG_LEVEL_TRACE */
/**************************************************************************
*
* Define the FT_TRACE macro
*
* IMPORTANT!
*
* Each component must define the macro FT_COMPONENT to a valid FT_Trace
* value before using any TRACE macro.
*
* To get consistent logging output, there should be no newline character
* (i.e., '\n') or a single trailing one in the message string of
* `FT_TRACEx` and `FT_ERROR`.
*/
/*************************************************************************
*
* If FT_DEBUG_LOGGING is enabled, tracing messages are sent to dlg's API.
* If FT_DEBUG_LOGGING is disabled, tracing messages are sent to
* `FT_Message` (defined in ftdebug.c).
*/
#ifdef FT_DEBUG_LOGGING
/* we need two macros to convert the names of `FT_COMPONENT` to a string */
#define FT_LOGGING_TAG( x ) FT_LOGGING_TAG_( x )
#define FT_LOGGING_TAG_( x ) #x
/* we need two macros to convert the component and the trace level */
/* to a string that combines them */
#define FT_LOGGING_TAGX( x, y ) FT_LOGGING_TAGX_( x, y )
#define FT_LOGGING_TAGX_( x, y ) #x ":" #y
#define FT_LOG( level, varformat ) \
do \
{ \
const char* dlg_tag = FT_LOGGING_TAGX( FT_COMPONENT, level ); \
\
\
ft_add_tag( dlg_tag ); \
if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
{ \
if ( custom_output_handler != NULL ) \
FT_Logging_Callback varformat; \
else \
dlg_trace varformat; \
} \
ft_remove_tag( dlg_tag ); \
} while( 0 )
#else /* !FT_DEBUG_LOGGING */
#define FT_LOG( level, varformat ) \
do \
{ \
if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
FT_Message varformat; \
} while ( 0 )
#endif /* !FT_DEBUG_LOGGING */
#ifdef FT_DEBUG_LEVEL_TRACE
/* we need two macros here to make cpp expand `FT_COMPONENT' */
#define FT_TRACE_COMP( x ) FT_TRACE_COMP_( x )
#define FT_TRACE_COMP_( x ) trace_ ## x
#define FT_TRACE( level, varformat ) FT_LOG( level, varformat )
#else /* !FT_DEBUG_LEVEL_TRACE */
#define FT_TRACE( level, varformat ) do { } while ( 0 ) /* nothing */
#endif /* !FT_DEBUG_LEVEL_TRACE */
/**************************************************************************
*
* @function:
* FT_Trace_Get_Count
*
* @description:
* Return the number of available trace components.
*
* @return:
* The number of trace components. 0 if FreeType 2 is not built with
* FT_DEBUG_LEVEL_TRACE definition.
*
* @note:
* This function may be useful if you want to access elements of the
* internal trace levels array by an index.
*/
FT_BASE( FT_Int )
FT_Trace_Get_Count( void );
/**************************************************************************
*
* @function:
* FT_Trace_Get_Name
*
* @description:
* Return the name of a trace component.
*
* @input:
* The index of the trace component.
*
* @return:
* The name of the trace component. This is a statically allocated
* C~string, so do not free it after use. `NULL` if FreeType is not
* built with FT_DEBUG_LEVEL_TRACE definition.
*
* @note:
* Use @FT_Trace_Get_Count to get the number of available trace
* components.
*/
FT_BASE( const char* )
FT_Trace_Get_Name( FT_Int idx );
/**************************************************************************
*
* @function:
* FT_Trace_Disable
*
* @description:
* Switch off tracing temporarily. It can be activated again with
* @FT_Trace_Enable.
*/
FT_BASE( void )
FT_Trace_Disable( void );
/**************************************************************************
*
* @function:
* FT_Trace_Enable
*
* @description:
* Activate tracing. Use it after tracing has been switched off with
* @FT_Trace_Disable.
*/
FT_BASE( void )
FT_Trace_Enable( void );
/**************************************************************************
*
* You need two opening and closing parentheses!
*
* Example: FT_TRACE0(( "Value is %i", foo ))
*
* Output of the FT_TRACEX macros is sent to stderr.
*
*/
#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat )
#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat )
#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat )
#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat )
#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
/**************************************************************************
*
* Define the FT_ERROR macro.
*
* Output of this macro is sent to stderr.
*
*/
#ifdef FT_DEBUG_LEVEL_ERROR
/**************************************************************************
*
* If FT_DEBUG_LOGGING is enabled, error messages are sent to dlg's API.
* If FT_DEBUG_LOGGING is disabled, error messages are sent to `FT_Message`
* (defined in ftdebug.c).
*
*/
#ifdef FT_DEBUG_LOGGING
#define FT_ERROR( varformat ) \
do \
{ \
const char* dlg_tag = FT_LOGGING_TAG( FT_COMPONENT ); \
\
\
ft_add_tag( dlg_tag ); \
dlg_trace varformat; \
ft_remove_tag( dlg_tag ); \
} while ( 0 )
#else /* !FT_DEBUG_LOGGING */
#define FT_ERROR( varformat ) FT_Message varformat
#endif /* !FT_DEBUG_LOGGING */
#else /* !FT_DEBUG_LEVEL_ERROR */
#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */
#endif /* !FT_DEBUG_LEVEL_ERROR */
/**************************************************************************
*
* Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw` makes
* it possible to easily set a breakpoint at this function.
*
*/
#ifdef FT_DEBUG_LEVEL_ERROR
#define FT_ASSERT( condition ) \
do \
{ \
if ( !( condition ) ) \
FT_Panic( "assertion failed on line %d of file %s\n", \
__LINE__, __FILE__ ); \
} while ( 0 )
#define FT_THROW( e ) \
( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ), \
__LINE__, \
__FILE__ ) | \
FT_ERR_CAT( FT_ERR_PREFIX, e ) )
#else /* !FT_DEBUG_LEVEL_ERROR */
#define FT_ASSERT( condition ) do { } while ( 0 )
#define FT_THROW( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
#endif /* !FT_DEBUG_LEVEL_ERROR */
/**************************************************************************
*
* Define `FT_Message` and `FT_Panic` when needed.
*
*/
#ifdef FT_DEBUG_LEVEL_ERROR
#include "stdio.h" /* for vfprintf() */
/* print a message */
FT_BASE( void )
FT_Message( const char* fmt,
... );
/* print a message and exit */
FT_BASE( void )
FT_Panic( const char* fmt,
... );
/* report file name and line number of an error */
FT_BASE( int )
FT_Throw( FT_Error error,
int line,
const char* file );
#endif /* FT_DEBUG_LEVEL_ERROR */
FT_BASE( void )
ft_debug_init( void );
#ifdef FT_DEBUG_LOGGING
/**************************************************************************
*
* 'dlg' uses output handlers to control how and where log messages are
* printed. Therefore we need to define a default output handler for
* FreeType.
*/
FT_BASE( void )
ft_log_handler( const struct dlg_origin* origin,
const char* string,
void* data );
/**************************************************************************
*
* 1. `ft_default_log_handler` stores the function pointer that is used
* internally by FreeType to print logs to a file.
*
* 2. `custom_output_handler` stores the function pointer to the callback
* function provided by the user.
*
* It is defined in `ftdebug.c`.
*/
extern dlg_handler ft_default_log_handler;
extern FT_Custom_Log_Handler custom_output_handler;
/**************************************************************************
*
* If FT_DEBUG_LOGGING macro is enabled, FreeType needs to initialize and
* un-initialize `FILE*`.
*
* These functions are defined in `ftdebug.c`.
*/
FT_BASE( void )
ft_logging_init( void );
FT_BASE( void )
ft_logging_deinit( void );
/**************************************************************************
*
* For printing the name of `FT_COMPONENT` along with the actual log we
* need to add a tag with the name of `FT_COMPONENT`.
*
* These functions are defined in `ftdebug.c`.
*/
FT_BASE( void )
ft_add_tag( const char* tag );
FT_BASE( void )
ft_remove_tag( const char* tag );
/**************************************************************************
*
* A function to print log data using a custom callback logging function
* (which is set using `FT_Set_Log_Handler`).
*
* This function is defined in `ftdebug.c`.
*/
FT_BASE( void )
FT_Logging_Callback( const char* fmt,
... );
#endif /* FT_DEBUG_LOGGING */
FT_END_HEADER
#endif /* FTDEBUG_H_ */
/* END */
/****************************************************************************
*
* ftdrv.h
*
* FreeType internal font driver interface (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTDRV_H_
#define FTDRV_H_
#include <freetype/ftmodapi.h>
#include "compiler-macros.h"
FT_BEGIN_HEADER
typedef FT_Error
(*FT_Face_InitFunc)( FT_Stream stream,
FT_Face face,
FT_Int typeface_index,
FT_Int num_params,
FT_Parameter* parameters );
typedef void
(*FT_Face_DoneFunc)( FT_Face face );
typedef FT_Error
(*FT_Size_InitFunc)( FT_Size size );
typedef void
(*FT_Size_DoneFunc)( FT_Size size );
typedef FT_Error
(*FT_Slot_InitFunc)( FT_GlyphSlot slot );
typedef void
(*FT_Slot_DoneFunc)( FT_GlyphSlot slot );
typedef FT_Error
(*FT_Size_RequestFunc)( FT_Size size,
FT_Size_Request req );
typedef FT_Error
(*FT_Size_SelectFunc)( FT_Size size,
FT_ULong size_index );
typedef FT_Error
(*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags );
typedef FT_Error
(*FT_Face_GetKerningFunc)( FT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning );
typedef FT_Error
(*FT_Face_AttachFunc)( FT_Face face,
FT_Stream stream );
typedef FT_Error
(*FT_Face_GetAdvancesFunc)( FT_Face face,
FT_UInt first,
FT_UInt count,
FT_Int32 flags,
FT_Fixed* advances );
/**************************************************************************
*
* @struct:
* FT_Driver_ClassRec
*
* @description:
* The font driver class. This structure mostly contains pointers to
* driver methods.
*
* @fields:
* root ::
* The parent module.
*
* face_object_size ::
* The size of a face object in bytes.
*
* size_object_size ::
* The size of a size object in bytes.
*
* slot_object_size ::
* The size of a glyph object in bytes.
*
* init_face ::
* The format-specific face constructor.
*
* done_face ::
* The format-specific face destructor.
*
* init_size ::
* The format-specific size constructor.
*
* done_size ::
* The format-specific size destructor.
*
* init_slot ::
* The format-specific slot constructor.
*
* done_slot ::
* The format-specific slot destructor.
*
*
* load_glyph ::
* A function handle to load a glyph to a slot. This field is
* mandatory!
*
* get_kerning ::
* A function handle to return the unscaled kerning for a given pair of
* glyphs. Can be set to 0 if the format doesn't support kerning.
*
* attach_file ::
* This function handle is used to read additional data for a face from
* another file/stream. For example, this can be used to add data from
* AFM or PFM files on a Type 1 face, or a CIDMap on a CID-keyed face.
*
* get_advances ::
* A function handle used to return advance widths of 'count' glyphs
* (in font units), starting at 'first'. The 'vertical' flag must be
* set to get vertical advance heights. The 'advances' buffer is
* caller-allocated. The idea of this function is to be able to
* perform device-independent text layout without loading a single
* glyph image.
*
* request_size ::
* A handle to a function used to request the new character size. Can
* be set to 0 if the scaling done in the base layer suffices.
*
* select_size ::
* A handle to a function used to select a new fixed size. It is used
* only if @FT_FACE_FLAG_FIXED_SIZES is set. Can be set to 0 if the
* scaling done in the base layer suffices.
*
* @note:
* Most function pointers, with the exception of `load_glyph`, can be set
* to 0 to indicate a default behaviour.
*/
typedef struct FT_Driver_ClassRec_
{
FT_Module_Class root;
FT_Long face_object_size;
FT_Long size_object_size;
FT_Long slot_object_size;
FT_Face_InitFunc init_face;
FT_Face_DoneFunc done_face;
FT_Size_InitFunc init_size;
FT_Size_DoneFunc done_size;
FT_Slot_InitFunc init_slot;
FT_Slot_DoneFunc done_slot;
FT_Slot_LoadFunc load_glyph;
FT_Face_GetKerningFunc get_kerning;
FT_Face_AttachFunc attach_file;
FT_Face_GetAdvancesFunc get_advances;
/* since version 2.2 */
FT_Size_RequestFunc request_size;
FT_Size_SelectFunc select_size;
} FT_Driver_ClassRec, *FT_Driver_Class;
/**************************************************************************
*
* @macro:
* FT_DECLARE_DRIVER
*
* @description:
* Used to create a forward declaration of an FT_Driver_ClassRec struct
* instance.
*
* @macro:
* FT_DEFINE_DRIVER
*
* @description:
* Used to initialize an instance of FT_Driver_ClassRec struct.
*
* `ftinit.c` (ft_create_default_module_classes) already contains a
* mechanism to call these functions for the default modules described in
* `ftmodule.h`.
*
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*/
#define FT_DECLARE_DRIVER( class_ ) \
FT_CALLBACK_TABLE \
const FT_Driver_ClassRec class_;
#define FT_DEFINE_DRIVER( \
class_, \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_, \
face_object_size_, \
size_object_size_, \
slot_object_size_, \
init_face_, \
done_face_, \
init_size_, \
done_size_, \
init_slot_, \
done_slot_, \
load_glyph_, \
get_kerning_, \
attach_file_, \
get_advances_, \
request_size_, \
select_size_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_Driver_ClassRec class_ = \
{ \
FT_DEFINE_ROOT_MODULE( flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
\
face_object_size_, \
size_object_size_, \
slot_object_size_, \
\
init_face_, \
done_face_, \
\
init_size_, \
done_size_, \
\
init_slot_, \
done_slot_, \
\
load_glyph_, \
\
get_kerning_, \
attach_file_, \
get_advances_, \
\
request_size_, \
select_size_ \
};
FT_END_HEADER
#endif /* FTDRV_H_ */
/* END */
/****************************************************************************
*
* ftgloadr.h
*
* The FreeType glyph loader (specification).
*
* Copyright (C) 2002-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTGLOADR_H_
#define FTGLOADR_H_
#include <freetype/freetype.h>
#include "compiler-macros.h"
FT_BEGIN_HEADER
/**************************************************************************
*
* @struct:
* FT_GlyphLoader
*
* @description:
* The glyph loader is an internal object used to load several glyphs
* together (for example, in the case of composites).
*/
typedef struct FT_SubGlyphRec_
{
FT_Int index;
FT_UShort flags;
FT_Int arg1;
FT_Int arg2;
FT_Matrix transform;
} FT_SubGlyphRec;
typedef struct FT_GlyphLoadRec_
{
FT_Outline outline; /* outline */
FT_Vector* extra_points; /* extra points table */
FT_Vector* extra_points2; /* second extra points table */
FT_UInt num_subglyphs; /* number of subglyphs */
FT_SubGlyph subglyphs; /* subglyphs */
} FT_GlyphLoadRec, *FT_GlyphLoad;
typedef struct FT_GlyphLoaderRec_
{
FT_Memory memory;
FT_UInt max_points;
FT_UInt max_contours;
FT_UInt max_subglyphs;
FT_Bool use_extra;
FT_GlyphLoadRec base;
FT_GlyphLoadRec current;
void* other; /* for possible future extension? */
} FT_GlyphLoaderRec, *FT_GlyphLoader;
/* create new empty glyph loader */
FT_BASE( FT_Error )
FT_GlyphLoader_New( FT_Memory memory,
FT_GlyphLoader *aloader );
/* add an extra points table to a glyph loader */
FT_BASE( FT_Error )
FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader );
/* destroy a glyph loader */
FT_BASE( void )
FT_GlyphLoader_Done( FT_GlyphLoader loader );
/* reset a glyph loader (frees everything int it) */
FT_BASE( void )
FT_GlyphLoader_Reset( FT_GlyphLoader loader );
/* rewind a glyph loader */
FT_BASE( void )
FT_GlyphLoader_Rewind( FT_GlyphLoader loader );
/* check that there is enough space to add `n_points' and `n_contours' */
/* to the glyph loader */
FT_BASE( FT_Error )
FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader,
FT_UInt n_points,
FT_UInt n_contours );
#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \
( (_count) == 0 || \
( (FT_UInt)(_loader)->base.outline.n_points + \
(FT_UInt)(_loader)->current.outline.n_points + \
(FT_UInt)(_count) ) <= (_loader)->max_points )
#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \
( (_count) == 0 || \
( (FT_UInt)(_loader)->base.outline.n_contours + \
(FT_UInt)(_loader)->current.outline.n_contours + \
(FT_UInt)(_count) ) <= (_loader)->max_contours )
#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \
( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \
FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \
? 0 \
: FT_GlyphLoader_CheckPoints( (_loader), \
(FT_UInt)(_points), \
(FT_UInt)(_contours) ) )
/* check that there is enough space to add `n_subs' sub-glyphs to */
/* a glyph loader */
FT_BASE( FT_Error )
FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader,
FT_UInt n_subs );
/* prepare a glyph loader, i.e. empty the current glyph */
FT_BASE( void )
FT_GlyphLoader_Prepare( FT_GlyphLoader loader );
/* add the current glyph to the base glyph */
FT_BASE( void )
FT_GlyphLoader_Add( FT_GlyphLoader loader );
FT_END_HEADER
#endif /* FTGLOADR_H_ */
/* END */
/****************************************************************************
*
* fthash.h
*
* Hashing functions (specification).
*
*/
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
* Copyright 2001-2015
* Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**************************************************************************
*
* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50
*
* taken from Mark Leisher's xmbdfed package
*
*/
#ifndef FTHASH_H_
#define FTHASH_H_
#include <freetype/freetype.h>
FT_BEGIN_HEADER
typedef union FT_Hashkey_
{
FT_Int num;
const char* str;
} FT_Hashkey;
typedef struct FT_HashnodeRec_
{
FT_Hashkey key;
size_t data;
} FT_HashnodeRec;
typedef struct FT_HashnodeRec_ *FT_Hashnode;
typedef FT_ULong
(*FT_Hash_LookupFunc)( FT_Hashkey* key );
typedef FT_Bool
(*FT_Hash_CompareFunc)( FT_Hashkey* a,
FT_Hashkey* b );
typedef struct FT_HashRec_
{
FT_UInt limit;
FT_UInt size;
FT_UInt used;
FT_Hash_LookupFunc lookup;
FT_Hash_CompareFunc compare;
FT_Hashnode* table;
} FT_HashRec;
typedef struct FT_HashRec_ *FT_Hash;
FT_Error
ft_hash_str_init( FT_Hash hash,
FT_Memory memory );
FT_Error
ft_hash_num_init( FT_Hash hash,
FT_Memory memory );
void
ft_hash_str_free( FT_Hash hash,
FT_Memory memory );
#define ft_hash_num_free ft_hash_str_free
FT_Error
ft_hash_str_insert( const char* key,
size_t data,
FT_Hash hash,
FT_Memory memory );
FT_Error
ft_hash_num_insert( FT_Int num,
size_t data,
FT_Hash hash,
FT_Memory memory );
size_t*
ft_hash_str_lookup( const char* key,
FT_Hash hash );
size_t*
ft_hash_num_lookup( FT_Int num,
FT_Hash hash );
FT_END_HEADER
#endif /* FTHASH_H_ */
/* END */
/****************************************************************************
*
* ftmemory.h
*
* The FreeType memory management macros (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTMEMORY_H_
#define FTMEMORY_H_
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include <freetype/fttypes.h>
#include "compiler-macros.h"
FT_BEGIN_HEADER
/**************************************************************************
*
* @macro:
* FT_SET_ERROR
*
* @description:
* This macro is used to set an implicit 'error' variable to a given
* expression's value (usually a function call), and convert it to a
* boolean which is set whenever the value is != 0.
*/
#undef FT_SET_ERROR
#define FT_SET_ERROR( expression ) \
( ( error = (expression) ) != 0 )
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** M E M O R Y ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* The calculation `NULL + n' is undefined in C. Even if the resulting */
/* pointer doesn't get dereferenced, this causes warnings with */
/* sanitizers. */
/* */
/* We thus provide a macro that should be used if `base' can be NULL. */
#define FT_OFFSET( base, count ) ( (base) ? (base) + (count) : NULL )
/*
* C++ refuses to handle statements like p = (void*)anything, with `p' a
* typed pointer. Since we don't have a `typeof' operator in standard C++,
* we have to use a template to emulate it.
*/
#ifdef __cplusplus
extern "C++"
{
template <typename T> inline T*
cplusplus_typeof( T*,
void *v )
{
return static_cast <T*> ( v );
}
}
#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) )
#else
#define FT_ASSIGNP( p, val ) (p) = (val)
#endif
#ifdef FT_DEBUG_MEMORY
FT_BASE( const char* ) ft_debug_file_;
FT_BASE( long ) ft_debug_lineno_;
#define FT_DEBUG_INNER( exp ) ( ft_debug_file_ = __FILE__, \
ft_debug_lineno_ = __LINE__, \
(exp) )
#define FT_ASSIGNP_INNER( p, exp ) ( ft_debug_file_ = __FILE__, \
ft_debug_lineno_ = __LINE__, \
FT_ASSIGNP( p, exp ) )
#else /* !FT_DEBUG_MEMORY */
#define FT_DEBUG_INNER( exp ) (exp)
#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp )
#endif /* !FT_DEBUG_MEMORY */
/*
* The allocation functions return a pointer, and the error code is written
* to through the `p_error' parameter.
*/
/* The `q' variants of the functions below (`q' for `quick') don't fill */
/* the allocated or reallocated memory with zero bytes. */
FT_BASE( FT_Pointer )
ft_mem_alloc( FT_Memory memory,
FT_Long size,
FT_Error *p_error );
FT_BASE( FT_Pointer )
ft_mem_qalloc( FT_Memory memory,
FT_Long size,
FT_Error *p_error );
FT_BASE( FT_Pointer )
ft_mem_realloc( FT_Memory memory,
FT_Long item_size,
FT_Long cur_count,
FT_Long new_count,
void* block,
FT_Error *p_error );
FT_BASE( FT_Pointer )
ft_mem_qrealloc( FT_Memory memory,
FT_Long item_size,
FT_Long cur_count,
FT_Long new_count,
void* block,
FT_Error *p_error );
FT_BASE( void )
ft_mem_free( FT_Memory memory,
const void* P );
/* The `Q' variants of the macros below (`Q' for `quick') don't fill */
/* the allocated or reallocated memory with zero bytes. */
#define FT_MEM_ALLOC( ptr, size ) \
FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \
(FT_Long)(size), \
&error ) )
#define FT_MEM_FREE( ptr ) \
FT_BEGIN_STMNT \
FT_DEBUG_INNER( ft_mem_free( memory, (ptr) ) ); \
(ptr) = NULL; \
FT_END_STMNT
#define FT_MEM_NEW( ptr ) \
FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) )
#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
1, \
(FT_Long)(cursz), \
(FT_Long)(newsz), \
(ptr), \
&error ) )
#define FT_MEM_QALLOC( ptr, size ) \
FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \
(FT_Long)(size), \
&error ) )
#define FT_MEM_QNEW( ptr ) \
FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) )
#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
1, \
(FT_Long)(cursz), \
(FT_Long)(newsz), \
(ptr), \
&error ) )
#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
(FT_Long)(item_size), \
0, \
(FT_Long)(count), \
NULL, \
&error ) )
#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
(FT_Long)(itmsz), \
(FT_Long)(oldcnt), \
(FT_Long)(newcnt), \
(ptr), \
&error ) )
#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
(FT_Long)(item_size), \
0, \
(FT_Long)(count), \
NULL, \
&error ) )
#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
(FT_Long)(itmsz), \
(FT_Long)(oldcnt), \
(FT_Long)(newcnt), \
(ptr), \
&error ) )
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 )
#define FT_MEM_SET( dest, byte, count ) \
ft_memset( dest, byte, (FT_Offset)(count) )
#define FT_MEM_COPY( dest, source, count ) \
ft_memcpy( dest, source, (FT_Offset)(count) )
#define FT_MEM_MOVE( dest, source, count ) \
ft_memmove( dest, source, (FT_Offset)(count) )
#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
#define FT_ARRAY_ZERO( dest, count ) \
FT_MEM_ZERO( dest, \
(FT_Offset)(count) * sizeof ( *(dest) ) )
#define FT_ARRAY_COPY( dest, source, count ) \
FT_MEM_COPY( dest, \
source, \
(FT_Offset)(count) * sizeof ( *(dest) ) )
#define FT_ARRAY_MOVE( dest, source, count ) \
FT_MEM_MOVE( dest, \
source, \
(FT_Offset)(count) * sizeof ( *(dest) ) )
/*
* Return the maximum number of addressable elements in an array. We limit
* ourselves to INT_MAX, rather than UINT_MAX, to avoid any problems.
*/
#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) )
#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) )
/**************************************************************************
*
* The following functions macros expect that their pointer argument is
* _typed_ in order to automatically compute array element sizes.
*/
#define FT_MEM_NEW_ARRAY( ptr, count ) \
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
sizeof ( *(ptr) ), \
0, \
(FT_Long)(count), \
NULL, \
&error ) )
#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
sizeof ( *(ptr) ), \
(FT_Long)(cursz), \
(FT_Long)(newsz), \
(ptr), \
&error ) )
#define FT_MEM_QNEW_ARRAY( ptr, count ) \
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
sizeof ( *(ptr) ), \
0, \
(FT_Long)(count), \
NULL, \
&error ) )
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \
sizeof ( *(ptr) ), \
(FT_Long)(cursz), \
(FT_Long)(newsz), \
(ptr), \
&error ) )
#define FT_ALLOC( ptr, size ) \
FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) )
#define FT_REALLOC( ptr, cursz, newsz ) \
FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) )
#define FT_ALLOC_MULT( ptr, count, item_size ) \
FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) )
#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \
newcnt, itmsz ) )
#define FT_QALLOC( ptr, size ) \
FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) )
#define FT_QREALLOC( ptr, cursz, newsz ) \
FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) )
#define FT_QALLOC_MULT( ptr, count, item_size ) \
FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) )
#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \
newcnt, itmsz ) )
#define FT_FREE( ptr ) FT_MEM_FREE( ptr )
#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) )
#define FT_NEW_ARRAY( ptr, count ) \
FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) )
#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \
FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) )
#define FT_QNEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) )
#define FT_QNEW_ARRAY( ptr, count ) \
FT_MEM_SET_ERROR( FT_MEM_QNEW_ARRAY( ptr, count ) )
#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \
FT_MEM_SET_ERROR( FT_MEM_QRENEW_ARRAY( ptr, curcnt, newcnt ) )
FT_BASE( FT_Pointer )
ft_mem_strdup( FT_Memory memory,
const char* str,
FT_Error *p_error );
FT_BASE( FT_Pointer )
ft_mem_dup( FT_Memory memory,
const void* address,
FT_ULong size,
FT_Error *p_error );
#define FT_MEM_STRDUP( dst, str ) \
(dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error )
#define FT_STRDUP( dst, str ) \
FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )
#define FT_MEM_DUP( dst, address, size ) \
FT_ASSIGNP_INNER( dst, ft_mem_dup( memory, \
(address), \
(FT_ULong)(size), \
&error ) )
#define FT_DUP( dst, address, size ) \
FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) )
/* Return >= 1 if a truncation occurs. */
/* Return 0 if the source string fits the buffer. */
/* This is *not* the same as strlcpy(). */
FT_BASE( FT_Int )
ft_mem_strcpyn( char* dst,
const char* src,
FT_ULong size );
#define FT_STRCPYN( dst, src, size ) \
ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) )
FT_END_HEADER
#endif /* FTMEMORY_H_ */
/* END */
/****************************************************************************
*
* ftmmtypes.h
*
* OpenType Variations type definitions for internal use
* with the multi-masters service (specification).
*
* Copyright (C) 2022-2024 by
* David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
* Dominik Röttsches.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTMMTYPES_H_
#define FTMMTYPES_H_
FT_BEGIN_HEADER
typedef FT_Int32 FT_ItemVarDelta;
typedef struct GX_ItemVarDataRec_
{
FT_UInt itemCount; /* Number of delta sets per item. */
FT_UInt regionIdxCount; /* Number of region indices. */
FT_UInt* regionIndices; /* Array of `regionCount` indices; */
/* these index `varRegionList`. */
FT_Byte* deltaSet; /* Array of `itemCount` deltas; */
/* use `innerIndex` for this array. */
FT_UShort wordDeltaCount; /* Number of the first 32-bit ints */
/* or 16-bit ints of `deltaSet` */
/* depending on `longWords`. */
FT_Bool longWords; /* If true, `deltaSet` is a 32-bit */
/* array followed by a 16-bit */
/* array, otherwise a 16-bit array */
/* followed by an 8-bit array. */
} GX_ItemVarDataRec, *GX_ItemVarData;
/* contribution of one axis to a region */
typedef struct GX_AxisCoordsRec_
{
FT_Fixed startCoord;
FT_Fixed peakCoord; /* zero means no effect (factor = 1) */
FT_Fixed endCoord;
} GX_AxisCoordsRec, *GX_AxisCoords;
typedef struct GX_VarRegionRec_
{
GX_AxisCoords axisList; /* array of axisCount records */
} GX_VarRegionRec, *GX_VarRegion;
/* item variation store */
typedef struct GX_ItemVarStoreRec_
{
FT_UInt dataCount;
GX_ItemVarData varData; /* array of dataCount records; */
/* use `outerIndex' for this array */
FT_UShort axisCount;
FT_UInt regionCount; /* total number of regions defined */
GX_VarRegion varRegionList;
} GX_ItemVarStoreRec, *GX_ItemVarStore;
typedef struct GX_DeltaSetIdxMapRec_
{
FT_ULong mapCount;
FT_UInt* outerIndex; /* indices to item var data */
FT_UInt* innerIndex; /* indices to delta set */
} GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap;
FT_END_HEADER
#endif /* FTMMTYPES_H_ */
/* END */
/****************************************************************************
*
* ftobjs.h
*
* The FreeType private base classes (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
/**************************************************************************
*
* This file contains the definition of all internal FreeType classes.
*
*/
#ifndef FTOBJS_H_
#define FTOBJS_H_
#include <freetype/ftrender.h>
#include <freetype/ftsizes.h>
#include <freetype/ftlcdfil.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftgloadr.h>
#include <freetype/internal/ftdrv.h>
#include <freetype/internal/autohint.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/ftcalc.h>
#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include <freetype/ftincrem.h>
#endif
#include "compiler-macros.h"
FT_BEGIN_HEADER
/**************************************************************************
*
* Some generic definitions.
*/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL (void*)0
#endif
/**************************************************************************
*
* The min and max functions missing in C. As usual, be careful not to
* write things like FT_MIN( a++, b++ ) to avoid side effects.
*/
#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
/*
* Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' algorithm.
* We use alpha = 1, beta = 3/8, giving us results with a largest error
* less than 7% compared to the exact value.
*/
#define FT_HYPOT( x, y ) \
( x = FT_ABS( x ), \
y = FT_ABS( y ), \
x > y ? x + ( 3 * y >> 3 ) \
: y + ( 3 * x >> 3 ) )
/* we use FT_TYPEOF to suppress signedness compilation warnings */
#define FT_PAD_FLOOR( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + (n) / 2, n )
#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + (n) - 1, n )
#define FT_PIX_FLOOR( x ) ( (x) & ~FT_TYPEOF( x )63 )
#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
/* specialized versions (for signed values) */
/* that don't produce run-time errors due to integer overflow */
#define FT_PAD_ROUND_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \
n )
#define FT_PAD_CEIL_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \
n )
#define FT_PIX_ROUND_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 32 ) )
#define FT_PIX_CEIL_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 63 ) )
#define FT_PAD_ROUND_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \
n )
#define FT_PAD_CEIL_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \
n )
#define FT_PIX_ROUND_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 32 ) )
#define FT_PIX_CEIL_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 63 ) )
/*
* character classification functions -- since these are used to parse font
* files, we must not use those in <ctypes.h> which are locale-dependent
*/
#define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U )
#define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \
( (unsigned)(x) - 'a' ) < 6U || \
( (unsigned)(x) - 'A' ) < 6U )
/* the next two macros assume ASCII representation */
#define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U )
#define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U )
#define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) )
#define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) )
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** C H A R M A P S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* handle to internal charmap object */
typedef struct FT_CMapRec_* FT_CMap;
/* handle to charmap class structure */
typedef const struct FT_CMap_ClassRec_* FT_CMap_Class;
/* internal charmap object structure */
typedef struct FT_CMapRec_
{
FT_CharMapRec charmap;
FT_CMap_Class clazz;
} FT_CMapRec;
/* typecast any pointer to a charmap handle */
#define FT_CMAP( x ) ( (FT_CMap)( x ) )
/* obvious macros */
#define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id
#define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id
#define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding
#define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face
/* class method definitions */
typedef FT_Error
(*FT_CMap_InitFunc)( FT_CMap cmap,
FT_Pointer init_data );
typedef void
(*FT_CMap_DoneFunc)( FT_CMap cmap );
typedef FT_UInt
(*FT_CMap_CharIndexFunc)( FT_CMap cmap,
FT_UInt32 char_code );
typedef FT_UInt
(*FT_CMap_CharNextFunc)( FT_CMap cmap,
FT_UInt32 *achar_code );
typedef FT_UInt
(*FT_CMap_CharVarIndexFunc)( FT_CMap cmap,
FT_CMap unicode_cmap,
FT_UInt32 char_code,
FT_UInt32 variant_selector );
typedef FT_Int
(*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap,
FT_UInt32 char_code,
FT_UInt32 variant_selector );
typedef FT_UInt32 *
(*FT_CMap_VariantListFunc)( FT_CMap cmap,
FT_Memory mem );
typedef FT_UInt32 *
(*FT_CMap_CharVariantListFunc)( FT_CMap cmap,
FT_Memory mem,
FT_UInt32 char_code );
typedef FT_UInt32 *
(*FT_CMap_VariantCharListFunc)( FT_CMap cmap,
FT_Memory mem,
FT_UInt32 variant_selector );
typedef struct FT_CMap_ClassRec_
{
FT_ULong size;
FT_CMap_InitFunc init;
FT_CMap_DoneFunc done;
FT_CMap_CharIndexFunc char_index;
FT_CMap_CharNextFunc char_next;
/* Subsequent entries are special ones for format 14 -- the variant */
/* selector subtable which behaves like no other */
FT_CMap_CharVarIndexFunc char_var_index;
FT_CMap_CharVarIsDefaultFunc char_var_default;
FT_CMap_VariantListFunc variant_list;
FT_CMap_CharVariantListFunc charvariant_list;
FT_CMap_VariantCharListFunc variantchar_list;
} FT_CMap_ClassRec;
#define FT_DECLARE_CMAP_CLASS( class_ ) \
FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
#define FT_DEFINE_CMAP_CLASS( \
class_, \
size_, \
init_, \
done_, \
char_index_, \
char_next_, \
char_var_index_, \
char_var_default_, \
variant_list_, \
charvariant_list_, \
variantchar_list_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_CMap_ClassRec class_ = \
{ \
size_, \
init_, \
done_, \
char_index_, \
char_next_, \
char_var_index_, \
char_var_default_, \
variant_list_, \
charvariant_list_, \
variantchar_list_ \
};
/* create a new charmap and add it to charmap->face */
FT_BASE( FT_Error )
FT_CMap_New( FT_CMap_Class clazz,
FT_Pointer init_data,
FT_CharMap charmap,
FT_CMap *acmap );
/* destroy a charmap and remove it from face's list */
FT_BASE( void )
FT_CMap_Done( FT_CMap cmap );
/* add LCD padding to CBox */
FT_BASE( void )
ft_lcd_padding( FT_BBox* cbox,
FT_GlyphSlot slot,
FT_Render_Mode mode );
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
FT_Byte* weights );
/* This is the default LCD filter, an in-place, 5-tap FIR filter. */
FT_BASE( void )
ft_lcd_filter_fir( FT_Bitmap* bitmap,
FT_LcdFiveTapFilter weights );
#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/**************************************************************************
*
* @struct:
* FT_Face_InternalRec
*
* @description:
* This structure contains the internal fields of each FT_Face object.
* These fields may change between different releases of FreeType.
*
* @fields:
* max_points ::
* The maximum number of points used to store the vectorial outline of
* any glyph in this face. If this value cannot be known in advance,
* or if the face isn't scalable, this should be set to 0. Only
* relevant for scalable formats.
*
* max_contours ::
* The maximum number of contours used to store the vectorial outline
* of any glyph in this face. If this value cannot be known in
* advance, or if the face isn't scalable, this should be set to 0.
* Only relevant for scalable formats.
*
* transform_matrix ::
* A 2x2 matrix of 16.16 coefficients used to transform glyph outlines
* after they are loaded from the font. Only used by the convenience
* functions.
*
* transform_delta ::
* A translation vector used to transform glyph outlines after they are
* loaded from the font. Only used by the convenience functions.
*
* transform_flags ::
* Some flags used to classify the transform. Only used by the
* convenience functions.
*
* services ::
* A cache for frequently used services. It should be only accessed
* with the macro `FT_FACE_LOOKUP_SERVICE`.
*
* incremental_interface ::
* If non-null, the interface through which glyph data and metrics are
* loaded incrementally for faces that do not provide all of this data
* when first opened. This field exists only if
* @FT_CONFIG_OPTION_INCREMENTAL is defined.
*
* no_stem_darkening ::
* Overrides the module-level default, see @stem-darkening[cff], for
* example. FALSE and TRUE toggle stem darkening on and off,
* respectively, value~-1 means to use the module/driver default.
*
* random_seed ::
* If positive, override the seed value for the CFF 'random' operator.
* Value~0 means to use the font's value. Value~-1 means to use the
* CFF driver's default.
*
* lcd_weights ::
* lcd_filter_func ::
* These fields specify the LCD filtering weights and callback function
* for ClearType-style subpixel rendering.
*
* refcount ::
* A counter initialized to~1 at the time an @FT_Face structure is
* created. @FT_Reference_Face increments this counter, and
* @FT_Done_Face only destroys a face if the counter is~1, otherwise it
* simply decrements it.
*/
typedef struct FT_Face_InternalRec_
{
FT_Matrix transform_matrix;
FT_Vector transform_delta;
FT_Int transform_flags;
FT_ServiceCacheRec services;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec* incremental_interface;
#endif
FT_Char no_stem_darkening;
FT_Int32 random_seed;
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */
FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
#endif
FT_Int refcount;
} FT_Face_InternalRec;
/**************************************************************************
*
* @struct:
* FT_Slot_InternalRec
*
* @description:
* This structure contains the internal fields of each FT_GlyphSlot
* object. These fields may change between different releases of
* FreeType.
*
* @fields:
* loader ::
* The glyph loader object used to load outlines into the glyph slot.
*
* flags ::
* Possible values are zero or FT_GLYPH_OWN_BITMAP. The latter
* indicates that the FT_GlyphSlot structure owns the bitmap buffer.
*
* glyph_transformed ::
* Boolean. Set to TRUE when the loaded glyph must be transformed
* through a specific font transformation. This is _not_ the same as
* the face transform set through FT_Set_Transform().
*
* glyph_matrix ::
* The 2x2 matrix corresponding to the glyph transformation, if
* necessary.
*
* glyph_delta ::
* The 2d translation vector corresponding to the glyph transformation,
* if necessary.
*
* glyph_hints ::
* Format-specific glyph hints management.
*
* load_flags ::
* The load flags passed as an argument to @FT_Load_Glyph while
* initializing the glyph slot.
*/
#define FT_GLYPH_OWN_BITMAP 0x1U
#define FT_GLYPH_OWN_GZIP_SVG 0x2U
typedef struct FT_Slot_InternalRec_
{
FT_GlyphLoader loader;
FT_UInt flags;
FT_Bool glyph_transformed;
FT_Matrix glyph_matrix;
FT_Vector glyph_delta;
void* glyph_hints;
FT_Int32 load_flags;
} FT_GlyphSlot_InternalRec;
/**************************************************************************
*
* @struct:
* FT_Size_InternalRec
*
* @description:
* This structure contains the internal fields of each FT_Size object.
*
* @fields:
* module_data ::
* Data specific to a driver module.
*
* autohint_mode ::
* The used auto-hinting mode.
*
* autohint_metrics ::
* Metrics used by the auto-hinter.
*
*/
typedef struct FT_Size_InternalRec_
{
void* module_data;
FT_Render_Mode autohint_mode;
FT_Size_Metrics autohint_metrics;
} FT_Size_InternalRec;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** M O D U L E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* FT_ModuleRec
*
* @description:
* A module object instance.
*
* @fields:
* clazz ::
* A pointer to the module's class.
*
* library ::
* A handle to the parent library object.
*
* memory ::
* A handle to the memory manager.
*/
typedef struct FT_ModuleRec_
{
FT_Module_Class* clazz;
FT_Library library;
FT_Memory memory;
} FT_ModuleRec;
/* typecast an object to an FT_Module */
#define FT_MODULE( x ) ( (FT_Module)(x) )
#define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
#define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
#define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_FONT_DRIVER )
#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_RENDERER )
#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_HINTER )
#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_STYLER )
#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_DRIVER_SCALABLE )
#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_DRIVER_NO_OUTLINES )
#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_DRIVER_HAS_HINTER )
#define FT_DRIVER_HINTS_LIGHTLY( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_DRIVER_HINTS_LIGHTLY )
/**************************************************************************
*
* @function:
* FT_Get_Module_Interface
*
* @description:
* Finds a module and returns its specific interface as a typeless
* pointer.
*
* @input:
* library ::
* A handle to the library object.
*
* module_name ::
* The module's name (as an ASCII string).
*
* @return:
* A module-specific interface if available, 0 otherwise.
*
* @note:
* You should better be familiar with FreeType internals to know which
* module to look for, and what its interface is :-)
*/
FT_BASE( const void* )
FT_Get_Module_Interface( FT_Library library,
const char* mod_name );
FT_BASE( FT_Pointer )
ft_module_get_service( FT_Module module,
const char* service_id,
FT_Bool global );
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_BASE( FT_Error )
ft_property_string_set( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
FT_String* value );
#endif
/* */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** F A C E, S I Z E & G L Y P H S L O T O B J E C T S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* a few macros used to perform easy typecasts with minimal brain damage */
#define FT_FACE( x ) ( (FT_Face)(x) )
#define FT_SIZE( x ) ( (FT_Size)(x) )
#define FT_SLOT( x ) ( (FT_GlyphSlot)(x) )
#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
#define FT_FACE_STREAM( x ) FT_FACE( x )->stream
/**************************************************************************
*
* @function:
* FT_New_GlyphSlot
*
* @description:
* It is sometimes useful to have more than one glyph slot for a given
* face object. This function is used to create additional slots. All
* of them are automatically discarded when the face is destroyed.
*
* @input:
* face ::
* A handle to a parent face object.
*
* @output:
* aslot ::
* A handle to a new glyph slot object.
*
* @return:
* FreeType error code. 0 means success.
*/
FT_BASE( FT_Error )
FT_New_GlyphSlot( FT_Face face,
FT_GlyphSlot *aslot );
/**************************************************************************
*
* @function:
* FT_Done_GlyphSlot
*
* @description:
* Destroys a given glyph slot. Remember however that all slots are
* automatically destroyed with its parent. Using this function is not
* always mandatory.
*
* @input:
* slot ::
* A handle to a target glyph slot.
*/
FT_BASE( void )
FT_Done_GlyphSlot( FT_GlyphSlot slot );
/* */
#define FT_REQUEST_WIDTH( req ) \
( (req)->horiResolution \
? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \
: (req)->width )
#define FT_REQUEST_HEIGHT( req ) \
( (req)->vertResolution \
? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \
: (req)->height )
/* Set the metrics according to a bitmap strike. */
FT_BASE( void )
FT_Select_Metrics( FT_Face face,
FT_ULong strike_index );
/* Set the metrics according to a size request. */
FT_BASE( FT_Error )
FT_Request_Metrics( FT_Face face,
FT_Size_Request req );
/* Match a size request against `available_sizes'. */
FT_BASE( FT_Error )
FT_Match_Size( FT_Face face,
FT_Size_Request req,
FT_Bool ignore_width,
FT_ULong* size_index );
/* Use the horizontal metrics to synthesize the vertical metrics. */
/* If `advance' is zero, it is also synthesized. */
FT_BASE( void )
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance );
/* Free the bitmap of a given glyphslot when needed (i.e., only when it */
/* was allocated with ft_glyphslot_alloc_bitmap). */
FT_BASE( void )
ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
/* Preset bitmap metrics of an outline glyphslot prior to rendering */
/* and check whether the truncated bbox is too large for rendering. */
FT_BASE( FT_Bool )
ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin );
/* Allocate a new bitmap buffer in a glyph slot. */
FT_BASE( FT_Error )
ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
FT_ULong size );
/* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
/* will not be freed by a later call to ft_glyphslot_free_bitmap. */
FT_BASE( void )
ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
FT_Byte* buffer );
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** R E N D E R E R S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#define FT_RENDERER( x ) ( (FT_Renderer)(x) )
#define FT_GLYPH( x ) ( (FT_Glyph)(x) )
#define FT_BITMAP_GLYPH( x ) ( (FT_BitmapGlyph)(x) )
#define FT_OUTLINE_GLYPH( x ) ( (FT_OutlineGlyph)(x) )
typedef struct FT_RendererRec_
{
FT_ModuleRec root;
FT_Renderer_Class* clazz;
FT_Glyph_Format glyph_format;
FT_Glyph_Class glyph_class;
FT_Raster raster;
FT_Raster_Render_Func raster_render;
FT_Renderer_RenderFunc render;
} FT_RendererRec;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** F O N T D R I V E R S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* typecast a module into a driver easily */
#define FT_DRIVER( x ) ( (FT_Driver)(x) )
/* typecast a module as a driver, and get its driver class */
#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
/**************************************************************************
*
* @struct:
* FT_DriverRec
*
* @description:
* The root font driver class. A font driver is responsible for managing
* and loading font files of a given format.
*
* @fields:
* root ::
* Contains the fields of the root module class.
*
* clazz ::
* A pointer to the font driver's class. Note that this is NOT
* root.clazz. 'class' wasn't used as it is a reserved word in C++.
*
* faces_list ::
* The list of faces currently opened by this driver.
*
* glyph_loader ::
* Unused. Used to be glyph loader for all faces managed by this
* driver.
*/
typedef struct FT_DriverRec_
{
FT_ModuleRec root;
FT_Driver_Class clazz;
FT_ListRec faces_list;
FT_GlyphLoader glyph_loader;
} FT_DriverRec;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** L I B R A R I E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* FT_LibraryRec
*
* @description:
* The FreeType library class. This is the root of all FreeType data.
* Use FT_New_Library() to create a library object, and FT_Done_Library()
* to discard it and all child objects.
*
* @fields:
* memory ::
* The library's memory object. Manages memory allocation.
*
* version_major ::
* The major version number of the library.
*
* version_minor ::
* The minor version number of the library.
*
* version_patch ::
* The current patch level of the library.
*
* num_modules ::
* The number of modules currently registered within this library.
* This is set to 0 for new libraries. New modules are added through
* the FT_Add_Module() API function.
*
* modules ::
* A table used to store handles to the currently registered
* modules. Note that each font driver contains a list of its opened
* faces.
*
* renderers ::
* The list of renderers currently registered within the library.
*
* cur_renderer ::
* The current outline renderer. This is a shortcut used to avoid
* parsing the list on each call to FT_Outline_Render(). It is a
* handle to the current renderer for the FT_GLYPH_FORMAT_OUTLINE
* format.
*
* auto_hinter ::
* The auto-hinter module interface.
*
* debug_hooks ::
* An array of four function pointers that allow debuggers to hook into
* a font format's interpreter. Currently, only the TrueType bytecode
* debugger uses this.
*
* lcd_weights ::
* The LCD filter weights for ClearType-style subpixel rendering.
*
* lcd_filter_func ::
* The LCD filtering callback function for for ClearType-style subpixel
* rendering.
*
* lcd_geometry ::
* This array specifies LCD subpixel geometry and controls Harmony LCD
* rendering technique, alternative to ClearType.
*
* pic_container ::
* Contains global structs and tables, instead of defining them
* globally.
*
* refcount ::
* A counter initialized to~1 at the time an @FT_Library structure is
* created. @FT_Reference_Library increments this counter, and
* @FT_Done_Library only destroys a library if the counter is~1,
* otherwise it simply decrements it.
*/
typedef struct FT_LibraryRec_
{
FT_Memory memory; /* library's memory manager */
FT_Int version_major;
FT_Int version_minor;
FT_Int version_patch;
FT_UInt num_modules;
FT_Module modules[FT_MAX_MODULES]; /* module objects */
FT_ListRec renderers; /* list of renderers */
FT_Renderer cur_renderer; /* current outline renderer */
FT_Module auto_hinter;
FT_DebugHook_Func debug_hooks[4];
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */
FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
#else
FT_Vector lcd_geometry[3]; /* RGB subpixel positions */
#endif
FT_Int refcount;
} FT_LibraryRec;
FT_BASE( FT_Renderer )
FT_Lookup_Renderer( FT_Library library,
FT_Glyph_Format format,
FT_ListNode* node );
FT_BASE( FT_Error )
FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot,
FT_Render_Mode render_mode );
typedef const char*
(*FT_Face_GetPostscriptNameFunc)( FT_Face face );
typedef FT_Error
(*FT_Face_GetGlyphNameFunc)( FT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max );
typedef FT_UInt
(*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
const FT_String* glyph_name );
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
/**************************************************************************
*
* @function:
* FT_New_Memory
*
* @description:
* Creates a new memory object.
*
* @return:
* A pointer to the new memory object. 0 in case of error.
*/
FT_BASE( FT_Memory )
FT_New_Memory( void );
/**************************************************************************
*
* @function:
* FT_Done_Memory
*
* @description:
* Discards memory manager.
*
* @input:
* memory ::
* A handle to the memory manager.
*/
FT_BASE( void )
FT_Done_Memory( FT_Memory memory );
#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
/* Define default raster's interface. The default raster is located in */
/* `src/base/ftraster.c'. */
/* */
/* Client applications can register new rasters through the */
/* FT_Set_Raster() API. */
#ifndef FT_NO_DEFAULT_RASTER
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
#endif
/**************************************************************************
*
* @macro:
* FT_DEFINE_OUTLINE_FUNCS
*
* @description:
* Used to initialize an instance of FT_Outline_Funcs struct. The struct
* will be allocated in the global scope (or the scope where the macro is
* used).
*/
#define FT_DEFINE_OUTLINE_FUNCS( \
class_, \
move_to_, \
line_to_, \
conic_to_, \
cubic_to_, \
shift_, \
delta_ ) \
static const FT_Outline_Funcs class_ = \
{ \
move_to_, \
line_to_, \
conic_to_, \
cubic_to_, \
shift_, \
delta_ \
};
/**************************************************************************
*
* @macro:
* FT_DEFINE_RASTER_FUNCS
*
* @description:
* Used to initialize an instance of FT_Raster_Funcs struct. The struct
* will be allocated in the global scope (or the scope where the macro is
* used).
*/
#define FT_DEFINE_RASTER_FUNCS( \
class_, \
glyph_format_, \
raster_new_, \
raster_reset_, \
raster_set_mode_, \
raster_render_, \
raster_done_ ) \
const FT_Raster_Funcs class_ = \
{ \
glyph_format_, \
raster_new_, \
raster_reset_, \
raster_set_mode_, \
raster_render_, \
raster_done_ \
};
/**************************************************************************
*
* @macro:
* FT_DEFINE_GLYPH
*
* @description:
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*/
#define FT_DECLARE_GLYPH( class_ ) \
FT_CALLBACK_TABLE const FT_Glyph_Class class_;
#define FT_DEFINE_GLYPH( \
class_, \
size_, \
format_, \
init_, \
done_, \
copy_, \
transform_, \
bbox_, \
prepare_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_Glyph_Class class_ = \
{ \
size_, \
format_, \
init_, \
done_, \
copy_, \
transform_, \
bbox_, \
prepare_ \
};
/**************************************************************************
*
* @macro:
* FT_DECLARE_RENDERER
*
* @description:
* Used to create a forward declaration of a FT_Renderer_Class struct
* instance.
*
* @macro:
* FT_DEFINE_RENDERER
*
* @description:
* Used to initialize an instance of FT_Renderer_Class struct.
*
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*/
#define FT_DECLARE_RENDERER( class_ ) \
FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
#define FT_DEFINE_RENDERER( \
class_, \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_, \
glyph_format_, \
render_glyph_, \
transform_glyph_, \
get_glyph_cbox_, \
set_mode_, \
raster_class_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_Renderer_Class class_ = \
{ \
FT_DEFINE_ROOT_MODULE( flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
glyph_format_, \
\
render_glyph_, \
transform_glyph_, \
get_glyph_cbox_, \
set_mode_, \
\
raster_class_ \
};
/**************************************************************************
*
* @macro:
* FT_DECLARE_MODULE
*
* @description:
* Used to create a forward declaration of a FT_Module_Class struct
* instance.
*
* @macro:
* FT_DEFINE_MODULE
*
* @description:
* Used to initialize an instance of an FT_Module_Class struct.
*
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*
* @macro:
* FT_DEFINE_ROOT_MODULE
*
* @description:
* Used to initialize an instance of an FT_Module_Class struct inside
* another struct that contains it or in a function that initializes that
* containing struct.
*/
#define FT_DECLARE_MODULE( class_ ) \
FT_CALLBACK_TABLE \
const FT_Module_Class class_;
#define FT_DEFINE_ROOT_MODULE( \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
{ \
flags_, \
size_, \
\
name_, \
version_, \
requires_, \
\
interface_, \
\
init_, \
done_, \
get_interface_, \
},
#define FT_DEFINE_MODULE( \
class_, \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_Module_Class class_ = \
{ \
flags_, \
size_, \
\
name_, \
version_, \
requires_, \
\
interface_, \
\
init_, \
done_, \
get_interface_, \
};
FT_END_HEADER
#endif /* FTOBJS_H_ */
/* END */
/****************************************************************************
*
* ftpsprop.h
*
* Get and set properties of PostScript drivers (specification).
*
* Copyright (C) 2017-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTPSPROP_H_
#define FTPSPROP_H_
#include <freetype/freetype.h>
FT_BEGIN_HEADER
FT_BASE_CALLBACK( FT_Error )
ps_property_set( FT_Module module, /* PS_Driver */
const char* property_name,
const void* value,
FT_Bool value_is_string );
FT_BASE_CALLBACK( FT_Error )
ps_property_get( FT_Module module, /* PS_Driver */
const char* property_name,
void* value );
FT_END_HEADER
#endif /* FTPSPROP_H_ */
/* END */
/****************************************************************************
*
* ftrfork.h
*
* Embedded resource forks accessor (specification).
*
* Copyright (C) 2004-2024 by
* Masatake YAMATO and Redhat K.K.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
/****************************************************************************
* Development of the code in this file is support of
* Information-technology Promotion Agency, Japan.
*/
#ifndef FTRFORK_H_
#define FTRFORK_H_
#include <freetype/internal/ftobjs.h>
FT_BEGIN_HEADER
/* Number of guessing rules supported in `FT_Raccess_Guess'. */
/* Don't forget to increment the number if you add a new guessing rule. */
#define FT_RACCESS_N_RULES 9
/* A structure to describe a reference in a resource by its resource ID */
/* and internal offset. The `POST' resource expects to be concatenated */
/* by the order of resource IDs instead of its appearance in the file. */
typedef struct FT_RFork_Ref_
{
FT_Short res_id;
FT_Long offset;
} FT_RFork_Ref;
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
typedef FT_Error
(*ft_raccess_guess_func)( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
typedef enum FT_RFork_Rule_ {
FT_RFork_Rule_invalid = -2,
FT_RFork_Rule_uknown, /* -1 */
FT_RFork_Rule_apple_double,
FT_RFork_Rule_apple_single,
FT_RFork_Rule_darwin_ufs_export,
FT_RFork_Rule_darwin_newvfs,
FT_RFork_Rule_darwin_hfsplus,
FT_RFork_Rule_vfat,
FT_RFork_Rule_linux_cap,
FT_RFork_Rule_linux_double,
FT_RFork_Rule_linux_netatalk
} FT_RFork_Rule;
/* For fast translation between rule index and rule type,
* the macros FT_RFORK_xxx should be kept consistent with the
* raccess_guess_funcs table
*/
typedef struct ft_raccess_guess_rec_ {
ft_raccess_guess_func func;
FT_RFork_Rule type;
} ft_raccess_guess_rec;
#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
static const type name[] = {
#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
{ raccess_guess_ ## func_suffix, \
FT_RFork_Rule_ ## type_suffix },
/* this array is a storage, thus a final `;' is needed */
#define CONST_FT_RFORK_RULE_ARRAY_END };
#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
/**************************************************************************
*
* @function:
* FT_Raccess_Guess
*
* @description:
* Guess a file name and offset where the actual resource fork is stored.
* The macro FT_RACCESS_N_RULES holds the number of guessing rules; the
* guessed result for the Nth rule is represented as a triplet: a new
* file name (new_names[N]), a file offset (offsets[N]), and an error
* code (errors[N]).
*
* @input:
* library ::
* A FreeType library instance.
*
* stream ::
* A file stream containing the resource fork.
*
* base_name ::
* The (base) file name of the resource fork used for some guessing
* rules.
*
* @output:
* new_names ::
* An array of guessed file names in which the resource forks may
* exist. If 'new_names[N]' is `NULL`, the guessed file name is equal
* to `base_name`.
*
* offsets ::
* An array of guessed file offsets. 'offsets[N]' holds the file
* offset of the possible start of the resource fork in file
* 'new_names[N]'.
*
* errors ::
* An array of FreeType error codes. 'errors[N]' is the error code of
* Nth guessing rule function. If 'errors[N]' is not FT_Err_Ok,
* 'new_names[N]' and 'offsets[N]' are meaningless.
*/
FT_BASE( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
char* base_name,
char** new_names,
FT_Long* offsets,
FT_Error* errors );
/**************************************************************************
*
* @function:
* FT_Raccess_Get_HeaderInfo
*
* @description:
* Get the information from the header of resource fork. The information
* includes the file offset where the resource map starts, and the file
* offset where the resource data starts. `FT_Raccess_Get_DataOffsets`
* requires these two data.
*
* @input:
* library ::
* A FreeType library instance.
*
* stream ::
* A file stream containing the resource fork.
*
* rfork_offset ::
* The file offset where the resource fork starts.
*
* @output:
* map_offset ::
* The file offset where the resource map starts.
*
* rdata_pos ::
* The file offset where the resource data starts.
*
* @return:
* FreeType error code. FT_Err_Ok means success.
*/
FT_BASE( FT_Error )
FT_Raccess_Get_HeaderInfo( FT_Library library,
FT_Stream stream,
FT_Long rfork_offset,
FT_Long *map_offset,
FT_Long *rdata_pos );
/**************************************************************************
*
* @function:
* FT_Raccess_Get_DataOffsets
*
* @description:
* Get the data offsets for a tag in a resource fork. Offsets are stored
* in an array because, in some cases, resources in a resource fork have
* the same tag.
*
* @input:
* library ::
* A FreeType library instance.
*
* stream ::
* A file stream containing the resource fork.
*
* map_offset ::
* The file offset where the resource map starts.
*
* rdata_pos ::
* The file offset where the resource data starts.
*
* tag ::
* The resource tag.
*
* sort_by_res_id ::
* A Boolean to sort the fragmented resource by their ids. The
* fragmented resources for 'POST' resource should be sorted to restore
* Type1 font properly. For 'sfnt' resources, sorting may induce a
* different order of the faces in comparison to that by QuickDraw API.
*
* @output:
* offsets ::
* The stream offsets for the resource data specified by 'tag'. This
* array is allocated by the function, so you have to call @ft_mem_free
* after use.
*
* count ::
* The length of offsets array.
*
* @return:
* FreeType error code. FT_Err_Ok means success.
*
* @note:
* Normally you should use `FT_Raccess_Get_HeaderInfo` to get the value
* for `map_offset` and `rdata_pos`.
*/
FT_BASE( FT_Error )
FT_Raccess_Get_DataOffsets( FT_Library library,
FT_Stream stream,
FT_Long map_offset,
FT_Long rdata_pos,
FT_Long tag,
FT_Bool sort_by_res_id,
FT_Long **offsets,
FT_Long *count );
FT_END_HEADER
#endif /* FTRFORK_H_ */
/* END */
/****************************************************************************
*
* ftserv.h
*
* The FreeType services (specification only).
*
* Copyright (C) 2003-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
/**************************************************************************
*
* Each module can export one or more 'services'. Each service is
* identified by a constant string and modeled by a pointer; the latter
* generally corresponds to a structure containing function pointers.
*
* Note that a service's data cannot be a mere function pointer because in
* C it is possible that function pointers might be implemented differently
* than data pointers (e.g. 48 bits instead of 32).
*
*/
#ifndef FTSERV_H_
#define FTSERV_H_
#include "compiler-macros.h"
FT_BEGIN_HEADER
/**************************************************************************
*
* @macro:
* FT_FACE_FIND_SERVICE
*
* @description:
* This macro is used to look up a service from a face's driver module.
*
* @input:
* face ::
* The source face handle.
*
* id ::
* A string describing the service as defined in the service's header
* files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
* 'multi-masters'). It is automatically prefixed with
* `FT_SERVICE_ID_`.
*
* @output:
* ptr ::
* A variable that receives the service pointer. Will be `NULL` if not
* found.
*/
#ifdef __cplusplus
#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_ = NULL; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
if ( module->clazz->get_interface ) \
_tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_ = NULL; \
\
if ( module->clazz->get_interface ) \
_tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
/**************************************************************************
*
* @macro:
* FT_FACE_FIND_GLOBAL_SERVICE
*
* @description:
* This macro is used to look up a service from all modules.
*
* @input:
* face ::
* The source face handle.
*
* id ::
* A string describing the service as defined in the service's header
* files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
* 'multi-masters'). It is automatically prefixed with
* `FT_SERVICE_ID_`.
*
* @output:
* ptr ::
* A variable that receives the service pointer. Will be `NULL` if not
* found.
*/
#ifdef __cplusplus
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S E R V I C E D E S C R I P T O R S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* The following structure is used to _describe_ a given service to the
* library. This is useful to build simple static service lists.
*/
typedef struct FT_ServiceDescRec_
{
const char* serv_id; /* service name */
const void* serv_data; /* service pointer/data */
} FT_ServiceDescRec;
typedef const FT_ServiceDescRec* FT_ServiceDesc;
/**************************************************************************
*
* @macro:
* FT_DEFINE_SERVICEDESCREC1
* FT_DEFINE_SERVICEDESCREC2
* FT_DEFINE_SERVICEDESCREC3
* FT_DEFINE_SERVICEDESCREC4
* FT_DEFINE_SERVICEDESCREC5
* FT_DEFINE_SERVICEDESCREC6
* FT_DEFINE_SERVICEDESCREC7
* FT_DEFINE_SERVICEDESCREC8
* FT_DEFINE_SERVICEDESCREC9
* FT_DEFINE_SERVICEDESCREC10
*
* @description:
* Used to initialize an array of FT_ServiceDescRec structures.
*
* The array will be allocated in the global scope (or the scope where
* the macro is used).
*/
#define FT_DEFINE_SERVICEDESCREC1( class_, \
serv_id_1, serv_data_1 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC2( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC3( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC4( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC5( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC6( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC7( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ serv_id_7, serv_data_7 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC8( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ serv_id_7, serv_data_7 }, \
{ serv_id_8, serv_data_8 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC9( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8, \
serv_id_9, serv_data_9 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ serv_id_7, serv_data_7 }, \
{ serv_id_8, serv_data_8 }, \
{ serv_id_9, serv_data_9 }, \
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC10( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8, \
serv_id_9, serv_data_9, \
serv_id_10, serv_data_10 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ serv_id_7, serv_data_7 }, \
{ serv_id_8, serv_data_8 }, \
{ serv_id_9, serv_data_9 }, \
{ serv_id_10, serv_data_10 }, \
{ NULL, NULL } \
};
/*
* Parse a list of FT_ServiceDescRec descriptors and look for a specific
* service by ID. Note that the last element in the array must be { NULL,
* NULL }, and that the function should return NULL if the service isn't
* available.
*
* This function can be used by modules to implement their `get_service'
* method.
*/
FT_BASE( FT_Pointer )
ft_service_list_lookup( FT_ServiceDesc service_descriptors,
const char* service_id );
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S E R V I C E S C A C H E *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* This structure is used to store a cache for several frequently used
* services. It is the type of `face->internal->services'. You should
* only use FT_FACE_LOOKUP_SERVICE to access it.
*
* All fields should have the type FT_Pointer to relax compilation
* dependencies. We assume the developer isn't completely stupid.
*
* Each field must be named `service_XXXX' where `XXX' corresponds to the
* correct FT_SERVICE_ID_XXXX macro. See the definition of
* FT_FACE_LOOKUP_SERVICE below how this is implemented.
*
*/
typedef struct FT_ServiceCacheRec_
{
FT_Pointer service_POSTSCRIPT_FONT_NAME;
FT_Pointer service_MULTI_MASTERS;
FT_Pointer service_METRICS_VARIATIONS;
FT_Pointer service_GLYPH_DICT;
FT_Pointer service_PFR_METRICS;
FT_Pointer service_WINFNT;
} FT_ServiceCacheRec, *FT_ServiceCache;
/*
* A magic number used within the services cache.
*/
/* ensure that value `1' has the same width as a pointer */
#define FT_SERVICE_UNAVAILABLE ((FT_Pointer)~(FT_PtrDist)1)
/**************************************************************************
*
* @macro:
* FT_FACE_LOOKUP_SERVICE
*
* @description:
* This macro is used to look up a service from a face's driver module
* using its cache.
*
* @input:
* face ::
* The source face handle containing the cache.
*
* field ::
* The field name in the cache.
*
* id ::
* The service ID.
*
* @output:
* ptr ::
* A variable receiving the service data. `NULL` if not available.
*/
#ifdef __cplusplus
#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Pointer svc; \
FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \
\
\
svc = FT_FACE( face )->internal->services. service_ ## id; \
if ( svc == FT_SERVICE_UNAVAILABLE ) \
svc = NULL; \
else if ( svc == NULL ) \
{ \
FT_FACE_FIND_SERVICE( face, svc, id ); \
\
FT_FACE( face )->internal->services. service_ ## id = \
(FT_Pointer)( svc != NULL ? svc \
: FT_SERVICE_UNAVAILABLE ); \
} \
*Pptr = svc; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Pointer svc; \
\
\
svc = FT_FACE( face )->internal->services. service_ ## id; \
if ( svc == FT_SERVICE_UNAVAILABLE ) \
svc = NULL; \
else if ( svc == NULL ) \
{ \
FT_FACE_FIND_SERVICE( face, svc, id ); \
\
FT_FACE( face )->internal->services. service_ ## id = \
(FT_Pointer)( svc != NULL ? svc \
: FT_SERVICE_UNAVAILABLE ); \
} \
ptr = svc; \
FT_END_STMNT
#endif /* !C++ */
/*
* A macro used to define new service structure types.
*/
#define FT_DEFINE_SERVICE( name ) \
typedef struct FT_Service_ ## name ## Rec_ \
FT_Service_ ## name ## Rec ; \
typedef struct FT_Service_ ## name ## Rec_ \
const * FT_Service_ ## name ; \
struct FT_Service_ ## name ## Rec_
/* */
FT_END_HEADER
#endif /* FTSERV_H_ */
/* END */
/****************************************************************************
*
* ftstream.h
*
* Stream handling (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTSTREAM_H_
#define FTSTREAM_H_
#include <ft2build.h>
#include <freetype/ftsystem.h>
#include <freetype/internal/ftobjs.h>
FT_BEGIN_HEADER
/* format of an 8-bit frame_op value: */
/* */
/* bit 76543210 */
/* xxxxxxes */
/* */
/* s is set to 1 if the value is signed. */
/* e is set to 1 if the value is little-endian. */
/* xxx is a command. */
#define FT_FRAME_OP_SHIFT 2
#define FT_FRAME_OP_SIGNED 1
#define FT_FRAME_OP_LITTLE 2
#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT )
#define FT_MAKE_FRAME_OP( command, little, sign ) \
( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign )
#define FT_FRAME_OP_END 0
#define FT_FRAME_OP_START 1 /* start a new frame */
#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */
#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */
#define FT_FRAME_OP_LONG 4 /* read 4-byte value */
#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */
#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */
typedef enum FT_Frame_Op_
{
ft_frame_end = 0,
ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ),
ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ),
ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ),
ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ),
ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ),
ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ),
ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ),
ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ),
ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ),
ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ),
ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ),
ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ),
ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ),
ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ),
ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ),
ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ),
ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 )
} FT_Frame_Op;
typedef struct FT_Frame_Field_
{
FT_Byte value;
FT_Byte size;
FT_UShort offset;
} FT_Frame_Field;
/* Construct an FT_Frame_Field out of a structure type and a field name. */
/* The structure type must be set in the FT_STRUCTURE macro before */
/* calling the FT_FRAME_START() macro. */
/* */
#define FT_FIELD_SIZE( f ) \
(FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f )
#define FT_FIELD_SIZE_DELTA( f ) \
(FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] )
#define FT_FIELD_OFFSET( f ) \
(FT_UShort)( offsetof( FT_STRUCTURE, f ) )
#define FT_FRAME_FIELD( frame_op, field ) \
{ \
frame_op, \
FT_FIELD_SIZE( field ), \
FT_FIELD_OFFSET( field ) \
}
#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 }
#define FT_FRAME_START( size ) { ft_frame_start, 0, size }
#define FT_FRAME_END { ft_frame_end, 0, 0 }
#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f )
#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f )
#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f )
#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f )
#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f )
#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f )
#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f )
#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f )
#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f )
#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f )
#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f )
#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f )
#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f )
#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f )
#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 }
#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 }
#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 }
#define FT_FRAME_BYTES( field, count ) \
{ \
ft_frame_bytes, \
count, \
FT_FIELD_OFFSET( field ) \
}
#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 }
/**************************************************************************
*
* Integer extraction macros -- the 'buffer' parameter must ALWAYS be of
* type 'char*' or equivalent (1-byte elements).
*/
#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] )
#define FT_INT16( x ) ( (FT_Int16)(x) )
#define FT_UINT16( x ) ( (FT_UInt16)(x) )
#define FT_INT32( x ) ( (FT_Int32)(x) )
#define FT_UINT32( x ) ( (FT_UInt32)(x) )
#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) )
#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) )
/*
* function acts on increases does range for emits
* pointer checking frames error
* -------------------------------------------------------------------
* FT_PEEK_XXX buffer pointer no no no no
* FT_NEXT_XXX buffer pointer yes no no no
* FT_GET_XXX stream->cursor yes yes yes no
* FT_READ_XXX stream->pos yes yes no yes
*/
/*
* `FT_PEEK_XXX' are generic macros to get data from a buffer position. No
* safety checks are performed.
*/
#define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \
FT_BYTE_U16( p, 1, 0 ) )
#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \
FT_BYTE_U16( p, 1, 0 ) )
#define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \
FT_BYTE_U32( p, 1, 16 ) | \
FT_BYTE_U32( p, 2, 8 ) | \
FT_BYTE_U32( p, 3, 0 ) )
#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \
FT_BYTE_U32( p, 1, 16 ) | \
FT_BYTE_U32( p, 2, 8 ) | \
FT_BYTE_U32( p, 3, 0 ) )
#define FT_PEEK_OFF3( p ) ( FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \
FT_BYTE_U32( p, 1, 16 ) | \
FT_BYTE_U32( p, 2, 8 ) ) >> 8 )
#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \
FT_BYTE_U32( p, 1, 8 ) | \
FT_BYTE_U32( p, 2, 0 ) )
#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \
FT_BYTE_U16( p, 0, 0 ) )
#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \
FT_BYTE_U16( p, 0, 0 ) )
#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \
FT_BYTE_U32( p, 2, 16 ) | \
FT_BYTE_U32( p, 1, 8 ) | \
FT_BYTE_U32( p, 0, 0 ) )
#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \
FT_BYTE_U32( p, 2, 16 ) | \
FT_BYTE_U32( p, 1, 8 ) | \
FT_BYTE_U32( p, 0, 0 ) )
#define FT_PEEK_OFF3_LE( p ) ( FT_INT32( FT_BYTE_U32( p, 2, 24 ) | \
FT_BYTE_U32( p, 1, 16 ) | \
FT_BYTE_U32( p, 0, 8 ) ) >> 8 )
#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \
FT_BYTE_U32( p, 1, 8 ) | \
FT_BYTE_U32( p, 0, 0 ) )
/*
* `FT_NEXT_XXX' are generic macros to get data from a buffer position
* which is then increased appropriately. No safety checks are performed.
*/
#define FT_NEXT_CHAR( buffer ) \
( (signed char)*buffer++ )
#define FT_NEXT_BYTE( buffer ) \
( (unsigned char)*buffer++ )
#define FT_NEXT_SHORT( buffer ) \
( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) )
#define FT_NEXT_USHORT( buffer ) \
( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) )
#define FT_NEXT_OFF3( buffer ) \
( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) )
#define FT_NEXT_UOFF3( buffer ) \
( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) )
#define FT_NEXT_LONG( buffer ) \
( buffer += 4, FT_PEEK_LONG( buffer - 4 ) )
#define FT_NEXT_ULONG( buffer ) \
( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) )
#define FT_NEXT_SHORT_LE( buffer ) \
( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) )
#define FT_NEXT_USHORT_LE( buffer ) \
( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) )
#define FT_NEXT_OFF3_LE( buffer ) \
( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) )
#define FT_NEXT_UOFF3_LE( buffer ) \
( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) )
#define FT_NEXT_LONG_LE( buffer ) \
( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) )
#define FT_NEXT_ULONG_LE( buffer ) \
( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) )
/**************************************************************************
*
* The `FT_GET_XXX` macros use an implicit 'stream' variable.
*
* Note that a call to `FT_STREAM_SEEK` or `FT_STREAM_POS` has **no**
* effect on `FT_GET_XXX`! They operate on `stream->pos`, while
* `FT_GET_XXX` use `stream->cursor`.
*/
#if 0
#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor )
#define FT_GET_CHAR() FT_GET_MACRO( CHAR )
#define FT_GET_BYTE() FT_GET_MACRO( BYTE )
#define FT_GET_SHORT() FT_GET_MACRO( SHORT )
#define FT_GET_USHORT() FT_GET_MACRO( USHORT )
#define FT_GET_OFF3() FT_GET_MACRO( OFF3 )
#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 )
#define FT_GET_LONG() FT_GET_MACRO( LONG )
#define FT_GET_ULONG() FT_GET_MACRO( ULONG )
#define FT_GET_TAG4() FT_GET_MACRO( ULONG )
#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE )
#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE )
#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE )
#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE )
#else
#define FT_GET_MACRO( func, type ) ( (type)func( stream ) )
#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetByte, FT_Char )
#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetByte, FT_Byte )
#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Int16 )
#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UInt16 )
#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_UInt32 )
#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Int32 )
#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_UInt32 )
#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_UInt32 )
#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Int16 )
#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UInt16 )
#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Int32 )
#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_UInt32 )
#endif
#define FT_READ_MACRO( func, type, var ) \
( var = (type)func( stream, &error ), \
error != FT_Err_Ok )
/*
* The `FT_READ_XXX' macros use implicit `stream' and `error' variables.
*
* `FT_READ_XXX' can be controlled with `FT_STREAM_SEEK' and
* `FT_STREAM_POS'. They use the full machinery to check whether a read is
* valid.
*/
#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadByte, FT_Byte, var )
#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadByte, FT_Char, var )
#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Int16, var )
#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UInt16, var )
#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_UInt32, var )
#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Int32, var )
#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_UInt32, var )
#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Int16, var )
#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UInt16, var )
#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Int32, var )
#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_UInt32, var )
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
/* initialize a stream for reading a regular system stream */
FT_BASE( FT_Error )
FT_Stream_Open( FT_Stream stream,
const char* filepathname );
#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
/* create a new (input) stream from an FT_Open_Args structure */
FT_BASE( FT_Error )
FT_Stream_New( FT_Library library,
const FT_Open_Args* args,
FT_Stream *astream );
/* free a stream */
FT_BASE( void )
FT_Stream_Free( FT_Stream stream,
FT_Int external );
/* initialize a stream for reading in-memory data */
FT_BASE( void )
FT_Stream_OpenMemory( FT_Stream stream,
const FT_Byte* base,
FT_ULong size );
/* close a stream (does not destroy the stream structure) */
FT_BASE( void )
FT_Stream_Close( FT_Stream stream );
/* seek within a stream. position is relative to start of stream */
FT_BASE( FT_Error )
FT_Stream_Seek( FT_Stream stream,
FT_ULong pos );
/* skip bytes in a stream */
FT_BASE( FT_Error )
FT_Stream_Skip( FT_Stream stream,
FT_Long distance );
/* return current stream position */
FT_BASE( FT_ULong )
FT_Stream_Pos( FT_Stream stream );
/* read bytes from a stream into a user-allocated buffer, returns an */
/* error if not all bytes could be read. */
FT_BASE( FT_Error )
FT_Stream_Read( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count );
/* read bytes from a stream at a given position */
FT_BASE( FT_Error )
FT_Stream_ReadAt( FT_Stream stream,
FT_ULong pos,
FT_Byte* buffer,
FT_ULong count );
/* try to read bytes at the end of a stream; return number of bytes */
/* really available */
FT_BASE( FT_ULong )
FT_Stream_TryRead( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count );
/* Enter a frame of `count' consecutive bytes in a stream. Returns an */
/* error if the frame could not be read/accessed. The caller can use */
/* the `FT_Stream_GetXXX' functions to retrieve frame data without */
/* error checks. */
/* */
/* You must _always_ call `FT_Stream_ExitFrame' once you have entered */
/* a stream frame! */
/* */
/* Nested frames are not permitted. */
/* */
FT_BASE( FT_Error )
FT_Stream_EnterFrame( FT_Stream stream,
FT_ULong count );
/* exit a stream frame */
FT_BASE( void )
FT_Stream_ExitFrame( FT_Stream stream );
/* Extract a stream frame. If the stream is disk-based, a heap block */
/* is allocated and the frame bytes are read into it. If the stream */
/* is memory-based, this function simply sets a pointer to the data. */
/* */
/* Useful to optimize access to memory-based streams transparently. */
/* */
/* `FT_Stream_GetXXX' functions can't be used. */
/* */
/* An extracted frame must be `freed' with a call to the function */
/* `FT_Stream_ReleaseFrame'. */
/* */
FT_BASE( FT_Error )
FT_Stream_ExtractFrame( FT_Stream stream,
FT_ULong count,
FT_Byte** pbytes );
/* release an extract frame (see `FT_Stream_ExtractFrame') */
FT_BASE( void )
FT_Stream_ReleaseFrame( FT_Stream stream,
FT_Byte** pbytes );
/* read a byte from an entered frame */
FT_BASE( FT_Byte )
FT_Stream_GetByte( FT_Stream stream );
/* read a 16-bit big-endian unsigned integer from an entered frame */
FT_BASE( FT_UInt16 )
FT_Stream_GetUShort( FT_Stream stream );
/* read a 24-bit big-endian unsigned integer from an entered frame */
FT_BASE( FT_UInt32 )
FT_Stream_GetUOffset( FT_Stream stream );
/* read a 32-bit big-endian unsigned integer from an entered frame */
FT_BASE( FT_UInt32 )
FT_Stream_GetULong( FT_Stream stream );
/* read a 16-bit little-endian unsigned integer from an entered frame */
FT_BASE( FT_UInt16 )
FT_Stream_GetUShortLE( FT_Stream stream );
/* read a 32-bit little-endian unsigned integer from an entered frame */
FT_BASE( FT_UInt32 )
FT_Stream_GetULongLE( FT_Stream stream );
/* read a byte from a stream */
FT_BASE( FT_Byte )
FT_Stream_ReadByte( FT_Stream stream,
FT_Error* error );
/* read a 16-bit big-endian unsigned integer from a stream */
FT_BASE( FT_UInt16 )
FT_Stream_ReadUShort( FT_Stream stream,
FT_Error* error );
/* read a 24-bit big-endian unsigned integer from a stream */
FT_BASE( FT_ULong )
FT_Stream_ReadUOffset( FT_Stream stream,
FT_Error* error );
/* read a 32-bit big-endian integer from a stream */
FT_BASE( FT_UInt32 )
FT_Stream_ReadULong( FT_Stream stream,
FT_Error* error );
/* read a 16-bit little-endian unsigned integer from a stream */
FT_BASE( FT_UInt16 )
FT_Stream_ReadUShortLE( FT_Stream stream,
FT_Error* error );
/* read a 32-bit little-endian unsigned integer from a stream */
FT_BASE( FT_UInt32 )
FT_Stream_ReadULongLE( FT_Stream stream,
FT_Error* error );
/* Read a structure from a stream. The structure must be described */
/* by an array of FT_Frame_Field records. */
FT_BASE( FT_Error )
FT_Stream_ReadFields( FT_Stream stream,
const FT_Frame_Field* fields,
void* structure );
#define FT_STREAM_POS() \
FT_Stream_Pos( stream )
#define FT_STREAM_SEEK( position ) \
FT_SET_ERROR( FT_Stream_Seek( stream, \
(FT_ULong)(position) ) )
#define FT_STREAM_SKIP( distance ) \
FT_SET_ERROR( FT_Stream_Skip( stream, \
(FT_Long)(distance) ) )
#define FT_STREAM_READ( buffer, count ) \
FT_SET_ERROR( FT_Stream_Read( stream, \
(FT_Byte*)(buffer), \
(FT_ULong)(count) ) )
#define FT_STREAM_READ_AT( position, buffer, count ) \
FT_SET_ERROR( FT_Stream_ReadAt( stream, \
(FT_ULong)(position), \
(FT_Byte*)(buffer), \
(FT_ULong)(count) ) )
#define FT_STREAM_READ_FIELDS( fields, object ) \
FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) )
#define FT_FRAME_ENTER( size ) \
FT_SET_ERROR( \
FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \
(FT_ULong)(size) ) ) )
#define FT_FRAME_EXIT() \
FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) )
#define FT_FRAME_EXTRACT( size, bytes ) \
FT_SET_ERROR( \
FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \
(FT_ULong)(size), \
(FT_Byte**)&(bytes) ) ) )
#define FT_FRAME_RELEASE( bytes ) \
FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \
(FT_Byte**)&(bytes) ) )
FT_END_HEADER
#endif /* FTSTREAM_H_ */
/* END */
/****************************************************************************
*
* fttrace.h
*
* Tracing handling (specification only).
*
* Copyright (C) 2002-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
/* definitions of trace levels for FreeType 2 */
/* the maximum string length (if the argument to `FT_TRACE_DEF` */
/* gets used as a string) plus one charachter for ':' plus */
/* another one for the trace level */
#define FT_MAX_TRACE_LEVEL_LENGTH (9 + 1 + 1)
/* the first level must always be `trace_any' */
FT_TRACE_DEF( any )
/* base components */
FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */
FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */
FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */
FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */
FT_TRACE_DEF( init ) /* initialization (ftinit.c) */
FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */
FT_TRACE_DEF( list ) /* list management (ftlist.c) */
FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */
FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */
FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */
FT_TRACE_DEF( bitmap ) /* bitmap manipulation (ftbitmap.c) */
FT_TRACE_DEF( checksum ) /* bitmap checksum (ftobjs.c) */
FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */
FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */
FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */
FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */
/* rasterizers */
FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */
FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
/* ot-svg module */
FT_TRACE_DEF( otsvg ) /* OT-SVG renderer (ftsvg.c) */
/* cache sub-system */
FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */
/* SFNT driver components */
FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */
FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */
FT_TRACE_DEF( sfwoff ) /* WOFF format handler (sfwoff.c) */
FT_TRACE_DEF( sfwoff2 ) /* WOFF2 format handler (sfwoff2.c) */
FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */
FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */
FT_TRACE_DEF( ttcolr ) /* glyph layer table (ttcolr.c) */
FT_TRACE_DEF( ttcpal ) /* color palette table (ttcpal.c) */
FT_TRACE_DEF( ttgpos ) /* GPOS handler (ttgpos.c) */
FT_TRACE_DEF( ttsvg ) /* OpenType SVG table (ttsvg.c) */
FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */
FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */
FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */
FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */
FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */
/* TrueType driver components */
FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */
FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */
FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */
FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */
FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */
FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */
/* Type 1 driver components */
FT_TRACE_DEF( t1afm )
FT_TRACE_DEF( t1driver )
FT_TRACE_DEF( t1gload )
FT_TRACE_DEF( t1load )
FT_TRACE_DEF( t1objs )
FT_TRACE_DEF( t1parse )
/* PostScript helper module `psaux' */
FT_TRACE_DEF( afmparse )
FT_TRACE_DEF( cffdecode )
FT_TRACE_DEF( psconv )
FT_TRACE_DEF( psobjs )
FT_TRACE_DEF( t1decode )
/* PostScript hinting module `pshinter' */
FT_TRACE_DEF( pshalgo )
FT_TRACE_DEF( pshrec )
/* Type 2 driver components */
FT_TRACE_DEF( cffdriver )
FT_TRACE_DEF( cffgload )
FT_TRACE_DEF( cffload )
FT_TRACE_DEF( cffobjs )
FT_TRACE_DEF( cffparse )
FT_TRACE_DEF( cf2blues )
FT_TRACE_DEF( cf2hints )
FT_TRACE_DEF( cf2interp )
/* Type 42 driver component */
FT_TRACE_DEF( t42 )
/* CID driver components */
FT_TRACE_DEF( ciddriver )
FT_TRACE_DEF( cidgload )
FT_TRACE_DEF( cidload )
FT_TRACE_DEF( cidobjs )
FT_TRACE_DEF( cidparse )
/* Windows font component */
FT_TRACE_DEF( winfnt )
/* PCF font components */
FT_TRACE_DEF( pcfdriver )
FT_TRACE_DEF( pcfread )
/* BDF font components */
FT_TRACE_DEF( bdfdriver )
FT_TRACE_DEF( bdflib )
/* PFR font component */
FT_TRACE_DEF( pfr )
/* OpenType validation components */
FT_TRACE_DEF( otvcommon )
FT_TRACE_DEF( otvbase )
FT_TRACE_DEF( otvgdef )
FT_TRACE_DEF( otvgpos )
FT_TRACE_DEF( otvgsub )
FT_TRACE_DEF( otvjstf )
FT_TRACE_DEF( otvmath )
FT_TRACE_DEF( otvmodule )
/* TrueTypeGX/AAT validation components */
FT_TRACE_DEF( gxvbsln )
FT_TRACE_DEF( gxvcommon )
FT_TRACE_DEF( gxvfeat )
FT_TRACE_DEF( gxvjust )
FT_TRACE_DEF( gxvkern )
FT_TRACE_DEF( gxvmodule )
FT_TRACE_DEF( gxvmort )
FT_TRACE_DEF( gxvmorx )
FT_TRACE_DEF( gxvlcar )
FT_TRACE_DEF( gxvopbd )
FT_TRACE_DEF( gxvprop )
FT_TRACE_DEF( gxvtrak )
/* autofit components */
FT_TRACE_DEF( afcjk )
FT_TRACE_DEF( afglobal )
FT_TRACE_DEF( afhints )
FT_TRACE_DEF( afmodule )
FT_TRACE_DEF( aflatin )
FT_TRACE_DEF( afshaper )
/* SDF components */
FT_TRACE_DEF( sdf ) /* signed distance raster for outlines (ftsdf.c) */
FT_TRACE_DEF( bsdf ) /* signed distance raster for bitmaps (ftbsdf.c) */
/* END */
/****************************************************************************
*
* ftvalid.h
*
* FreeType validation support (specification).
*
* Copyright (C) 2004-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*/
#ifndef FTVALID_H_
#define FTVALID_H_
#include <ft2build.h>
#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_jmpbuf */
#include "compiler-macros.h"
FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** V A L I D A T I O N ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* handle to a validation object */
typedef struct FT_ValidatorRec_ volatile* FT_Validator;
/**************************************************************************
*
* There are three distinct validation levels defined here:
*
* FT_VALIDATE_DEFAULT ::
* A table that passes this validation level can be used reliably by
* FreeType. It generally means that all offsets have been checked to
* prevent out-of-bound reads, that array counts are correct, etc.
*
* FT_VALIDATE_TIGHT ::
* A table that passes this validation level can be used reliably and
* doesn't contain invalid data. For example, a charmap table that
* returns invalid glyph indices will not pass, even though it can be
* used with FreeType in default mode (the library will simply return an
* error later when trying to load the glyph).
*
* It also checks that fields which must be a multiple of 2, 4, or 8,
* don't have incorrect values, etc.
*
* FT_VALIDATE_PARANOID ::
* Only for font debugging. Checks that a table follows the
* specification by 100%. Very few fonts will be able to pass this level
* anyway but it can be useful for certain tools like font
* editors/converters.
*/
typedef enum FT_ValidationLevel_
{
FT_VALIDATE_DEFAULT = 0,
FT_VALIDATE_TIGHT,
FT_VALIDATE_PARANOID
} FT_ValidationLevel;
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `structure was padded due to */
/* __declspec(align())' in order to compile cleanly with */
/* the maximum level of warnings. */
#pragma warning( push )
#pragma warning( disable : 4324 )
#endif /* _MSC_VER */
/* validator structure */
typedef struct FT_ValidatorRec_
{
ft_jmp_buf jump_buffer; /* used for exception handling */
const FT_Byte* base; /* address of table in memory */
const FT_Byte* limit; /* `base' + sizeof(table) in memory */
FT_ValidationLevel level; /* validation level */
FT_Error error; /* error returned. 0 means success */
} FT_ValidatorRec;
#if defined( _MSC_VER )
#pragma warning( pop )
#endif
#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) )
FT_BASE( void )
ft_validator_init( FT_Validator valid,
const FT_Byte* base,
const FT_Byte* limit,
FT_ValidationLevel level );
/* Do not use this. It's broken and will cause your validator to crash */
/* if you run it on an invalid font. */
FT_BASE( FT_Int )
ft_validator_run( FT_Validator valid );
/* Sets the error field in a validator, then calls `longjmp' to return */
/* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
/* error checks within the validation routines. */
/* */
FT_BASE( void )
ft_validator_error( FT_Validator valid,
FT_Error error );
/* Calls ft_validate_error. Assumes that the `valid' local variable */
/* holds a pointer to the current validator object. */
/* */
#define FT_INVALID( _error ) FT_INVALID_( _error )
#define FT_INVALID_( _error ) \
ft_validator_error( valid, FT_THROW( _error ) )
/* called when a broken table is detected */
#define FT_INVALID_TOO_SHORT \
FT_INVALID( Invalid_Table )
/* called when an invalid offset is detected */
#define FT_INVALID_OFFSET \
FT_INVALID( Invalid_Offset )
/* called when an invalid format/value is detected */
#define FT_INVALID_FORMAT \
FT_INVALID( Invalid_Table )
/* called when an invalid glyph index is detected */
#define FT_INVALID_GLYPH_ID \
FT_INVALID( Invalid_Glyph_Index )
/* called when an invalid field value is detected */
#define FT_INVALID_DATA \
FT_INVALID( Invalid_Table )
FT_END_HEADER
#endif /* FTVALID_H_ */
/* END */