zenilib: zenilib/jni/external/freetype2/include/freetype/internal/ftvalid.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ftvalid.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftvalid.h */
4 /* */
5 /* FreeType validation support (specification). */
6 /* */
7 /* Copyright 2004 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17
18
19 #ifndef __FTVALID_H__
20 #define __FTVALID_H__
21
22 #include <ft2build.h>
23 #include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */
24
25
26 FT_BEGIN_HEADER
27
28
29 /*************************************************************************/
30 /*************************************************************************/
31 /*************************************************************************/
32 /**** ****/
33 /**** ****/
34 /**** V A L I D A T I O N ****/
35 /**** ****/
36 /**** ****/
37 /*************************************************************************/
38 /*************************************************************************/
39 /*************************************************************************/
40
41 /* handle to a validation object */
42 typedef struct FT_ValidatorRec_ volatile* FT_Validator;
43
44
45 /*************************************************************************/
46 /* */
47 /* There are three distinct validation levels defined here: */
48 /* */
49 /* FT_VALIDATE_DEFAULT :: */
50 /* A table that passes this validation level can be used reliably by */
51 /* FreeType. It generally means that all offsets have been checked to */
52 /* prevent out-of-bound reads, that array counts are correct, etc. */
53 /* */
54 /* FT_VALIDATE_TIGHT :: */
55 /* A table that passes this validation level can be used reliably and */
56 /* doesn't contain invalid data. For example, a charmap table that */
57 /* returns invalid glyph indices will not pass, even though it can */
58 /* be used with FreeType in default mode (the library will simply */
59 /* return an error later when trying to load the glyph). */
60 /* */
61 /* It also checks that fields which must be a multiple of 2, 4, or 8, */
62 /* don't have incorrect values, etc. */
63 /* */
64 /* FT_VALIDATE_PARANOID :: */
65 /* Only for font debugging. Checks that a table follows the */
66 /* specification by 100%. Very few fonts will be able to pass this */
67 /* level anyway but it can be useful for certain tools like font */
68 /* editors/converters. */
69 /* */
70 typedef enum FT_ValidationLevel_
71 {
72 FT_VALIDATE_DEFAULT = 0,
73 FT_VALIDATE_TIGHT,
74 FT_VALIDATE_PARANOID
75
76 } FT_ValidationLevel;
77
78
79 /* validator structure */
80 typedef struct FT_ValidatorRec_
81 {
82 const FT_Byte* base; /* address of table in memory */
83 const FT_Byte* limit; /* `base' + sizeof(table) in memory */
84 FT_ValidationLevel level; /* validation level */
85 FT_Error error; /* error returned. 0 means success */
86
87 ft_jmp_buf jump_buffer; /* used for exception handling */
88
89 } FT_ValidatorRec;
90
91
92 #define FT_VALIDATOR( x ) ((FT_Validator)( x ))
93
94
95 FT_BASE( void )
96 ft_validator_init( FT_Validator valid,
97 const FT_Byte* base,
98 const FT_Byte* limit,
99 FT_ValidationLevel level );
100
101 /* Do not use this. It's broken and will cause your validator to crash */
102 /* if you run it on an invalid font. */
103 FT_BASE( FT_Int )
104 ft_validator_run( FT_Validator valid );
105
106 /* Sets the error field in a validator, then calls `longjmp' to return */
107 /* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
108 /* error checks within the validation routines. */
109 /* */
110 FT_BASE( void )
111 ft_validator_error( FT_Validator valid,
112 FT_Error error );
113
114
115 /* Calls ft_validate_error. Assumes that the `valid' local variable */
116 /* holds a pointer to the current validator object. */
117 /* */
118 /* Use preprocessor prescan to pass FT_ERR_PREFIX. */
119 /* */
120 #define FT_INVALID( _prefix, _error ) FT_INVALID_( _prefix, _error )
121 #define FT_INVALID_( _prefix, _error ) \
122 ft_validator_error( valid, _prefix ## _error )
123
124 /* called when a broken table is detected */
125 #define FT_INVALID_TOO_SHORT \
126 FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
127
128 /* called when an invalid offset is detected */
129 #define FT_INVALID_OFFSET \
130 FT_INVALID( FT_ERR_PREFIX, Invalid_Offset )
131
132 /* called when an invalid format/value is detected */
133 #define FT_INVALID_FORMAT \
134 FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
135
136 /* called when an invalid glyph index is detected */
137 #define FT_INVALID_GLYPH_ID \
138 FT_INVALID( FT_ERR_PREFIX, Invalid_Glyph_Index )
139
140 /* called when an invalid field value is detected */
141 #define FT_INVALID_DATA \
142 FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
143
144
145 FT_END_HEADER
146
147 #endif /* __FTVALID_H__ */
148
149
150 /* END */
ft_jmp_buf
#define ft_jmp_buf
Definition: ftstdlib.h:157
FT_Error
int FT_Error
Definition: fttypes.h:296
FT_ValidatorRec
struct FT_ValidatorRec_ FT_ValidatorRec
FT_END_HEADER
#define FT_END_HEADER
Definition: ftheader.h:54
FT_Int
signed int FT_Int
Definition: fttypes.h:216
FT_ValidationLevel
enum FT_ValidationLevel_ FT_ValidationLevel
FT_VALIDATE_PARANOID
Definition: ftvalid.h:74
FT_ValidatorRec_::jump_buffer
ft_jmp_buf jump_buffer
Definition: ftvalid.h:87
ft_validator_run
ft_validator_run(FT_Validator valid)
Definition: ftobjs.c:84
FT_ValidatorRec_::error
FT_Error error
Definition: ftvalid.h:85
FT_Byte
unsigned char FT_Byte
Definition: fttypes.h:150
FT_BEGIN_HEADER
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
error
FT_Error error
Definition: cffdrivr.c:407
FT_ValidationLevel_
FT_ValidationLevel_
Definition: ftvalid.h:70
FT_Validator
typedefFT_BEGIN_HEADER struct FT_ValidatorRec_ volatile * FT_Validator
Definition: ftvalid.h:42
limit
GLint limit
Definition: glew.h:11829
ft_validator_error
ft_validator_error(FT_Validator valid, FT_Error error)
Definition: ftobjs.c:94
FT_ValidatorRec_::limit
const FT_Byte * limit
Definition: ftvalid.h:83
FT_VALIDATE_TIGHT
Definition: ftvalid.h:73
const
#define const
Definition: zconf.h:91
FT_ValidatorRec_::level
FT_ValidationLevel level
Definition: ftvalid.h:84
ft2build.h
FT_VALIDATE_DEFAULT
Definition: ftvalid.h:72
level
GLint level
Definition: gl2ext.h:845
FT_ValidatorRec_
Definition: ftvalid.h:80
ft_validator_init
ft_validator_init(FT_Validator valid, const FT_Byte *base, const FT_Byte *limit, FT_ValidationLevel level)
Definition: ftobjs.c:71
FT_BASE
#define FT_BASE(x)
Definition: ftconfig.h:478
FT_ValidatorRec_::base
const FT_Byte * base
Definition: ftvalid.h:82