Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengxvmod.c
Go to the documentation of this file.
00001 /***************************************************************************/ 00002 /* */ 00003 /* gxvmod.c */ 00004 /* */ 00005 /* FreeType's TrueTypeGX/AAT validation module implementation (body). */ 00006 /* */ 00007 /* Copyright 2004, 2005, 2006 */ 00008 /* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ 00009 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00010 /* */ 00011 /* This file is part of the FreeType project, and may only be used, */ 00012 /* modified, and distributed under the terms of the FreeType project */ 00013 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00014 /* this file you indicate that you have read the license and */ 00015 /* understand and accept it fully. */ 00016 /* */ 00017 /***************************************************************************/ 00018 00019 /***************************************************************************/ 00020 /* */ 00021 /* gxvalid is derived from both gxlayout module and otvalid module. */ 00022 /* Development of gxlayout is supported by the Information-technology */ 00023 /* Promotion Agency(IPA), Japan. */ 00024 /* */ 00025 /***************************************************************************/ 00026 00027 00028 #include <ft2build.h> 00029 #include FT_TRUETYPE_TABLES_H 00030 #include FT_TRUETYPE_TAGS_H 00031 #include FT_GX_VALIDATE_H 00032 #include FT_INTERNAL_OBJECTS_H 00033 #include FT_SERVICE_GX_VALIDATE_H 00034 00035 #include "gxvmod.h" 00036 #include "gxvalid.h" 00037 #include "gxvcommn.h" 00038 00039 00040 /*************************************************************************/ 00041 /* */ 00042 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ 00043 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ 00044 /* messages during execution. */ 00045 /* */ 00046 #undef FT_COMPONENT 00047 #define FT_COMPONENT trace_gxvmodule 00048 00049 00050 static FT_Error 00051 gxv_load_table( FT_Face face, 00052 FT_Tag tag, 00053 FT_Byte* volatile* table, 00054 FT_ULong* table_len ) 00055 { 00056 FT_Error error; 00057 FT_Memory memory = FT_FACE_MEMORY( face ); 00058 00059 00060 error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len ); 00061 if ( error == GXV_Err_Table_Missing ) 00062 return GXV_Err_Ok; 00063 if ( error ) 00064 goto Exit; 00065 00066 if ( FT_ALLOC( *table, *table_len ) ) 00067 goto Exit; 00068 00069 error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len ); 00070 00071 Exit: 00072 return error; 00073 } 00074 00075 00076 #define GXV_TABLE_DECL( _sfnt ) \ 00077 FT_Byte* volatile _sfnt = NULL; \ 00078 FT_ULong len_ ## _sfnt = 0 00079 00080 #define GXV_TABLE_LOAD( _sfnt ) \ 00081 if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \ 00082 ( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \ 00083 { \ 00084 error = gxv_load_table( face, TTAG_ ## _sfnt, \ 00085 &_sfnt, &len_ ## _sfnt ); \ 00086 if ( error ) \ 00087 goto Exit; \ 00088 } 00089 00090 #define GXV_TABLE_VALIDATE( _sfnt ) \ 00091 if ( _sfnt ) \ 00092 { \ 00093 ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \ 00094 FT_VALIDATE_DEFAULT ); \ 00095 if ( ft_setjmp( valid.jump_buffer ) == 0 ) \ 00096 gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \ 00097 error = valid.error; \ 00098 if ( error ) \ 00099 goto Exit; \ 00100 } 00101 00102 #define GXV_TABLE_SET( _sfnt ) \ 00103 if ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) \ 00104 tables[FT_VALIDATE_ ## _sfnt ## _INDEX] = (FT_Bytes)_sfnt 00105 00106 00107 static FT_Error 00108 gxv_validate( FT_Face face, 00109 FT_UInt gx_flags, 00110 FT_Bytes tables[FT_VALIDATE_GX_LENGTH], 00111 FT_UInt table_count ) 00112 { 00113 FT_Memory volatile memory = FT_FACE_MEMORY( face ); 00114 00115 FT_Error error = GXV_Err_Ok; 00116 FT_ValidatorRec volatile valid; 00117 00118 FT_UInt i; 00119 00120 00121 GXV_TABLE_DECL( feat ); 00122 GXV_TABLE_DECL( bsln ); 00123 GXV_TABLE_DECL( trak ); 00124 GXV_TABLE_DECL( just ); 00125 GXV_TABLE_DECL( mort ); 00126 GXV_TABLE_DECL( morx ); 00127 GXV_TABLE_DECL( kern ); 00128 GXV_TABLE_DECL( opbd ); 00129 GXV_TABLE_DECL( prop ); 00130 GXV_TABLE_DECL( lcar ); 00131 00132 for ( i = 0; i < table_count; i++ ) 00133 tables[i] = 0; 00134 00135 /* load tables */ 00136 GXV_TABLE_LOAD( feat ); 00137 GXV_TABLE_LOAD( bsln ); 00138 GXV_TABLE_LOAD( trak ); 00139 GXV_TABLE_LOAD( just ); 00140 GXV_TABLE_LOAD( mort ); 00141 GXV_TABLE_LOAD( morx ); 00142 GXV_TABLE_LOAD( kern ); 00143 GXV_TABLE_LOAD( opbd ); 00144 GXV_TABLE_LOAD( prop ); 00145 GXV_TABLE_LOAD( lcar ); 00146 00147 /* validate tables */ 00148 GXV_TABLE_VALIDATE( feat ); 00149 GXV_TABLE_VALIDATE( bsln ); 00150 GXV_TABLE_VALIDATE( trak ); 00151 GXV_TABLE_VALIDATE( just ); 00152 GXV_TABLE_VALIDATE( mort ); 00153 GXV_TABLE_VALIDATE( morx ); 00154 GXV_TABLE_VALIDATE( kern ); 00155 GXV_TABLE_VALIDATE( opbd ); 00156 GXV_TABLE_VALIDATE( prop ); 00157 GXV_TABLE_VALIDATE( lcar ); 00158 00159 /* Set results */ 00160 GXV_TABLE_SET( feat ); 00161 GXV_TABLE_SET( mort ); 00162 GXV_TABLE_SET( morx ); 00163 GXV_TABLE_SET( bsln ); 00164 GXV_TABLE_SET( just ); 00165 GXV_TABLE_SET( kern ); 00166 GXV_TABLE_SET( opbd ); 00167 GXV_TABLE_SET( trak ); 00168 GXV_TABLE_SET( prop ); 00169 GXV_TABLE_SET( lcar ); 00170 00171 Exit: 00172 if ( error ) 00173 { 00174 FT_FREE( feat ); 00175 FT_FREE( bsln ); 00176 FT_FREE( trak ); 00177 FT_FREE( just ); 00178 FT_FREE( mort ); 00179 FT_FREE( morx ); 00180 FT_FREE( kern ); 00181 FT_FREE( opbd ); 00182 FT_FREE( prop ); 00183 FT_FREE( lcar ); 00184 } 00185 00186 return error; 00187 } 00188 00189 00190 static FT_Error 00191 classic_kern_validate( FT_Face face, 00192 FT_UInt ckern_flags, 00193 FT_Bytes* ckern_table ) 00194 { 00195 FT_Memory volatile memory = FT_FACE_MEMORY( face ); 00196 00197 FT_Byte* volatile ckern = NULL; 00198 FT_ULong len_ckern = 0; 00199 00200 /* without volatile on `error' GCC 4.1.1. emits: */ 00201 /* warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */ 00202 /* this warning seems spurious but --- */ 00203 FT_Error volatile error = GXV_Err_Ok; 00204 FT_ValidatorRec volatile valid; 00205 00206 00207 *ckern_table = NULL; 00208 00209 error = gxv_load_table( face, TTAG_kern, &ckern, &len_ckern ); 00210 if ( error ) 00211 goto Exit; 00212 00213 if ( ckern ) 00214 { 00215 ft_validator_init( &valid, ckern, ckern + len_ckern, 00216 FT_VALIDATE_DEFAULT ); 00217 if ( ft_setjmp( valid.jump_buffer ) == 0 ) 00218 gxv_kern_validate_classic( ckern, face, 00219 ckern_flags & FT_VALIDATE_CKERN, &valid ); 00220 error = valid.error; 00221 if ( error ) 00222 goto Exit; 00223 } 00224 00225 *ckern_table = ckern; 00226 00227 Exit: 00228 if ( error ) 00229 FT_FREE( ckern ); 00230 00231 return error; 00232 } 00233 00234 00235 static 00236 const FT_Service_GXvalidateRec gxvalid_interface = 00237 { 00238 gxv_validate 00239 }; 00240 00241 00242 static 00243 const FT_Service_CKERNvalidateRec ckernvalid_interface = 00244 { 00245 classic_kern_validate 00246 }; 00247 00248 00249 static 00250 const FT_ServiceDescRec gxvalid_services[] = 00251 { 00252 { FT_SERVICE_ID_GX_VALIDATE, &gxvalid_interface }, 00253 { FT_SERVICE_ID_CLASSICKERN_VALIDATE, &ckernvalid_interface }, 00254 { NULL, NULL } 00255 }; 00256 00257 00258 static FT_Pointer 00259 gxvalid_get_service( FT_Module module, 00260 const char* service_id ) 00261 { 00262 FT_UNUSED( module ); 00263 00264 return ft_service_list_lookup( gxvalid_services, service_id ); 00265 } 00266 00267 00268 FT_CALLBACK_TABLE_DEF 00269 const FT_Module_Class gxv_module_class = 00270 { 00271 0, 00272 sizeof( FT_ModuleRec ), 00273 "gxvalid", 00274 0x10000L, 00275 0x20000L, 00276 00277 0, /* module-specific interface */ 00278 00279 (FT_Module_Constructor)0, 00280 (FT_Module_Destructor) 0, 00281 (FT_Module_Requester) gxvalid_get_service 00282 }; 00283 00284 00285 /* END */ Generated on Sun May 27 2012 04:33:51 for ReactOS by
1.7.6.1
|