1 /***************************************************************************/
5 /* TrueTypeGX/AAT morx table validation */
6 /* body for type5 (Contextual Glyph Insertion) subtable. */
8 /* Copyright 2005, 2007 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_gxvmorx
42 * `morx' subtable type5 (Contextual Glyph Insertion)
43 * has format of a StateTable with insertion-glyph-list
44 * without name. However, the 32bit offset from the head
45 * of subtable to the i-g-l is given after `entryTable',
46 * without variable name specification (the existence of
47 * this offset to the table is different from mort type5).
51 typedef struct GXV_morx_subtable_type5_StateOptRec_
53 FT_ULong insertionGlyphList
;
54 FT_ULong insertionGlyphList_length
;
56 } GXV_morx_subtable_type5_StateOptRec
,
57 *GXV_morx_subtable_type5_StateOptRecData
;
60 #define GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE \
61 ( GXV_STATETABLE_HEADER_SIZE + 4 )
65 gxv_morx_subtable_type5_insertionGlyphList_load( FT_Bytes table
,
67 GXV_Validator gxvalid
)
71 GXV_morx_subtable_type5_StateOptRecData optdata
=
72 (GXV_morx_subtable_type5_StateOptRecData
)gxvalid
->xstatetable
.optdata
;
76 optdata
->insertionGlyphList
= FT_NEXT_ULONG( p
);
81 gxv_morx_subtable_type5_subtable_setup( FT_ULong table_size
,
85 FT_ULong
* classTable_length_p
,
86 FT_ULong
* stateArray_length_p
,
87 FT_ULong
* entryTable_length_p
,
88 GXV_Validator gxvalid
)
94 GXV_morx_subtable_type5_StateOptRecData optdata
=
95 (GXV_morx_subtable_type5_StateOptRecData
)gxvalid
->xstatetable
.optdata
;
101 o
[3] = optdata
->insertionGlyphList
;
102 l
[0] = classTable_length_p
;
103 l
[1] = stateArray_length_p
;
104 l
[2] = entryTable_length_p
;
105 l
[3] = &(optdata
->insertionGlyphList_length
);
107 gxv_set_length_by_ulong_offset( o
, l
, buff
, 4, table_size
, gxvalid
);
112 gxv_morx_subtable_type5_InsertList_validate( FT_UShort table_index
,
116 GXV_Validator gxvalid
)
118 FT_Bytes p
= table
+ table_index
* 2;
121 #ifndef GXV_LOAD_TRACE_VARS
122 GXV_LIMIT_CHECK( count
* 2 );
124 while ( p
< table
+ count
* 2 + table_index
* 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
));
140 gxv_morx_subtable_type5_entry_validate(
143 GXV_StateTable_GlyphOffsetCPtr glyphOffset_p
,
146 GXV_Validator gxvalid
)
148 #ifdef GXV_LOAD_UNUSED_VARS
151 FT_Bool currentIsKashidaLike
;
152 FT_Bool markedIsKashidaLike
;
153 FT_Bool currentInsertBefore
;
154 FT_Bool markedInsertBefore
;
156 FT_Byte currentInsertCount
;
157 FT_Byte markedInsertCount
;
158 FT_Byte currentInsertList
;
159 FT_UShort markedInsertList
;
164 #ifdef GXV_LOAD_UNUSED_VARS
165 setMark
= FT_BOOL( ( flags
>> 15 ) & 1 );
166 dontAdvance
= FT_BOOL( ( flags
>> 14 ) & 1 );
167 currentIsKashidaLike
= FT_BOOL( ( flags
>> 13 ) & 1 );
168 markedIsKashidaLike
= FT_BOOL( ( flags
>> 12 ) & 1 );
169 currentInsertBefore
= FT_BOOL( ( flags
>> 11 ) & 1 );
170 markedInsertBefore
= FT_BOOL( ( flags
>> 10 ) & 1 );
173 currentInsertCount
= (FT_Byte
)( ( flags
>> 5 ) & 0x1F );
174 markedInsertCount
= (FT_Byte
)( flags
& 0x001F );
176 currentInsertList
= (FT_Byte
) ( glyphOffset_p
->ul
>> 16 );
177 markedInsertList
= (FT_UShort
)( glyphOffset_p
->ul
);
179 if ( currentInsertList
&& 0 != currentInsertCount
)
180 gxv_morx_subtable_type5_InsertList_validate( currentInsertList
,
185 if ( markedInsertList
&& 0 != markedInsertCount
)
186 gxv_morx_subtable_type5_InsertList_validate( markedInsertList
,
194 gxv_morx_subtable_type5_validate( FT_Bytes table
,
196 GXV_Validator gxvalid
)
200 GXV_morx_subtable_type5_StateOptRec et_rec
;
201 GXV_morx_subtable_type5_StateOptRecData et
= &et_rec
;
204 GXV_NAME_ENTER( "morx chain subtable type5 (Glyph Insertion)" );
206 GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE
);
208 gxvalid
->xstatetable
.optdata
=
210 gxvalid
->xstatetable
.optdata_load_func
=
211 gxv_morx_subtable_type5_insertionGlyphList_load
;
212 gxvalid
->xstatetable
.subtable_setup_func
=
213 gxv_morx_subtable_type5_subtable_setup
;
214 gxvalid
->xstatetable
.entry_glyphoffset_fmt
=
215 GXV_GLYPHOFFSET_ULONG
;
216 gxvalid
->xstatetable
.entry_validate_func
=
217 gxv_morx_subtable_type5_entry_validate
;
219 gxv_XStateTable_validate( p
, limit
, gxvalid
);