1 /***************************************************************************/
5 /* TrueTypeGX/AAT mort table validation */
6 /* body for type5 (Contextual Glyph Insertion) subtable. */
8 /* Copyright 2005 by 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. */
17 /***************************************************************************/
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. */
25 /***************************************************************************/
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 trace_gxvmort
42 * mort subtable type5 (Contextual Glyph Insertion)
43 * has the format of StateTable with insertion-glyph-list,
44 * but without name. The offset is given by glyphOffset in
45 * entryTable. There is no table location declaration
49 typedef struct GXV_mort_subtable_type5_StateOptRec_
55 #define GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE GXV_STATETABLE_HEADER_SIZE
57 FT_UShort
* classTable_length_p
;
58 FT_UShort
* stateArray_length_p
;
59 FT_UShort
* entryTable_length_p
;
61 } GXV_mort_subtable_type5_StateOptRec
,
62 *GXV_mort_subtable_type5_StateOptRecData
;
66 gxv_mort_subtable_type5_subtable_setup( FT_UShort table_size
,
70 FT_UShort
* classTable_length_p
,
71 FT_UShort
* stateArray_length_p
,
72 FT_UShort
* entryTable_length_p
,
75 GXV_mort_subtable_type5_StateOptRecData optdata
=
76 (GXV_mort_subtable_type5_StateOptRecData
)valid
->statetable
.optdata
;
79 gxv_StateTable_subtable_setup( table_size
,
88 optdata
->classTable
= classTable
;
89 optdata
->stateArray
= stateArray
;
90 optdata
->entryTable
= entryTable
;
92 optdata
->classTable_length_p
= classTable_length_p
;
93 optdata
->stateArray_length_p
= stateArray_length_p
;
94 optdata
->entryTable_length_p
= entryTable_length_p
;
99 gxv_mort_subtable_type5_InsertList_validate( FT_UShort offset
,
103 GXV_Validator valid
)
106 * We don't know the range of insertion-glyph-list.
107 * Set range by whole of state table.
109 FT_Bytes p
= table
+ offset
;
111 GXV_mort_subtable_type5_StateOptRecData optdata
=
112 (GXV_mort_subtable_type5_StateOptRecData
)valid
->statetable
.optdata
;
114 if ( optdata
->classTable
< offset
&&
115 offset
< optdata
->classTable
+ *(optdata
->classTable_length_p
) )
116 GXV_TRACE(( " offset runs into ClassTable" ));
117 if ( optdata
->stateArray
< offset
&&
118 offset
< optdata
->stateArray
+ *(optdata
->stateArray_length_p
) )
119 GXV_TRACE(( " offset runs into StateArray" ));
120 if ( optdata
->entryTable
< offset
&&
121 offset
< optdata
->entryTable
+ *(optdata
->entryTable_length_p
) )
122 GXV_TRACE(( " offset runs into EntryTable" ));
124 while ( p
< table
+ offset
+ ( count
* 2 ) )
126 FT_UShort insert_glyphID
;
129 GXV_LIMIT_CHECK( 2 );
130 insert_glyphID
= FT_NEXT_USHORT( p
);
131 GXV_TRACE(( " 0x%04x", insert_glyphID
));
139 gxv_mort_subtable_type5_entry_validate(
142 GXV_StateTable_GlyphOffsetDesc glyphOffset
,
145 GXV_Validator valid
)
149 FT_Bool currentIsKashidaLike
;
150 FT_Bool markedIsKashidaLike
;
151 FT_Bool currentInsertBefore
;
152 FT_Bool markedInsertBefore
;
153 FT_Byte currentInsertCount
;
154 FT_Byte markedInsertCount
;
155 FT_UShort currentInsertList
;
156 FT_UShort markedInsertList
;
161 setMark
= FT_BOOL( ( flags
>> 15 ) & 1 );
162 dontAdvance
= FT_BOOL( ( flags
>> 14 ) & 1 );
163 currentIsKashidaLike
= FT_BOOL( ( flags
>> 13 ) & 1 );
164 markedIsKashidaLike
= FT_BOOL( ( flags
>> 12 ) & 1 );
165 currentInsertBefore
= FT_BOOL( ( flags
>> 11 ) & 1 );
166 markedInsertBefore
= FT_BOOL( ( flags
>> 10 ) & 1 );
168 currentInsertCount
= (FT_Byte
)( ( flags
>> 5 ) & 0x1F );
169 markedInsertCount
= (FT_Byte
)( flags
& 0x001F );
171 currentInsertList
= (FT_UShort
)( glyphOffset
.ul
>> 16 );
172 markedInsertList
= (FT_UShort
)( glyphOffset
.ul
);
174 if ( 0 != currentInsertList
&& 0 != currentInsertCount
)
176 gxv_mort_subtable_type5_InsertList_validate( currentInsertList
,
183 if ( 0 != markedInsertList
&& 0 != markedInsertCount
)
185 gxv_mort_subtable_type5_InsertList_validate( markedInsertList
,
195 gxv_mort_subtable_type5_validate( FT_Bytes table
,
197 GXV_Validator valid
)
201 GXV_mort_subtable_type5_StateOptRec et_rec
;
202 GXV_mort_subtable_type5_StateOptRecData et
= &et_rec
;
205 GXV_NAME_ENTER( "mort chain subtable type5 (Glyph Insertion)" );
207 GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE
);
209 valid
->statetable
.optdata
=
211 valid
->statetable
.optdata_load_func
=
213 valid
->statetable
.subtable_setup_func
=
214 gxv_mort_subtable_type5_subtable_setup
;
215 valid
->statetable
.entry_glyphoffset_fmt
=
216 GXV_GLYPHOFFSET_ULONG
;
217 valid
->statetable
.entry_validate_func
=
218 gxv_mort_subtable_type5_entry_validate
;
220 gxv_StateTable_validate( p
, limit
, valid
);