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