Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengxvlcar.c
Go to the documentation of this file.
00001 /***************************************************************************/ 00002 /* */ 00003 /* gxvlcar.c */ 00004 /* */ 00005 /* TrueTypeGX/AAT lcar table validation (body). */ 00006 /* */ 00007 /* Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ 00008 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00009 /* */ 00010 /* This file is part of the FreeType project, and may only be used, */ 00011 /* modified, and distributed under the terms of the FreeType project */ 00012 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00013 /* this file you indicate that you have read the license and */ 00014 /* understand and accept it fully. */ 00015 /* */ 00016 /***************************************************************************/ 00017 00018 /***************************************************************************/ 00019 /* */ 00020 /* gxvalid is derived from both gxlayout module and otvalid module. */ 00021 /* Development of gxlayout is supported by the Information-technology */ 00022 /* Promotion Agency(IPA), Japan. */ 00023 /* */ 00024 /***************************************************************************/ 00025 00026 00027 #include "gxvalid.h" 00028 #include "gxvcommn.h" 00029 00030 00031 /*************************************************************************/ 00032 /* */ 00033 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ 00034 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ 00035 /* messages during execution. */ 00036 /* */ 00037 #undef FT_COMPONENT 00038 #define FT_COMPONENT trace_gxvlcar 00039 00040 00041 /*************************************************************************/ 00042 /*************************************************************************/ 00043 /***** *****/ 00044 /***** Data and Types *****/ 00045 /***** *****/ 00046 /*************************************************************************/ 00047 /*************************************************************************/ 00048 00049 typedef struct GXV_lcar_DataRec_ 00050 { 00051 FT_UShort format; 00052 00053 } GXV_lcar_DataRec, *GXV_lcar_Data; 00054 00055 00056 #define GXV_LCAR_DATA( FIELD ) GXV_TABLE_DATA( lcar, FIELD ) 00057 00058 00059 /*************************************************************************/ 00060 /*************************************************************************/ 00061 /***** *****/ 00062 /***** UTILITY FUNCTIONS *****/ 00063 /***** *****/ 00064 /*************************************************************************/ 00065 /*************************************************************************/ 00066 00067 static void 00068 gxv_lcar_partial_validate( FT_UShort partial, 00069 FT_UShort glyph, 00070 GXV_Validator valid ) 00071 { 00072 GXV_NAME_ENTER( "partial" ); 00073 00074 if ( GXV_LCAR_DATA( format ) != 1 ) 00075 goto Exit; 00076 00077 gxv_ctlPoint_validate( glyph, partial, valid ); 00078 00079 Exit: 00080 GXV_EXIT; 00081 } 00082 00083 00084 static void 00085 gxv_lcar_LookupValue_validate( FT_UShort glyph, 00086 GXV_LookupValueCPtr value_p, 00087 GXV_Validator valid ) 00088 { 00089 FT_Bytes p = valid->root->base + value_p->u; 00090 FT_Bytes limit = valid->root->limit; 00091 FT_UShort count; 00092 FT_Short partial; 00093 FT_UShort i; 00094 00095 00096 GXV_NAME_ENTER( "element in lookupTable" ); 00097 00098 GXV_LIMIT_CHECK( 2 ); 00099 count = FT_NEXT_USHORT( p ); 00100 00101 GXV_LIMIT_CHECK( 2 * count ); 00102 for ( i = 0; i < count; i++ ) 00103 { 00104 partial = FT_NEXT_SHORT( p ); 00105 gxv_lcar_partial_validate( partial, glyph, valid ); 00106 } 00107 00108 GXV_EXIT; 00109 } 00110 00111 00112 /* 00113 +------ lcar --------------------+ 00114 | | 00115 | +===============+ | 00116 | | looup header | | 00117 | +===============+ | 00118 | | BinSrchHeader | | 00119 | +===============+ | 00120 | | lastGlyph[0] | | 00121 | +---------------+ | 00122 | | firstGlyph[0] | | head of lcar sfnt table 00123 | +---------------+ | + 00124 | | offset[0] | -> | offset [byte] 00125 | +===============+ | + 00126 | | lastGlyph[1] | | (glyphID - firstGlyph) * 2 [byte] 00127 | +---------------+ | 00128 | | firstGlyph[1] | | 00129 | +---------------+ | 00130 | | offset[1] | | 00131 | +===============+ | 00132 | | 00133 | .... | 00134 | | 00135 | 16bit value array | 00136 | +===============+ | 00137 +------| value | <-------+ 00138 | .... 00139 | 00140 | 00141 | 00142 | 00143 | 00144 +----> lcar values...handled by lcar callback function 00145 */ 00146 00147 static GXV_LookupValueDesc 00148 gxv_lcar_LookupFmt4_transit( FT_UShort relative_gindex, 00149 GXV_LookupValueCPtr base_value_p, 00150 FT_Bytes lookuptbl_limit, 00151 GXV_Validator valid ) 00152 { 00153 FT_Bytes p; 00154 FT_Bytes limit; 00155 FT_UShort offset; 00156 GXV_LookupValueDesc value; 00157 00158 FT_UNUSED( lookuptbl_limit ); 00159 00160 /* XXX: check range? */ 00161 offset = (FT_UShort)( base_value_p->u + 00162 relative_gindex * sizeof ( FT_UShort ) ); 00163 p = valid->root->base + offset; 00164 limit = valid->root->limit; 00165 00166 GXV_LIMIT_CHECK ( 2 ); 00167 value.u = FT_NEXT_USHORT( p ); 00168 00169 return value; 00170 } 00171 00172 00173 /*************************************************************************/ 00174 /*************************************************************************/ 00175 /***** *****/ 00176 /***** lcar TABLE *****/ 00177 /***** *****/ 00178 /*************************************************************************/ 00179 /*************************************************************************/ 00180 00181 FT_LOCAL_DEF( void ) 00182 gxv_lcar_validate( FT_Bytes table, 00183 FT_Face face, 00184 FT_Validator ftvalid ) 00185 { 00186 FT_Bytes p = table; 00187 FT_Bytes limit = 0; 00188 GXV_ValidatorRec validrec; 00189 GXV_Validator valid = &validrec; 00190 00191 GXV_lcar_DataRec lcarrec; 00192 GXV_lcar_Data lcar = &lcarrec; 00193 00194 FT_Fixed version; 00195 00196 00197 valid->root = ftvalid; 00198 valid->table_data = lcar; 00199 valid->face = face; 00200 00201 FT_TRACE3(( "validating `lcar' table\n" )); 00202 GXV_INIT; 00203 00204 GXV_LIMIT_CHECK( 4 + 2 ); 00205 version = FT_NEXT_ULONG( p ); 00206 GXV_LCAR_DATA( format ) = FT_NEXT_USHORT( p ); 00207 00208 if ( version != 0x00010000UL) 00209 FT_INVALID_FORMAT; 00210 00211 if ( GXV_LCAR_DATA( format ) > 1 ) 00212 FT_INVALID_FORMAT; 00213 00214 valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED; 00215 valid->lookupval_func = gxv_lcar_LookupValue_validate; 00216 valid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit; 00217 gxv_LookupTable_validate( p, limit, valid ); 00218 00219 FT_TRACE4(( "\n" )); 00220 } 00221 00222 00223 /* END */ Generated on Sun May 27 2012 04:33:51 for ReactOS by
1.7.6.1
|