1 /***************************************************************************/
5 /* TrueTypeGX/AAT morx table validation */
6 /* body for type5 (Contextual Glyph Insertion) subtable. */
8 /* Copyright 2005-2018 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. */
18 /***************************************************************************/
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. */
26 /***************************************************************************/
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 trace_gxvmorx
43 * `morx' subtable type5 (Contextual Glyph Insertion)
44 * has format of a StateTable with insertion-glyph-list
45 * without name. However, the 32bit offset from the head
46 * of subtable to the i-g-l is given after `entryTable',
47 * without variable name specification (the existence of
48 * this offset to the table is different from mort type5).
52 typedef struct GXV_morx_subtable_type5_StateOptRec_
54 FT_ULong insertionGlyphList
;
55 FT_ULong insertionGlyphList_length
;
57 } GXV_morx_subtable_type5_StateOptRec
,
58 *GXV_morx_subtable_type5_StateOptRecData
;
61 #define GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE \
62 ( GXV_STATETABLE_HEADER_SIZE + 4 )
66 gxv_morx_subtable_type5_insertionGlyphList_load( FT_Bytes table
,
68 GXV_Validator gxvalid
)
72 GXV_morx_subtable_type5_StateOptRecData optdata
=
73 (GXV_morx_subtable_type5_StateOptRecData
)gxvalid
->xstatetable
.optdata
;
77 optdata
->insertionGlyphList
= FT_NEXT_ULONG( p
);
82 gxv_morx_subtable_type5_subtable_setup( FT_ULong table_size
,
86 FT_ULong
* classTable_length_p
,
87 FT_ULong
* stateArray_length_p
,
88 FT_ULong
* entryTable_length_p
,
89 GXV_Validator gxvalid
)
95 GXV_morx_subtable_type5_StateOptRecData optdata
=
96 (GXV_morx_subtable_type5_StateOptRecData
)gxvalid
->xstatetable
.optdata
;
102 o
[3] = optdata
->insertionGlyphList
;
103 l
[0] = classTable_length_p
;
104 l
[1] = stateArray_length_p
;
105 l
[2] = entryTable_length_p
;
106 l
[3] = &(optdata
->insertionGlyphList_length
);
108 gxv_set_length_by_ulong_offset( o
, l
, buff
, 4, table_size
, gxvalid
);
113 gxv_morx_subtable_type5_InsertList_validate( FT_UShort table_index
,
117 GXV_Validator gxvalid
)
119 FT_Bytes p
= table
+ table_index
* 2;
122 #ifndef GXV_LOAD_TRACE_VARS
123 GXV_LIMIT_CHECK( count
* 2 );
125 while ( p
< table
+ count
* 2 + table_index
* 2 )
127 FT_UShort insert_glyphID
;
130 GXV_LIMIT_CHECK( 2 );
131 insert_glyphID
= FT_NEXT_USHORT( p
);
132 GXV_TRACE(( " 0x%04x", insert_glyphID
));
141 gxv_morx_subtable_type5_entry_validate(
144 GXV_StateTable_GlyphOffsetCPtr glyphOffset_p
,
147 GXV_Validator gxvalid
)
149 #ifdef GXV_LOAD_UNUSED_VARS
152 FT_Bool currentIsKashidaLike
;
153 FT_Bool markedIsKashidaLike
;
154 FT_Bool currentInsertBefore
;
155 FT_Bool markedInsertBefore
;
157 FT_Byte currentInsertCount
;
158 FT_Byte markedInsertCount
;
159 FT_Byte currentInsertList
;
160 FT_UShort markedInsertList
;
165 #ifdef GXV_LOAD_UNUSED_VARS
166 setMark
= FT_BOOL( ( flags
>> 15 ) & 1 );
167 dontAdvance
= FT_BOOL( ( flags
>> 14 ) & 1 );
168 currentIsKashidaLike
= FT_BOOL( ( flags
>> 13 ) & 1 );
169 markedIsKashidaLike
= FT_BOOL( ( flags
>> 12 ) & 1 );
170 currentInsertBefore
= FT_BOOL( ( flags
>> 11 ) & 1 );
171 markedInsertBefore
= FT_BOOL( ( flags
>> 10 ) & 1 );
174 currentInsertCount
= (FT_Byte
)( ( flags
>> 5 ) & 0x1F );
175 markedInsertCount
= (FT_Byte
)( flags
& 0x001F );
177 currentInsertList
= (FT_Byte
) ( glyphOffset_p
->ul
>> 16 );
178 markedInsertList
= (FT_UShort
)( glyphOffset_p
->ul
);
180 if ( currentInsertList
&& 0 != currentInsertCount
)
181 gxv_morx_subtable_type5_InsertList_validate( currentInsertList
,
186 if ( markedInsertList
&& 0 != markedInsertCount
)
187 gxv_morx_subtable_type5_InsertList_validate( markedInsertList
,
195 gxv_morx_subtable_type5_validate( FT_Bytes table
,
197 GXV_Validator gxvalid
)
201 GXV_morx_subtable_type5_StateOptRec et_rec
;
202 GXV_morx_subtable_type5_StateOptRecData et
= &et_rec
;
205 GXV_NAME_ENTER( "morx chain subtable type5 (Glyph Insertion)" );
207 GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE
);
209 gxvalid
->xstatetable
.optdata
=
211 gxvalid
->xstatetable
.optdata_load_func
=
212 gxv_morx_subtable_type5_insertionGlyphList_load
;
213 gxvalid
->xstatetable
.subtable_setup_func
=
214 gxv_morx_subtable_type5_subtable_setup
;
215 gxvalid
->xstatetable
.entry_glyphoffset_fmt
=
216 GXV_GLYPHOFFSET_ULONG
;
217 gxvalid
->xstatetable
.entry_validate_func
=
218 gxv_morx_subtable_type5_entry_validate
;
220 gxv_XStateTable_validate( p
, limit
, gxvalid
);