1 /****************************************************************************
5 * TrueTypeGX/AAT mort table validation
6 * body for type5 (Contextual Glyph Insertion) subtable.
8 * Copyright (C) 2005-2023 by
9 * suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
10 * David Turner, Robert Wilhelm, and Werner Lemberg.
12 * This file is part of the FreeType project, and may only be used,
13 * modified, and distributed under the terms of the FreeType project
14 * license, LICENSE.TXT. By continuing to use, modify, or distribute
15 * this file you indicate that you have read the license and
16 * understand and accept it fully.
20 /****************************************************************************
22 * gxvalid is derived from both gxlayout module and otvalid module.
23 * Development of gxlayout is supported by the Information-technology
24 * Promotion Agency(IPA), Japan.
32 /**************************************************************************
34 * The macro FT_COMPONENT is used in trace mode. It is an implicit
35 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
36 * messages during execution.
39 #define FT_COMPONENT gxvmort
43 * mort subtable type5 (Contextual Glyph Insertion)
44 * has the format of StateTable with insertion-glyph-list,
45 * but without name. The offset is given by glyphOffset in
46 * entryTable. There is no table location declaration
50 typedef struct GXV_mort_subtable_type5_StateOptRec_
56 #define GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE GXV_STATETABLE_HEADER_SIZE
58 FT_UShort* classTable_length_p;
59 FT_UShort* stateArray_length_p;
60 FT_UShort* entryTable_length_p;
62 } GXV_mort_subtable_type5_StateOptRec,
63 *GXV_mort_subtable_type5_StateOptRecData;
67 gxv_mort_subtable_type5_subtable_setup( FT_UShort table_size,
71 FT_UShort* classTable_length_p,
72 FT_UShort* stateArray_length_p,
73 FT_UShort* entryTable_length_p,
74 GXV_Validator gxvalid )
76 GXV_mort_subtable_type5_StateOptRecData optdata =
77 (GXV_mort_subtable_type5_StateOptRecData)gxvalid->statetable.optdata;
80 gxv_StateTable_subtable_setup( table_size,
89 optdata->classTable = classTable;
90 optdata->stateArray = stateArray;
91 optdata->entryTable = entryTable;
93 optdata->classTable_length_p = classTable_length_p;
94 optdata->stateArray_length_p = stateArray_length_p;
95 optdata->entryTable_length_p = entryTable_length_p;
100 gxv_mort_subtable_type5_InsertList_validate( FT_UShort offset,
104 GXV_Validator gxvalid )
107 * We don't know the range of insertion-glyph-list.
108 * Set range by whole of state table.
110 FT_Bytes p = table + offset;
112 GXV_mort_subtable_type5_StateOptRecData optdata =
113 (GXV_mort_subtable_type5_StateOptRecData)gxvalid->statetable.optdata;
115 if ( optdata->classTable < offset &&
116 offset < optdata->classTable + *(optdata->classTable_length_p) )
117 GXV_TRACE(( " offset runs into ClassTable" ));
118 if ( optdata->stateArray < offset &&
119 offset < optdata->stateArray + *(optdata->stateArray_length_p) )
120 GXV_TRACE(( " offset runs into StateArray" ));
121 if ( optdata->entryTable < offset &&
122 offset < optdata->entryTable + *(optdata->entryTable_length_p) )
123 GXV_TRACE(( " offset runs into EntryTable" ));
125 #ifndef GXV_LOAD_TRACE_VARS
126 GXV_LIMIT_CHECK( count * 2 );
128 while ( p < table + offset + ( count * 2 ) )
130 FT_UShort insert_glyphID;
133 GXV_LIMIT_CHECK( 2 );
134 insert_glyphID = FT_NEXT_USHORT( p );
135 GXV_TRACE(( " 0x%04x", insert_glyphID ));
143 gxv_mort_subtable_type5_entry_validate(
146 GXV_StateTable_GlyphOffsetCPtr glyphOffset,
149 GXV_Validator gxvalid )
151 #ifdef GXV_LOAD_UNUSED_VARS
154 FT_Bool currentIsKashidaLike;
155 FT_Bool markedIsKashidaLike;
156 FT_Bool currentInsertBefore;
157 FT_Bool markedInsertBefore;
159 FT_Byte currentInsertCount;
160 FT_Byte markedInsertCount;
161 FT_UShort currentInsertList;
162 FT_UShort markedInsertList;
167 #ifdef GXV_LOAD_UNUSED_VARS
168 setMark = FT_BOOL( ( flags >> 15 ) & 1 );
169 dontAdvance = FT_BOOL( ( flags >> 14 ) & 1 );
170 currentIsKashidaLike = FT_BOOL( ( flags >> 13 ) & 1 );
171 markedIsKashidaLike = FT_BOOL( ( flags >> 12 ) & 1 );
172 currentInsertBefore = FT_BOOL( ( flags >> 11 ) & 1 );
173 markedInsertBefore = FT_BOOL( ( flags >> 10 ) & 1 );
176 currentInsertCount = (FT_Byte)( ( flags >> 5 ) & 0x1F );
177 markedInsertCount = (FT_Byte)( flags & 0x001F );
179 currentInsertList = (FT_UShort)( glyphOffset->ul >> 16 );
180 markedInsertList = (FT_UShort)( glyphOffset->ul );
182 if ( 0 != currentInsertList && 0 != currentInsertCount )
184 gxv_mort_subtable_type5_InsertList_validate( currentInsertList,
191 if ( 0 != markedInsertList && 0 != markedInsertCount )
193 gxv_mort_subtable_type5_InsertList_validate( markedInsertList,
203 gxv_mort_subtable_type5_validate( FT_Bytes table,
205 GXV_Validator gxvalid )
209 GXV_mort_subtable_type5_StateOptRec et_rec;
210 GXV_mort_subtable_type5_StateOptRecData et = &et_rec;
213 GXV_NAME_ENTER( "mort chain subtable type5 (Glyph Insertion)" );
215 GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE );
217 gxvalid->statetable.optdata =
219 gxvalid->statetable.optdata_load_func =
221 gxvalid->statetable.subtable_setup_func =
222 gxv_mort_subtable_type5_subtable_setup;
223 gxvalid->statetable.entry_glyphoffset_fmt =
224 GXV_GLYPHOFFSET_ULONG;
225 gxvalid->statetable.entry_validate_func =
226 gxv_mort_subtable_type5_entry_validate;
228 gxv_StateTable_validate( p, limit, gxvalid );