1
/***************************************************************************/
5
/* FreeType's TrueTypeGX/AAT validation module implementation (body). */
7
/* Copyright 2004, 2005, 2006 */
8
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
9
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11
/* This file is part of the FreeType project, and may only be used, */
12
/* modified, and distributed under the terms of the FreeType project */
13
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14
/* this file you indicate that you have read the license and */
15
/* understand and accept it fully. */
17
/***************************************************************************/
19
/***************************************************************************/
21
/* gxvalid is derived from both gxlayout module and otvalid module. */
22
/* Development of gxlayout is supported by the Information-technology */
23
/* Promotion Agency(IPA), Japan. */
25
/***************************************************************************/
29
#include FT_TRUETYPE_TABLES_H
30
#include FT_TRUETYPE_TAGS_H
31
#include FT_GX_VALIDATE_H
32
#include FT_INTERNAL_OBJECTS_H
33
#include FT_SERVICE_GX_VALIDATE_H
40
/*************************************************************************/
42
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
43
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
44
/* messages during execution. */
47
#define FT_COMPONENT trace_gxvmodule
51
gxv_load_table( FT_Face face,
53
FT_Byte* volatile* table,
57
FT_Memory memory = FT_FACE_MEMORY( face );
60
error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
61
if ( error == GXV_Err_Table_Missing )
66
if ( FT_ALLOC( *table, *table_len ) )
69
error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len );
76
#define GXV_TABLE_DECL( _sfnt ) \
77
FT_Byte* volatile _sfnt = NULL; \
78
FT_ULong len_ ## _sfnt = 0
80
#define GXV_TABLE_LOAD( _sfnt ) \
81
if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \
82
( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \
84
error = gxv_load_table( face, TTAG_ ## _sfnt, \
85
&_sfnt, &len_ ## _sfnt ); \
90
#define GXV_TABLE_VALIDATE( _sfnt ) \
93
ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \
94
FT_VALIDATE_DEFAULT ); \
95
if ( ft_setjmp( valid.jump_buffer ) == 0 ) \
96
gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \
97
error = valid.error; \
102
#define GXV_TABLE_SET( _sfnt ) \
103
if ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) \
104
tables[FT_VALIDATE_ ## _sfnt ## _INDEX] = (FT_Bytes)_sfnt
108
gxv_validate( FT_Face face,
110
FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
111
FT_UInt table_count )
113
FT_Memory volatile memory = FT_FACE_MEMORY( face );
115
FT_Error error = GXV_Err_Ok;
116
FT_ValidatorRec volatile valid;
121
GXV_TABLE_DECL( feat );
122
GXV_TABLE_DECL( bsln );
123
GXV_TABLE_DECL( trak );
124
GXV_TABLE_DECL( just );
125
GXV_TABLE_DECL( mort );
126
GXV_TABLE_DECL( morx );
127
GXV_TABLE_DECL( kern );
128
GXV_TABLE_DECL( opbd );
129
GXV_TABLE_DECL( prop );
130
GXV_TABLE_DECL( lcar );
132
for ( i = 0; i < table_count; i++ )
136
GXV_TABLE_LOAD( feat );
137
GXV_TABLE_LOAD( bsln );
138
GXV_TABLE_LOAD( trak );
139
GXV_TABLE_LOAD( just );
140
GXV_TABLE_LOAD( mort );
141
GXV_TABLE_LOAD( morx );
142
GXV_TABLE_LOAD( kern );
143
GXV_TABLE_LOAD( opbd );
144
GXV_TABLE_LOAD( prop );
145
GXV_TABLE_LOAD( lcar );
147
/* validate tables */
148
GXV_TABLE_VALIDATE( feat );
149
GXV_TABLE_VALIDATE( bsln );
150
GXV_TABLE_VALIDATE( trak );
151
GXV_TABLE_VALIDATE( just );
152
GXV_TABLE_VALIDATE( mort );
153
GXV_TABLE_VALIDATE( morx );
154
GXV_TABLE_VALIDATE( kern );
155
GXV_TABLE_VALIDATE( opbd );
156
GXV_TABLE_VALIDATE( prop );
157
GXV_TABLE_VALIDATE( lcar );
160
GXV_TABLE_SET( feat );
161
GXV_TABLE_SET( mort );
162
GXV_TABLE_SET( morx );
163
GXV_TABLE_SET( bsln );
164
GXV_TABLE_SET( just );
165
GXV_TABLE_SET( kern );
166
GXV_TABLE_SET( opbd );
167
GXV_TABLE_SET( trak );
168
GXV_TABLE_SET( prop );
169
GXV_TABLE_SET( lcar );
191
classic_kern_validate( FT_Face face,
193
FT_Bytes* ckern_table )
195
FT_Memory volatile memory = FT_FACE_MEMORY( face );
197
FT_Byte* volatile ckern = NULL;
198
FT_ULong len_ckern = 0;
200
/* without volatile on `error' GCC 4.1.1. emits: */
201
/* warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */
202
/* this warning seems spurious but --- */
203
FT_Error volatile error = GXV_Err_Ok;
204
FT_ValidatorRec volatile valid;
209
error = gxv_load_table( face, TTAG_kern, &ckern, &len_ckern );
215
ft_validator_init( &valid, ckern, ckern + len_ckern,
216
FT_VALIDATE_DEFAULT );
217
if ( ft_setjmp( valid.jump_buffer ) == 0 )
218
gxv_kern_validate_classic( ckern, face,
219
ckern_flags & FT_VALIDATE_CKERN, &valid );
225
*ckern_table = ckern;
236
const FT_Service_GXvalidateRec gxvalid_interface =
243
const FT_Service_CKERNvalidateRec ckernvalid_interface =
245
classic_kern_validate
250
const FT_ServiceDescRec gxvalid_services[] =
252
{ FT_SERVICE_ID_GX_VALIDATE, &gxvalid_interface },
253
{ FT_SERVICE_ID_CLASSICKERN_VALIDATE, &ckernvalid_interface },
259
gxvalid_get_service( FT_Module module,
260
const char* service_id )
264
return ft_service_list_lookup( gxvalid_services, service_id );
268
FT_CALLBACK_TABLE_DEF
269
const FT_Module_Class gxv_module_class =
272
sizeof( FT_ModuleRec ),
277
0, /* module-specific interface */
279
(FT_Module_Constructor)0,
280
(FT_Module_Destructor) 0,
281
(FT_Module_Requester) gxvalid_get_service