ReactOS 0.4.16-dev-2357-g35d0dfe
ftvalid.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftvalid.h
4 *
5 * FreeType validation support (specification).
6 *
7 * Copyright (C) 2004-2020 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_jmpbuf */
24
25#include "compiler-macros.h"
26
28
29
30 /*************************************************************************/
31 /*************************************************************************/
32 /*************************************************************************/
33 /**** ****/
34 /**** ****/
35 /**** V A L I D A T I O N ****/
36 /**** ****/
37 /**** ****/
38 /*************************************************************************/
39 /*************************************************************************/
40 /*************************************************************************/
41
42 /* handle to a validation object */
44
45
46 /**************************************************************************
47 *
48 * There are three distinct validation levels defined here:
49 *
50 * FT_VALIDATE_DEFAULT ::
51 * A table that passes this validation level can be used reliably by
52 * FreeType. It generally means that all offsets have been checked to
53 * prevent out-of-bound reads, that array counts are correct, etc.
54 *
55 * FT_VALIDATE_TIGHT ::
56 * A table that passes this validation level can be used reliably and
57 * doesn't contain invalid data. For example, a charmap table that
58 * returns invalid glyph indices will not pass, even though it can be
59 * used with FreeType in default mode (the library will simply return an
60 * error later when trying to load the glyph).
61 *
62 * It also checks that fields which must be a multiple of 2, 4, or 8,
63 * don't have incorrect values, etc.
64 *
65 * FT_VALIDATE_PARANOID ::
66 * Only for font debugging. Checks that a table follows the
67 * specification by 100%. Very few fonts will be able to pass this level
68 * anyway but it can be useful for certain tools like font
69 * editors/converters.
70 */
72 {
76
78
79
80#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
81 /* We disable the warning `structure was padded due to */
82 /* __declspec(align())' in order to compile cleanly with */
83 /* the maximum level of warnings. */
84#pragma warning( push )
85#pragma warning( disable : 4324 )
86#endif /* _MSC_VER */
87
88 /* validator structure */
89 typedef struct FT_ValidatorRec_
90 {
91 ft_jmp_buf jump_buffer; /* used for exception handling */
92
93 const FT_Byte* base; /* address of table in memory */
94 const FT_Byte* limit; /* `base' + sizeof(table) in memory */
95 FT_ValidationLevel level; /* validation level */
96 FT_Error error; /* error returned. 0 means success */
97
99
100#if defined( _MSC_VER )
101#pragma warning( pop )
102#endif
103
104#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) )
105
106
107 FT_BASE( void )
109 const FT_Byte* base,
110 const FT_Byte* limit,
112
113 /* Do not use this. It's broken and will cause your validator to crash */
114 /* if you run it on an invalid font. */
115 FT_BASE( FT_Int )
117
118 /* Sets the error field in a validator, then calls `longjmp' to return */
119 /* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
120 /* error checks within the validation routines. */
121 /* */
122 FT_BASE( void )
124 FT_Error error );
125
126
127 /* Calls ft_validate_error. Assumes that the `valid' local variable */
128 /* holds a pointer to the current validator object. */
129 /* */
130#define FT_INVALID( _error ) FT_INVALID_( _error )
131#define FT_INVALID_( _error ) \
132 ft_validator_error( valid, FT_THROW( _error ) )
133
134 /* called when a broken table is detected */
135#define FT_INVALID_TOO_SHORT \
136 FT_INVALID( Invalid_Table )
137
138 /* called when an invalid offset is detected */
139#define FT_INVALID_OFFSET \
140 FT_INVALID( Invalid_Offset )
141
142 /* called when an invalid format/value is detected */
143#define FT_INVALID_FORMAT \
144 FT_INVALID( Invalid_Table )
145
146 /* called when an invalid glyph index is detected */
147#define FT_INVALID_GLYPH_ID \
148 FT_INVALID( Invalid_Glyph_Index )
149
150 /* called when an invalid field value is detected */
151#define FT_INVALID_DATA \
152 FT_INVALID( Invalid_Table )
153
154
156
157#endif /* FTVALID_H_ */
158
159
160/* END */
#define FT_BASE(x)
#define FT_END_HEADER
Definition: ftheader.h:57
#define FT_BEGIN_HEADER
Definition: ftheader.h:37
#define ft_jmp_buf
Definition: ftstdlib.h:158
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:299
signed int FT_Int
Definition: fttypes.h:220
FT_ValidationLevel_
Definition: ftvalid.h:72
@ FT_VALIDATE_DEFAULT
Definition: ftvalid.h:73
@ FT_VALIDATE_TIGHT
Definition: ftvalid.h:74
@ FT_VALIDATE_PARANOID
Definition: ftvalid.h:75
ft_validator_run(FT_Validator valid)
Definition: ftobjs.c:146
ft_validator_init(FT_Validator valid, const FT_Byte *base, const FT_Byte *limit, FT_ValidationLevel level)
Definition: ftobjs.c:133
enum FT_ValidationLevel_ FT_ValidationLevel
struct FT_ValidatorRec_ FT_ValidatorRec
ft_validator_error(FT_Validator valid, FT_Error error)
Definition: ftobjs.c:156
typedefFT_BEGIN_HEADER struct FT_ValidatorRec_ volatile * FT_Validator
Definition: ftvalid.h:43
BOOLEAN valid
GLint level
Definition: gl.h:1546
GLint limit
Definition: glext.h:10326
#define error(str)
Definition: mkdosfs.c:1605
#define volatile
Definition: prototyp.h:117
const FT_Byte * base
Definition: ftvalid.h:93
ft_jmp_buf jump_buffer
Definition: ftvalid.h:91
FT_ValidationLevel level
Definition: ftvalid.h:95
FT_Error error
Definition: ftvalid.h:96
const FT_Byte * limit
Definition: ftvalid.h:94