ReactOS 0.4.15-dev-7842-g558ab78
otvmod.c File Reference
#include <ft2build.h>
#include "otvmod.h"
#include "otvalid.h"
#include "otvcommn.h"
Include dependency graph for otvmod.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_otvmodule
 

Functions

static FT_Error otv_load_table (FT_Face face, FT_Tag tag, FT_Byte *volatile *table, FT_ULong *table_len)
 
static FT_Error otv_validate (FT_Face volatile face, FT_UInt ot_flags, FT_Bytes *ot_base, FT_Bytes *ot_gdef, FT_Bytes *ot_gpos, FT_Bytes *ot_gsub, FT_Bytes *ot_jstf)
 
static FT_Pointer otvalid_get_service (FT_Module module, const char *service_id)
 

Variables

static const FT_Service_OTvalidateRec otvalid_interface
 
static const FT_ServiceDescRec otvalid_services []
 
FT_CALLBACK_TABLE_DEF const FT_Module_Class otv_module_class
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_otvmodule

Definition at line 38 of file otvmod.c.

Function Documentation

◆ otv_load_table()

static FT_Error otv_load_table ( FT_Face  face,
FT_Tag  tag,
FT_Byte *volatile table,
FT_ULong table_len 
)
static

Definition at line 42 of file otvmod.c.

46 {
49
50
51 error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
52 if ( FT_ERR_EQ( error, Table_Missing ) )
53 return FT_Err_Ok;
54 if ( error )
55 goto Exit;
56
57 if ( FT_ALLOC( *table, *table_len ) )
58 goto Exit;
59
60 error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len );
61
62 Exit:
63 return error;
64 }
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:636
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_ERR_EQ(x, e)
Definition: fttypes.h:591
int FT_Error
Definition: fttypes.h:300
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
static void Exit(void)
Definition: sock.c:1330
Definition: ecma_167.h:138
FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
Definition: ftobjs.c:4134

Referenced by otv_validate().

◆ otv_validate()

static FT_Error otv_validate ( FT_Face volatile  face,
FT_UInt  ot_flags,
FT_Bytes ot_base,
FT_Bytes ot_gdef,
FT_Bytes ot_gpos,
FT_Bytes ot_gsub,
FT_Bytes ot_jstf 
)
static

Definition at line 68 of file otvmod.c.

75 {
77 FT_Byte* volatile base;
78 FT_Byte* volatile gdef;
79 FT_Byte* volatile gpos;
80 FT_Byte* volatile gsub;
81 FT_Byte* volatile jstf;
82 FT_Byte* volatile math;
83 FT_ULong len_base, len_gdef, len_gpos, len_gsub, len_jstf;
84 FT_ULong len_math;
85 FT_UInt num_glyphs = (FT_UInt)face->num_glyphs;
86 FT_ValidatorRec volatile valid;
87
88
89 base = gdef = gpos = gsub = jstf = math = NULL;
90 len_base = len_gdef = len_gpos = len_gsub = len_jstf = len_math = 0;
91
92 /*
93 * XXX: OpenType tables cannot handle 32-bit glyph index,
94 * although broken TrueType can have 32-bit glyph index.
95 */
96 if ( face->num_glyphs > 0xFFFFL )
97 {
98 FT_TRACE1(( "otv_validate: Invalid glyphs index (0x0000FFFF - 0x%08x) ",
99 face->num_glyphs ));
100 FT_TRACE1(( "are not handled by OpenType tables\n" ));
101 num_glyphs = 0xFFFF;
102 }
103
104 /* load tables */
105
106 if ( ot_flags & FT_VALIDATE_BASE )
107 {
108 error = otv_load_table( face, TTAG_BASE, &base, &len_base );
109 if ( error )
110 goto Exit;
111 }
112
113 if ( ot_flags & FT_VALIDATE_GDEF )
114 {
115 error = otv_load_table( face, TTAG_GDEF, &gdef, &len_gdef );
116 if ( error )
117 goto Exit;
118 }
119
120 if ( ot_flags & FT_VALIDATE_GPOS )
121 {
122 error = otv_load_table( face, TTAG_GPOS, &gpos, &len_gpos );
123 if ( error )
124 goto Exit;
125 }
126
127 if ( ot_flags & FT_VALIDATE_GSUB )
128 {
129 error = otv_load_table( face, TTAG_GSUB, &gsub, &len_gsub );
130 if ( error )
131 goto Exit;
132 }
133
134 if ( ot_flags & FT_VALIDATE_JSTF )
135 {
136 error = otv_load_table( face, TTAG_JSTF, &jstf, &len_jstf );
137 if ( error )
138 goto Exit;
139 }
140
141 if ( ot_flags & FT_VALIDATE_MATH )
142 {
143 error = otv_load_table( face, TTAG_MATH, &math, &len_math );
144 if ( error )
145 goto Exit;
146 }
147
148 /* validate tables */
149
150 if ( base )
151 {
153 if ( ft_setjmp( valid.jump_buffer ) == 0 )
155 error = valid.error;
156 if ( error )
157 goto Exit;
158 }
159
160 if ( gpos )
161 {
162 ft_validator_init( &valid, gpos, gpos + len_gpos, FT_VALIDATE_DEFAULT );
163 if ( ft_setjmp( valid.jump_buffer ) == 0 )
164 otv_GPOS_validate( gpos, num_glyphs, &valid );
165 error = valid.error;
166 if ( error )
167 goto Exit;
168 }
169
170 if ( gsub )
171 {
172 ft_validator_init( &valid, gsub, gsub + len_gsub, FT_VALIDATE_DEFAULT );
173 if ( ft_setjmp( valid.jump_buffer ) == 0 )
174 otv_GSUB_validate( gsub, num_glyphs, &valid );
175 error = valid.error;
176 if ( error )
177 goto Exit;
178 }
179
180 if ( gdef )
181 {
182 ft_validator_init( &valid, gdef, gdef + len_gdef, FT_VALIDATE_DEFAULT );
183 if ( ft_setjmp( valid.jump_buffer ) == 0 )
184 otv_GDEF_validate( gdef, gsub, gpos, num_glyphs, &valid );
185 error = valid.error;
186 if ( error )
187 goto Exit;
188 }
189
190 if ( jstf )
191 {
192 ft_validator_init( &valid, jstf, jstf + len_jstf, FT_VALIDATE_DEFAULT );
193 if ( ft_setjmp( valid.jump_buffer ) == 0 )
194 otv_JSTF_validate( jstf, gsub, gpos, num_glyphs, &valid );
195 error = valid.error;
196 if ( error )
197 goto Exit;
198 }
199
200 if ( math )
201 {
202 ft_validator_init( &valid, math, math + len_math, FT_VALIDATE_DEFAULT );
203 if ( ft_setjmp( valid.jump_buffer ) == 0 )
204 otv_MATH_validate( math, num_glyphs, &valid );
205 error = valid.error;
206 if ( error )
207 goto Exit;
208 }
209
210 *ot_base = (FT_Bytes)base;
211 *ot_gdef = (FT_Bytes)gdef;
212 *ot_gpos = (FT_Bytes)gpos;
213 *ot_gsub = (FT_Bytes)gsub;
214 *ot_jstf = (FT_Bytes)jstf;
215
216 Exit:
217 if ( error )
218 {
220
221
222 FT_FREE( base );
223 FT_FREE( gdef );
224 FT_FREE( gpos );
225 FT_FREE( gsub );
226 FT_FREE( jstf );
227 }
228
229 {
231
232
233 FT_FREE( math ); /* Can't return this as API is frozen */
234 }
235
236 return error;
237 }
#define FT_TRACE1(varformat)
Definition: ftdebug.h:158
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_VALIDATE_MATH
Definition: ftotval.h:107
#define FT_VALIDATE_GSUB
Definition: ftotval.h:105
#define FT_VALIDATE_GDEF
Definition: ftotval.h:103
#define FT_VALIDATE_JSTF
Definition: ftotval.h:106
#define FT_VALIDATE_GPOS
Definition: ftotval.h:104
#define FT_VALIDATE_BASE
Definition: ftotval.h:102
#define ft_setjmp(b)
Definition: ftstdlib.h:163
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned char FT_Byte
Definition: fttypes.h:154
unsigned int FT_UInt
Definition: fttypes.h:231
const FT_Byte * FT_Bytes
Definition: fttypes.h:165
@ FT_VALIDATE_DEFAULT
Definition: ftvalid.h:72
ft_validator_init(FT_Validator valid, const FT_Byte *base, const FT_Byte *limit, FT_ValidationLevel level)
Definition: ftobjs.c:122
BOOLEAN valid
if(dx< 0)
Definition: linetemp.h:194
otv_GPOS_validate(FT_Bytes table, FT_UInt glyph_count, FT_Validator valid)
Definition: otvgpos.c:982
otv_GDEF_validate(FT_Bytes table, FT_Bytes gsub, FT_Bytes gpos, FT_UInt glyph_count, FT_Validator valid)
Definition: otvgdef.c:181
otv_MATH_validate(FT_Bytes table, FT_UInt glyph_count, FT_Validator ftvalid)
Definition: otvmath.c:416
otv_GSUB_validate(FT_Bytes table, FT_UInt glyph_count, FT_Validator valid)
Definition: otvgsub.c:548
otv_JSTF_validate(FT_Bytes table, FT_Bytes gsub, FT_Bytes gpos, FT_UInt glyph_count, FT_Validator valid)
Definition: otvjstf.c:205
FT_BEGIN_HEADER otv_BASE_validate(FT_Bytes table, FT_Validator valid)
Definition: otvbase.c:280
static FT_Error otv_load_table(FT_Face face, FT_Tag tag, FT_Byte *volatile *table, FT_ULong *table_len)
Definition: otvmod.c:42
#define TTAG_JSTF
Definition: tttags.h:70
#define TTAG_GDEF
Definition: tttags.h:60
#define TTAG_GPOS
Definition: tttags.h:62
#define TTAG_GSUB
Definition: tttags.h:63
#define TTAG_BASE
Definition: tttags.h:37
#define TTAG_MATH
Definition: tttags.h:77

◆ otvalid_get_service()

static FT_Pointer otvalid_get_service ( FT_Module  module,
const char service_id 
)
static

Definition at line 256 of file otvmod.c.

258 {
259 FT_UNUSED( module );
260
261 return ft_service_list_lookup( otvalid_services, service_id );
262 }
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
Definition: ftobjs.c:98
static const FT_ServiceDescRec otvalid_services[]
Definition: otvmod.c:248

Variable Documentation

◆ otv_module_class

Initial value:
=
{
0,
sizeof ( FT_ModuleRec ),
"otvalid",
0x10000L,
0x20000L,
NULL,
}
void(* FT_Module_Destructor)(FT_Module module)
Definition: ftmodapi.h:167
FT_Error(* FT_Module_Constructor)(FT_Module module)
Definition: ftmodapi.h:152
FT_Module_Interface(* FT_Module_Requester)(FT_Module module, const char *name)
Definition: ftmodapi.h:184
struct FT_ModuleRec_ FT_ModuleRec
static FT_Pointer otvalid_get_service(FT_Module module, const char *service_id)
Definition: otvmod.c:256

Definition at line 266 of file otvmod.c.

◆ otvalid_interface

const FT_Service_OTvalidateRec otvalid_interface
static
Initial value:
=
{
}
static FT_Error otv_validate(FT_Face volatile face, FT_UInt ot_flags, FT_Bytes *ot_base, FT_Bytes *ot_gdef, FT_Bytes *ot_gpos, FT_Bytes *ot_gsub, FT_Bytes *ot_jstf)
Definition: otvmod.c:68

Definition at line 241 of file otvmod.c.

◆ otvalid_services

const FT_ServiceDescRec otvalid_services[]
static
Initial value:
=
{
{ NULL, NULL }
}
static const FT_Service_OTvalidateRec otvalid_interface
Definition: otvmod.c:241
#define FT_SERVICE_ID_OPENTYPE_VALIDATE
Definition: svotval.h:28

Definition at line 248 of file otvmod.c.

Referenced by otvalid_get_service().