39#define FT_COMPONENT gxvmort
43 gxv_mort_feature_validate( GXV_mort_feature f,
44 GXV_Validator gxvalid )
46 if ( f->featureType >= gxv_feat_registry_length )
48 GXV_TRACE((
"featureType %d is out of registered range, "
49 "setting %d is unchecked\n",
50 f->featureType, f->featureSetting ));
51 GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
53 else if ( !gxv_feat_registry[f->featureType].existence )
55 GXV_TRACE((
"featureType %d is within registered area "
56 "but undefined, setting %d is unchecked\n",
57 f->featureType, f->featureSetting ));
58 GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
62 FT_Byte nSettings_max;
66 nSettings_max = gxv_feat_registry[f->featureType].nSettings;
67 if ( gxv_feat_registry[f->featureType].exclusive )
68 nSettings_max = (FT_Byte)( 2 * nSettings_max );
70 GXV_TRACE((
"featureType %d is registered", f->featureType ));
71 GXV_TRACE((
"setting %d", f->featureSetting ));
73 if ( f->featureSetting > nSettings_max )
75 GXV_TRACE((
"out of defined range %d", nSettings_max ));
76 GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
90 gxv_mort_featurearray_validate( FT_Bytes table,
92 FT_ULong nFeatureFlags,
93 GXV_Validator gxvalid )
98 GXV_mort_featureRec f = GXV_MORT_FEATURE_OFF;
101 GXV_NAME_ENTER(
"mort feature list" );
102 for ( i = 0; i < nFeatureFlags; i++ )
104 GXV_LIMIT_CHECK( 2 + 2 + 4 + 4 );
105 f.featureType = FT_NEXT_USHORT( p );
106 f.featureSetting = FT_NEXT_USHORT( p );
107 f.enableFlags = FT_NEXT_ULONG( p );
108 f.disableFlags = FT_NEXT_ULONG( p );
110 gxv_mort_feature_validate( &f, gxvalid );
113 if ( !IS_GXV_MORT_FEATURE_OFF( f ) )
116 gxvalid->subtable_length = (FT_ULong)( p - table );
122 gxv_mort_coverage_validate( FT_UShort coverage,
123 GXV_Validator gxvalid )
125 FT_UNUSED( gxvalid );
126 FT_UNUSED( coverage );
128#ifdef FT_DEBUG_LEVEL_TRACE
129 if ( coverage & 0x8000U )
130 GXV_TRACE((
" this subtable is for vertical text only\n" ));
132 GXV_TRACE((
" this subtable is for horizontal text only\n" ));
134 if ( coverage & 0x4000 )
135 GXV_TRACE((
" this subtable is applied to glyph array "
136 "in descending order\n" ));
138 GXV_TRACE((
" this subtable is applied to glyph array "
139 "in ascending order\n" ));
141 if ( coverage & 0x2000 )
142 GXV_TRACE((
" this subtable is forcibly applied to "
143 "vertical/horizontal text\n" ));
145 if ( coverage & 0x1FF8 )
146 GXV_TRACE((
" coverage has non-zero bits in reserved area\n" ));
152 gxv_mort_subtables_validate( FT_Bytes table,
154 FT_UShort nSubtables,
155 GXV_Validator gxvalid )
159 GXV_Validate_Func fmt_funcs_table[] =
161 gxv_mort_subtable_type0_validate,
162 gxv_mort_subtable_type1_validate,
163 gxv_mort_subtable_type2_validate,
165 gxv_mort_subtable_type4_validate,
166 gxv_mort_subtable_type5_validate,
173 GXV_NAME_ENTER(
"subtables in a chain" );
175 for ( i = 0; i < nSubtables; i++ )
177 GXV_Validate_Func func;
181#ifdef GXV_LOAD_UNUSED_VARS
182 FT_ULong subFeatureFlags;
188 GXV_LIMIT_CHECK( 2 + 2 + 4 );
189 length = FT_NEXT_USHORT( p );
190 coverage = FT_NEXT_USHORT( p );
191#ifdef GXV_LOAD_UNUSED_VARS
192 subFeatureFlags = FT_NEXT_ULONG( p );
197 GXV_TRACE((
"validating chain subtable %d/%d (%d bytes)\n",
198 i + 1, nSubtables, length ));
199 type = coverage & 0x0007;
200 rest = length - ( 2 + 2 + 4 );
202 GXV_LIMIT_CHECK( rest );
203 gxv_mort_coverage_validate( coverage, gxvalid );
208 func = fmt_funcs_table[type];
210 GXV_TRACE((
"morx type %u is reserved\n", type ));
212 func( p, p + rest, gxvalid );
218 gxvalid->subtable_length = (FT_ULong)( p - table );
225 gxv_mort_chain_validate( FT_Bytes table,
227 GXV_Validator gxvalid )
230#ifdef GXV_LOAD_UNUSED_VARS
231 FT_ULong defaultFlags;
233 FT_ULong chainLength;
234 FT_UShort nFeatureFlags;
235 FT_UShort nSubtables;
238 GXV_NAME_ENTER(
"mort chain header" );
240 GXV_LIMIT_CHECK( 4 + 4 + 2 + 2 );
241#ifdef GXV_LOAD_UNUSED_VARS
242 defaultFlags = FT_NEXT_ULONG( p );
246 chainLength = FT_NEXT_ULONG( p );
247 nFeatureFlags = FT_NEXT_USHORT( p );
248 nSubtables = FT_NEXT_USHORT( p );
250 gxv_mort_featurearray_validate( p, table + chainLength,
251 nFeatureFlags, gxvalid );
252 p += gxvalid->subtable_length;
253 gxv_mort_subtables_validate( p, table + chainLength, nSubtables, gxvalid );
254 gxvalid->subtable_length = chainLength;
262 gxv_mort_validate( FT_Bytes table,
264 FT_Validator ftvalid )
266 GXV_ValidatorRec gxvalidrec;
267 GXV_Validator gxvalid = &gxvalidrec;
275 gxvalid->root = ftvalid;
276 gxvalid->face = face;
277 limit = gxvalid->root->limit;
279 FT_TRACE3((
"validating `mort' table\n" ));
282 GXV_LIMIT_CHECK( 4 + 4 );
283 version = FT_NEXT_ULONG( p );
284 nChains = FT_NEXT_ULONG( p );
286 if (version != 0x00010000UL)
289 for ( i = 0; i < nChains; i++ )
291 GXV_TRACE((
"validating chain %lu/%lu\n", i + 1, nChains ));
292 GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
293 gxv_mort_chain_validate( p, limit, gxvalid );
294 p += gxvalid->subtable_length;