|
|
|
@ -445,171 +445,6 @@ FT_BEGIN_HEADER |
|
|
|
|
FT_GlyphLoader* source ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/**** ****/ |
|
|
|
|
/**** ****/ |
|
|
|
|
/**** V A L I D A T O R ****/ |
|
|
|
|
/**** ****/ |
|
|
|
|
/**** ****/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
|
|
typedef struct FT_ValidatorRec_* FT_Validator; |
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
|
* |
|
|
|
|
* there are three distinct validation levels here: |
|
|
|
|
* |
|
|
|
|
* DEFAULT :: |
|
|
|
|
* used to perform normal checks. A table validated with this setting |
|
|
|
|
* is sufficiently correct to be used reliably by FreeType |
|
|
|
|
* |
|
|
|
|
* TIGHT :: |
|
|
|
|
* this is more strict than default. A table validated with this setting |
|
|
|
|
* is sufficiently correct to be used reliablity by FreeType and to not |
|
|
|
|
* contain invalid data (that will not crash FreeType or produce bogus |
|
|
|
|
* warnings). This is used to spot font converter/generation tool |
|
|
|
|
* bugs.. |
|
|
|
|
* |
|
|
|
|
* for example, a CharMap table could map a given character code to |
|
|
|
|
* a glyph index that is larger than the number of available glyphs |
|
|
|
|
* in the font. Such a table would not pass the "TIGHT" validation |
|
|
|
|
* even though it can be used safely with FreeType (which will later |
|
|
|
|
* report errors when trying to load the glyph, for example..) |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* PARANOID :: |
|
|
|
|
* in this mode, everything is checked to the maximum, and according |
|
|
|
|
* to the specification(s) defining the tables being checked. Really |
|
|
|
|
* useful for font fascists and to spot really weird font artefacts. |
|
|
|
|
* |
|
|
|
|
* Beware that most fonts will simply not pass this validation level |
|
|
|
|
* though !! |
|
|
|
|
*/ |
|
|
|
|
typedef enum |
|
|
|
|
{ |
|
|
|
|
FT_VALIDATE_DEFAULT = 0, |
|
|
|
|
FT_VALIDATE_TIGHT, |
|
|
|
|
FT_VALIDATE_PARANOID |
|
|
|
|
|
|
|
|
|
} FT_ValidationLevel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
|
* |
|
|
|
|
* to use it, you need something like: |
|
|
|
|
* |
|
|
|
|
* valid->error = 0; |
|
|
|
|
* |
|
|
|
|
* if ( setjmp( valid->jump_buffer ) == 0 ) |
|
|
|
|
* validate_table( table_data, .... ); |
|
|
|
|
* |
|
|
|
|
* return valid->error; |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
typedef struct FT_ValidatorRec_ |
|
|
|
|
{ |
|
|
|
|
FT_Byte* base; /* address of table in memory */ |
|
|
|
|
FT_Byte* limit; /* base + size of table in bytes */ |
|
|
|
|
|
|
|
|
|
FT_Error error; /* error code. 0 in case of success */ |
|
|
|
|
FT_ValidationLevel level; /* validation level.. */ |
|
|
|
|
FT_UInt num_glyphs; /* if level >= FT_VALIDATE_TIGHT only */ |
|
|
|
|
|
|
|
|
|
jmp_buf jump_buffer; |
|
|
|
|
|
|
|
|
|
} FT_ValidatorRec; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* call this function when an error is detected during validation. this */ |
|
|
|
|
/* will set the error and call 'longjmp' to return to the top-level */ |
|
|
|
|
/* caller of the validation routine.. */ |
|
|
|
|
/* */ |
|
|
|
|
FT_BASE( void ) |
|
|
|
|
ft_validator_error( FT_Validator valid, |
|
|
|
|
FT_Error error );
|
|
|
|
|
|
|
|
|
|
/* this macro assumes that the local variable 'valid' points to the */ |
|
|
|
|
/* current validator structure.. */ |
|
|
|
|
#define FT_INVALID(e) ft_validator_error( valid, e ) |
|
|
|
|
|
|
|
|
|
/* a few "common" errors in font tables */ |
|
|
|
|
#define FT_INVALID_TOO_SHORT FT_INVALID( FT_Err_Invalid_Table ) |
|
|
|
|
#define FT_INVALID_OFFSET FT_INVALID( FT_Err_Invalid_Offset ) |
|
|
|
|
#define FT_INVALID_GLYPH_ID FT_INVALID( FT_Err_Invalid_Table ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/**** ****/ |
|
|
|
|
/**** ****/ |
|
|
|
|
/**** 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, sub-class of 'FT_CharMapRec' */ |
|
|
|
|
typedef struct FT_CMapRec_ |
|
|
|
|
{ |
|
|
|
|
FT_CharMapRec charmap; |
|
|
|
|
FT_CMap_Class clazz; |
|
|
|
|
FT_Pointer data; /* passed to validate/index/next methods */ |
|
|
|
|
|
|
|
|
|
} FT_CMapRec; |
|
|
|
|
|
|
|
|
|
/* useful macros */ |
|
|
|
|
#define FT_CMAP(x) ((FT_CMap)(x)) |
|
|
|
|
#define FT_CMAP_FACE(x) (FT_CMAP(x)->charmap.face) |
|
|
|
|
#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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* charmap initializer */ |
|
|
|
|
typedef FT_Error (*FT_CMap_InitFunc)( FT_CMap cmap ); |
|
|
|
|
|
|
|
|
|
/* charmap finalizer */ |
|
|
|
|
typedef void (*FT_CMap_DoneFunc)( FT_CMap cmap ); |
|
|
|
|
|
|
|
|
|
/* charmap validation routine */ |
|
|
|
|
typedef FT_Error (*FT_CMap_ValidateFunc)( FT_Pointer cmap_data, |
|
|
|
|
FT_Validator valid ); |
|
|
|
|
|
|
|
|
|
/* charmap charcode to glyph index mapping function */ |
|
|
|
|
typedef FT_UInt (*FT_CMap_CharIndexFunc)( FT_Pointer cmap_data, |
|
|
|
|
FT_ULong char_code ); |
|
|
|
|
|
|
|
|
|
/* charmap charcode increment function */ |
|
|
|
|
typedef FT_ULong (*FT_CMap_CharNextFunc)( FT_Pointer cmap_data, |
|
|
|
|
FT_ULong char_code, |
|
|
|
|
FT_UInt *agindex ); |
|
|
|
|
|
|
|
|
|
/* charmap class */ |
|
|
|
|
typedef struct FT_CMap_ClassRec_ |
|
|
|
|
{ |
|
|
|
|
FT_ULong size; /* size in bytes */ |
|
|
|
|
FT_CMap_InitFunc init; |
|
|
|
|
FT_CMap_DoneFunc done; |
|
|
|
|
FT_CMap_ValidateFunc validate; |
|
|
|
|
FT_CMap_CharIndexFunc char_index; |
|
|
|
|
FT_CMap_CharNextFunc char_next; |
|
|
|
|
|
|
|
|
|
} FT_CMap_ClassRec; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|