Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenotvjstf.c
Go to the documentation of this file.
00001 /***************************************************************************/ 00002 /* */ 00003 /* otvjstf.c */ 00004 /* */ 00005 /* OpenType JSTF table validation (body). */ 00006 /* */ 00007 /* Copyright 2004, 2007 by */ 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 #include "otvalid.h" 00020 #include "otvcommn.h" 00021 #include "otvgpos.h" 00022 00023 00024 /*************************************************************************/ 00025 /* */ 00026 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ 00027 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ 00028 /* messages during execution. */ 00029 /* */ 00030 #undef FT_COMPONENT 00031 #define FT_COMPONENT trace_otvjstf 00032 00033 00034 #define JstfPriorityFunc otv_JstfPriority_validate 00035 #define JstfLookupFunc otv_GPOS_subtable_validate 00036 00037 /* uses valid->extra1 (GSUB lookup count) */ 00038 /* uses valid->extra2 (GPOS lookup count) */ 00039 /* sets valid->extra1 (counter) */ 00040 00041 static void 00042 otv_JstfPriority_validate( FT_Bytes table, 00043 OTV_Validator valid ) 00044 { 00045 FT_Bytes p = table; 00046 FT_UInt table_size; 00047 FT_UInt gsub_lookup_count, gpos_lookup_count; 00048 00049 OTV_OPTIONAL_TABLE( ShrinkageEnableGSUB ); 00050 OTV_OPTIONAL_TABLE( ShrinkageDisableGSUB ); 00051 OTV_OPTIONAL_TABLE( ShrinkageEnableGPOS ); 00052 OTV_OPTIONAL_TABLE( ShrinkageDisableGPOS ); 00053 OTV_OPTIONAL_TABLE( ExtensionEnableGSUB ); 00054 OTV_OPTIONAL_TABLE( ExtensionDisableGSUB ); 00055 OTV_OPTIONAL_TABLE( ExtensionEnableGPOS ); 00056 OTV_OPTIONAL_TABLE( ExtensionDisableGPOS ); 00057 OTV_OPTIONAL_TABLE( ShrinkageJstfMax ); 00058 OTV_OPTIONAL_TABLE( ExtensionJstfMax ); 00059 00060 00061 OTV_ENTER; 00062 OTV_TRACE(( "JstfPriority table\n" )); 00063 00064 OTV_LIMIT_CHECK( 20 ); 00065 00066 gsub_lookup_count = valid->extra1; 00067 gpos_lookup_count = valid->extra2; 00068 00069 table_size = 20; 00070 00071 valid->extra1 = gsub_lookup_count; 00072 00073 OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB ); 00074 OTV_SIZE_CHECK( ShrinkageEnableGSUB ); 00075 if ( ShrinkageEnableGSUB ) 00076 otv_x_ux( table + ShrinkageEnableGSUB, valid ); 00077 00078 OTV_OPTIONAL_OFFSET( ShrinkageDisableGSUB ); 00079 OTV_SIZE_CHECK( ShrinkageDisableGSUB ); 00080 if ( ShrinkageDisableGSUB ) 00081 otv_x_ux( table + ShrinkageDisableGSUB, valid ); 00082 00083 valid->extra1 = gpos_lookup_count; 00084 00085 OTV_OPTIONAL_OFFSET( ShrinkageEnableGPOS ); 00086 OTV_SIZE_CHECK( ShrinkageEnableGPOS ); 00087 if ( ShrinkageEnableGPOS ) 00088 otv_x_ux( table + ShrinkageEnableGPOS, valid ); 00089 00090 OTV_OPTIONAL_OFFSET( ShrinkageDisableGPOS ); 00091 OTV_SIZE_CHECK( ShrinkageDisableGPOS ); 00092 if ( ShrinkageDisableGPOS ) 00093 otv_x_ux( table + ShrinkageDisableGPOS, valid ); 00094 00095 OTV_OPTIONAL_OFFSET( ShrinkageJstfMax ); 00096 OTV_SIZE_CHECK( ShrinkageJstfMax ); 00097 if ( ShrinkageJstfMax ) 00098 { 00099 /* XXX: check lookup types? */ 00100 OTV_NEST2( JstfMax, JstfLookup ); 00101 OTV_RUN( table + ShrinkageJstfMax, valid ); 00102 } 00103 00104 valid->extra1 = gsub_lookup_count; 00105 00106 OTV_OPTIONAL_OFFSET( ExtensionEnableGSUB ); 00107 OTV_SIZE_CHECK( ExtensionEnableGSUB ); 00108 if ( ExtensionEnableGSUB ) 00109 otv_x_ux( table + ExtensionEnableGSUB, valid ); 00110 00111 OTV_OPTIONAL_OFFSET( ExtensionDisableGSUB ); 00112 OTV_SIZE_CHECK( ExtensionDisableGSUB ); 00113 if ( ExtensionDisableGSUB ) 00114 otv_x_ux( table + ExtensionDisableGSUB, valid ); 00115 00116 valid->extra1 = gpos_lookup_count; 00117 00118 OTV_OPTIONAL_OFFSET( ExtensionEnableGPOS ); 00119 OTV_SIZE_CHECK( ExtensionEnableGPOS ); 00120 if ( ExtensionEnableGPOS ) 00121 otv_x_ux( table + ExtensionEnableGPOS, valid ); 00122 00123 OTV_OPTIONAL_OFFSET( ExtensionDisableGPOS ); 00124 OTV_SIZE_CHECK( ExtensionDisableGPOS ); 00125 if ( ExtensionDisableGPOS ) 00126 otv_x_ux( table + ExtensionDisableGPOS, valid ); 00127 00128 OTV_OPTIONAL_OFFSET( ExtensionJstfMax ); 00129 OTV_SIZE_CHECK( ExtensionJstfMax ); 00130 if ( ExtensionJstfMax ) 00131 { 00132 /* XXX: check lookup types? */ 00133 OTV_NEST2( JstfMax, JstfLookup ); 00134 OTV_RUN( table + ExtensionJstfMax, valid ); 00135 } 00136 00137 valid->extra1 = gsub_lookup_count; 00138 valid->extra2 = gpos_lookup_count; 00139 00140 OTV_EXIT; 00141 } 00142 00143 00144 /* sets valid->extra (glyph count) */ 00145 /* sets valid->func1 (otv_JstfPriority_validate) */ 00146 00147 static void 00148 otv_JstfScript_validate( FT_Bytes table, 00149 OTV_Validator valid ) 00150 { 00151 FT_Bytes p = table; 00152 FT_UInt table_size; 00153 FT_UInt JstfLangSysCount; 00154 00155 OTV_OPTIONAL_TABLE( ExtGlyph ); 00156 OTV_OPTIONAL_TABLE( DefJstfLangSys ); 00157 00158 00159 OTV_NAME_ENTER( "JstfScript" ); 00160 00161 OTV_LIMIT_CHECK( 6 ); 00162 OTV_OPTIONAL_OFFSET( ExtGlyph ); 00163 OTV_OPTIONAL_OFFSET( DefJstfLangSys ); 00164 JstfLangSysCount = FT_NEXT_USHORT( p ); 00165 00166 OTV_TRACE(( " (JstfLangSysCount = %d)\n", JstfLangSysCount )); 00167 00168 table_size = JstfLangSysCount * 6 + 6; 00169 00170 OTV_SIZE_CHECK( ExtGlyph ); 00171 if ( ExtGlyph ) 00172 { 00173 valid->extra1 = valid->glyph_count; 00174 OTV_NEST1( ExtenderGlyph ); 00175 OTV_RUN( table + ExtGlyph, valid ); 00176 } 00177 00178 OTV_SIZE_CHECK( DefJstfLangSys ); 00179 if ( DefJstfLangSys ) 00180 { 00181 OTV_NEST2( JstfLangSys, JstfPriority ); 00182 OTV_RUN( table + DefJstfLangSys, valid ); 00183 } 00184 00185 OTV_LIMIT_CHECK( 6 * JstfLangSysCount ); 00186 00187 /* JstfLangSysRecord */ 00188 OTV_NEST2( JstfLangSys, JstfPriority ); 00189 for ( ; JstfLangSysCount > 0; JstfLangSysCount-- ) 00190 { 00191 p += 4; /* skip JstfLangSysTag */ 00192 00193 OTV_RUN( table + FT_NEXT_USHORT( p ), valid ); 00194 } 00195 00196 OTV_EXIT; 00197 } 00198 00199 00200 /* sets valid->extra1 (GSUB lookup count) */ 00201 /* sets valid->extra2 (GPOS lookup count) */ 00202 /* sets valid->glyph_count */ 00203 00204 FT_LOCAL_DEF( void ) 00205 otv_JSTF_validate( FT_Bytes table, 00206 FT_Bytes gsub, 00207 FT_Bytes gpos, 00208 FT_UInt glyph_count, 00209 FT_Validator ftvalid ) 00210 { 00211 OTV_ValidatorRec validrec; 00212 OTV_Validator valid = &validrec; 00213 FT_Bytes p = table; 00214 FT_UInt JstfScriptCount; 00215 00216 00217 valid->root = ftvalid; 00218 00219 FT_TRACE3(( "validating JSTF table\n" )); 00220 OTV_INIT; 00221 00222 OTV_LIMIT_CHECK( 6 ); 00223 00224 if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ 00225 FT_INVALID_FORMAT; 00226 00227 JstfScriptCount = FT_NEXT_USHORT( p ); 00228 00229 FT_TRACE3(( " (JstfScriptCount = %d)\n", JstfScriptCount )); 00230 00231 OTV_LIMIT_CHECK( JstfScriptCount * 6 ); 00232 00233 if ( gsub ) 00234 valid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub ); 00235 else 00236 valid->extra1 = 0; 00237 00238 if ( gpos ) 00239 valid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos ); 00240 else 00241 valid->extra2 = 0; 00242 00243 valid->glyph_count = glyph_count; 00244 00245 /* JstfScriptRecord */ 00246 for ( ; JstfScriptCount > 0; JstfScriptCount-- ) 00247 { 00248 p += 4; /* skip JstfScriptTag */ 00249 00250 /* JstfScript */ 00251 otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), valid ); 00252 } 00253 00254 FT_TRACE4(( "\n" )); 00255 } 00256 00257 00258 /* END */ Generated on Sun May 27 2012 04:33:52 for ReactOS by
1.7.6.1
|