1 /****************************************************************************
5 * TrueTypeGX/AAT morx table validation (body).
7 * Copyright (C) 2005-2023 by
8 * suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
9 * David Turner, Robert Wilhelm, and Werner Lemberg.
11 * This file is part of the FreeType project, and may only be used,
12 * modified, and distributed under the terms of the FreeType project
13 * license, LICENSE.TXT. By continuing to use, modify, or distribute
14 * this file you indicate that you have read the license and
15 * understand and accept it fully.
19 /****************************************************************************
21 * gxvalid is derived from both gxlayout module and otvalid module.
22 * Development of gxlayout is supported by the Information-technology
23 * Promotion Agency(IPA), Japan.
31 /**************************************************************************
33 * The macro FT_COMPONENT is used in trace mode. It is an implicit
34 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
35 * messages during execution.
38 #define FT_COMPONENT gxvmorx
42 gxv_morx_subtables_validate( FT_Bytes table,
45 GXV_Validator gxvalid )
49 GXV_Validate_Func fmt_funcs_table[] =
51 gxv_morx_subtable_type0_validate, /* 0 */
52 gxv_morx_subtable_type1_validate, /* 1 */
53 gxv_morx_subtable_type2_validate, /* 2 */
55 gxv_morx_subtable_type4_validate, /* 4 */
56 gxv_morx_subtable_type5_validate, /* 5 */
63 GXV_NAME_ENTER( "subtables in a chain" );
65 for ( i = 0; i < nSubtables; i++ )
67 GXV_Validate_Func func;
71 #ifdef GXV_LOAD_UNUSED_VARS
72 FT_ULong subFeatureFlags;
78 GXV_LIMIT_CHECK( 4 + 4 + 4 );
79 length = FT_NEXT_ULONG( p );
80 coverage = FT_NEXT_ULONG( p );
81 #ifdef GXV_LOAD_UNUSED_VARS
82 subFeatureFlags = FT_NEXT_ULONG( p );
87 GXV_TRACE(( "validating chain subtable %d/%d (%lu bytes)\n",
88 i + 1, nSubtables, length ));
90 type = coverage & 0x0007;
91 rest = length - ( 4 + 4 + 4 );
92 GXV_LIMIT_CHECK( rest );
94 /* morx coverage consists of mort_coverage & 16bit padding */
95 gxv_mort_coverage_validate( (FT_UShort)( ( coverage >> 16 ) | coverage ),
100 func = fmt_funcs_table[type];
102 GXV_TRACE(( "morx type %lu is reserved\n", type ));
104 func( p, p + rest, gxvalid );
106 /* TODO: subFeatureFlags should be unique in a table? */
110 gxvalid->subtable_length = (FT_ULong)( p - table );
117 gxv_morx_chain_validate( FT_Bytes table,
119 GXV_Validator gxvalid )
122 #ifdef GXV_LOAD_UNUSED_VARS
123 FT_ULong defaultFlags;
125 FT_ULong chainLength;
126 FT_ULong nFeatureFlags;
130 GXV_NAME_ENTER( "morx chain header" );
132 GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
133 #ifdef GXV_LOAD_UNUSED_VARS
134 defaultFlags = FT_NEXT_ULONG( p );
138 chainLength = FT_NEXT_ULONG( p );
139 nFeatureFlags = FT_NEXT_ULONG( p );
140 nSubtables = FT_NEXT_ULONG( p );
142 /* feature-array of morx is same with that of mort */
143 gxv_mort_featurearray_validate( p, limit, nFeatureFlags, gxvalid );
144 p += gxvalid->subtable_length;
146 if ( nSubtables >= 0x10000L )
149 gxv_morx_subtables_validate( p, table + chainLength,
150 (FT_UShort)nSubtables, gxvalid );
152 gxvalid->subtable_length = chainLength;
154 /* TODO: defaultFlags should be compared with the flags in tables */
161 gxv_morx_validate( FT_Bytes table,
163 FT_Validator ftvalid )
165 GXV_ValidatorRec gxvalidrec;
166 GXV_Validator gxvalid = &gxvalidrec;
174 gxvalid->root = ftvalid;
175 gxvalid->face = face;
177 FT_TRACE3(( "validating `morx' table\n" ));
180 GXV_LIMIT_CHECK( 4 + 4 );
181 version = FT_NEXT_ULONG( p );
182 nChains = FT_NEXT_ULONG( p );
184 if ( version != 0x00020000UL )
187 for ( i = 0; i < nChains; i++ )
189 GXV_TRACE(( "validating chain %lu/%lu\n", i + 1, nChains ));
190 GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
191 gxv_morx_chain_validate( p, limit, gxvalid );
192 p += gxvalid->subtable_length;