40#define FT_COMPONENT gxvfeat
53 FT_UInt reserved_size;
57 } GXV_feat_DataRec, *GXV_feat_Data;
60#define GXV_FEAT_DATA( field ) GXV_TABLE_DATA( feat, field )
63 typedef enum GXV_FeatureFlagsMask_
65 GXV_FEAT_MASK_EXCLUSIVE_SETTINGS = 0x8000U,
66 GXV_FEAT_MASK_DYNAMIC_DEFAULT = 0x4000,
67 GXV_FEAT_MASK_UNUSED = 0x3F00,
68 GXV_FEAT_MASK_DEFAULT_SETTING = 0x00FF
70 } GXV_FeatureFlagsMask;
82 gxv_feat_registry_validate( FT_UShort feature,
85 GXV_Validator gxvalid )
87 GXV_NAME_ENTER(
"feature in registry" );
89 GXV_TRACE((
" (feature = %u)\n", feature ));
91 if ( feature >= gxv_feat_registry_length )
93 GXV_TRACE((
"feature number %d is out of range %lu\n",
94 feature, gxv_feat_registry_length ));
95 GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
99 if ( gxv_feat_registry[feature].existence == 0 )
101 GXV_TRACE((
"feature number %d is in defined range but doesn't exist\n",
103 GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
107 if ( gxv_feat_registry[feature].apple_reserved )
110 GXV_TRACE((
"feature number %d is reserved by Apple\n", feature ));
111 if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
115 if ( nSettings != gxv_feat_registry[feature].nSettings )
117 GXV_TRACE((
"feature %d: nSettings %d != defined nSettings %d\n",
119 gxv_feat_registry[feature].nSettings ));
120 if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
124 if ( exclusive != gxv_feat_registry[feature].exclusive )
126 GXV_TRACE((
"exclusive flag %d differs from predefined value\n",
128 if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
138 gxv_feat_name_index_validate( FT_Bytes table,
140 GXV_Validator gxvalid )
147 GXV_NAME_ENTER(
"nameIndex" );
149 GXV_LIMIT_CHECK( 2 );
150 nameIndex = FT_NEXT_SHORT ( p );
151 GXV_TRACE((
" (nameIndex = %d)\n", nameIndex ));
153 gxv_sfntName_validate( (FT_UShort)nameIndex,
163 gxv_feat_setting_validate( FT_Bytes table,
166 GXV_Validator gxvalid )
172 GXV_NAME_ENTER(
"setting" );
174 GXV_LIMIT_CHECK( 2 );
176 setting = FT_NEXT_USHORT( p );
179 if ( exclusive && ( setting & 1 ) == 0 )
182 gxv_feat_name_index_validate( p, limit, gxvalid );
184 GXV_FEAT_DATA( setting ) = setting;
191 gxv_feat_name_validate( FT_Bytes table,
193 GXV_Validator gxvalid )
196 FT_UInt reserved_size = GXV_FEAT_DATA( reserved_size );
200 FT_ULong settingTable;
201 FT_UShort featureFlags;
208 GXV_NAME_ENTER(
"name" );
211 GXV_LIMIT_CHECK( 2 + 2 + 4 + 2 );
213 feature = FT_NEXT_USHORT( p );
214 GXV_FEAT_DATA( feature ) = feature;
216 nSettings = FT_NEXT_USHORT( p );
217 settingTable = FT_NEXT_ULONG ( p );
218 featureFlags = FT_NEXT_USHORT( p );
220 if ( settingTable < reserved_size )
223 if ( ( featureFlags & GXV_FEAT_MASK_UNUSED ) == 0 )
224 GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
226 exclusive = FT_BOOL( featureFlags & GXV_FEAT_MASK_EXCLUSIVE_SETTINGS );
229 FT_Byte dynamic_default;
232 if ( featureFlags & GXV_FEAT_MASK_DYNAMIC_DEFAULT )
233 dynamic_default = (FT_Byte)( featureFlags &
234 GXV_FEAT_MASK_DEFAULT_SETTING );
239 if ( !( dynamic_default < nSettings ) )
243 gxv_feat_registry_validate( feature, nSettings, exclusive, gxvalid );
245 gxv_feat_name_index_validate( p, limit, gxvalid );
247 p = gxvalid->root->base + settingTable;
248 for ( last_setting = -1, i = 0; i < nSettings; i++ )
250 gxv_feat_setting_validate( p, limit, exclusive, gxvalid );
252 if ( (FT_Int)GXV_FEAT_DATA( setting ) <= last_setting )
253 GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
255 last_setting = (FT_Int)GXV_FEAT_DATA( setting );
273 gxv_feat_validate( FT_Bytes table,
275 FT_Validator ftvalid )
277 GXV_ValidatorRec gxvalidrec;
278 GXV_Validator gxvalid = &gxvalidrec;
280 GXV_feat_DataRec featrec;
281 GXV_feat_Data feat = &featrec;
286 FT_UInt featureNameCount;
292 gxvalid->root = ftvalid;
293 gxvalid->table_data = feat;
294 gxvalid->face = face;
296 FT_TRACE3((
"validating `feat' table\n" ));
299 feat->reserved_size = 0;
302 GXV_LIMIT_CHECK( 4 + 2 + 2 + 4 );
303 feat->reserved_size += 4 + 2 + 2 + 4;
305 if ( FT_NEXT_ULONG( p ) != 0x00010000UL )
308 featureNameCount = FT_NEXT_USHORT( p );
309 GXV_TRACE((
" (featureNameCount = %u)\n", featureNameCount ));
311 if ( !( IS_PARANOID_VALIDATION ) )
315 if ( FT_NEXT_USHORT( p ) != 0 )
318 if ( FT_NEXT_ULONG( p ) != 0 )
322 feat->reserved_size += featureNameCount * ( 2 + 2 + 4 + 2 + 2 );
324 for ( last_feature = -1, i = 0; i < featureNameCount; i++ )
326 gxv_feat_name_validate( p, limit, gxvalid );
328 if ( (FT_Int)GXV_FEAT_DATA( feature ) <= last_feature )
329 GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
331 last_feature = GXV_FEAT_DATA( feature );
332 p += 2 + 2 + 4 + 2 + 2;