1 /***************************************************************************/
5 /* TrueTypeGX/AAT morx table validation (body). */
7 /* Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
18 /***************************************************************************/
20 /* gxvalid is derived from both gxlayout module and otvalid module. */
21 /* Development of gxlayout is supported by the Information-technology */
22 /* Promotion Agency(IPA), Japan. */
24 /***************************************************************************/
30 /*************************************************************************/
32 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
33 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
34 /* messages during execution. */
37 #define FT_COMPONENT trace_gxvmorx
41 gxv_morx_subtables_validate( FT_Bytes table
,
48 GXV_Validate_Func fmt_funcs_table
[] =
50 gxv_morx_subtable_type0_validate
, /* 0 */
51 gxv_morx_subtable_type1_validate
, /* 1 */
52 gxv_morx_subtable_type2_validate
, /* 2 */
54 gxv_morx_subtable_type4_validate
, /* 4 */
55 gxv_morx_subtable_type5_validate
, /* 5 */
59 GXV_Validate_Func func
;
64 GXV_NAME_ENTER( "subtables in a chain" );
66 for ( i
= 0; i
< nSubtables
; i
++ )
70 FT_ULong subFeatureFlags
;
75 GXV_LIMIT_CHECK( 4 + 4 + 4 );
76 length
= FT_NEXT_ULONG( p
);
77 coverage
= FT_NEXT_ULONG( p
);
78 subFeatureFlags
= FT_NEXT_ULONG( p
);
80 GXV_TRACE(( "validating chain subtable %d/%d (%d bytes)\n",
81 i
+ 1, nSubtables
, length
));
83 type
= coverage
& 0x0007;
84 rest
= length
- ( 4 + 4 + 4 );
85 GXV_LIMIT_CHECK( rest
);
87 /* morx coverage consists of mort_coverage & 16bit padding */
88 gxv_mort_coverage_validate( (FT_UShort
)( ( coverage
>> 16 ) | coverage
),
93 func
= fmt_funcs_table
[type
];
95 GXV_TRACE(( "morx type %d is reserved\n", type
));
97 func( p
, p
+ rest
, valid
);
102 valid
->subtable_length
= p
- table
;
109 gxv_morx_chain_validate( FT_Bytes table
,
111 GXV_Validator valid
)
114 FT_ULong defaultFlags
;
115 FT_ULong chainLength
;
116 FT_ULong nFeatureFlags
;
120 GXV_NAME_ENTER( "morx chain header" );
122 GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
123 defaultFlags
= FT_NEXT_ULONG( p
);
124 chainLength
= FT_NEXT_ULONG( p
);
125 nFeatureFlags
= FT_NEXT_ULONG( p
);
126 nSubtables
= FT_NEXT_ULONG( p
);
128 /* feature-array of morx is same with that of mort */
129 gxv_mort_featurearray_validate( p
, limit
, nFeatureFlags
, valid
);
130 p
+= valid
->subtable_length
;
132 if ( nSubtables
>= 0x10000 )
135 gxv_morx_subtables_validate( p
, table
+ chainLength
,
136 (FT_UShort
)nSubtables
, valid
);
138 valid
->subtable_length
= chainLength
;
145 gxv_morx_validate( FT_Bytes table
,
147 FT_Validator ftvalid
)
149 GXV_ValidatorRec validrec
;
150 GXV_Validator valid
= &validrec
;
158 valid
->root
= ftvalid
;
161 FT_TRACE3(( "validating `morx' table\n" ));
164 GXV_LIMIT_CHECK( 4 + 4 );
165 version
= FT_NEXT_ULONG( p
);
166 nChains
= FT_NEXT_ULONG( p
);
168 if ( version
!= 0x00020000UL
)
171 for ( i
= 0; i
< nChains
; i
++ )
173 GXV_TRACE(( "validating chain %d/%d\n", i
+ 1, nChains
));
174 GXV_32BIT_ALIGNMENT_VALIDATE( p
- table
);
175 gxv_morx_chain_validate( p
, limit
, valid
);
176 p
+= valid
->subtable_length
;