1 /***************************************************************************/ |
|
2 /* */ |
|
3 /* gxvmorx5.c */ |
|
4 /* */ |
|
5 /* TrueTypeGX/AAT morx table validation */ |
|
6 /* body for type5 (Contextual Glyph Insertion) subtable. */ |
|
7 /* */ |
|
8 /* Copyright 2005, 2007 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ |
|
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
|
10 /* */ |
|
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. */ |
|
16 /* */ |
|
17 /***************************************************************************/ |
|
18 |
|
19 /***************************************************************************/ |
|
20 /* */ |
|
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. */ |
|
24 /* */ |
|
25 /***************************************************************************/ |
|
26 |
|
27 |
|
28 #include "gxvmorx.h" |
|
29 |
|
30 |
|
31 /*************************************************************************/ |
|
32 /* */ |
|
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. */ |
|
36 /* */ |
|
37 #undef FT_COMPONENT |
|
38 #define FT_COMPONENT trace_gxvmorx |
|
39 |
|
40 |
|
41 /* |
|
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). |
|
48 */ |
|
49 |
|
50 |
|
51 typedef struct GXV_morx_subtable_type5_StateOptRec_ |
|
52 { |
|
53 FT_ULong insertionGlyphList; |
|
54 FT_ULong insertionGlyphList_length; |
|
55 |
|
56 } GXV_morx_subtable_type5_StateOptRec, |
|
57 *GXV_morx_subtable_type5_StateOptRecData; |
|
58 |
|
59 |
|
60 #define GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE \ |
|
61 ( GXV_STATETABLE_HEADER_SIZE + 4 ) |
|
62 |
|
63 |
|
64 static void |
|
65 gxv_morx_subtable_type5_insertionGlyphList_load( FT_Bytes table, |
|
66 FT_Bytes limit, |
|
67 GXV_Validator valid ) |
|
68 { |
|
69 FT_Bytes p = table; |
|
70 |
|
71 GXV_morx_subtable_type5_StateOptRecData optdata = |
|
72 (GXV_morx_subtable_type5_StateOptRecData)valid->xstatetable.optdata; |
|
73 |
|
74 |
|
75 GXV_LIMIT_CHECK( 4 ); |
|
76 optdata->insertionGlyphList = FT_NEXT_ULONG( p ); |
|
77 } |
|
78 |
|
79 |
|
80 static void |
|
81 gxv_morx_subtable_type5_subtable_setup( FT_ULong table_size, |
|
82 FT_ULong classTable, |
|
83 FT_ULong stateArray, |
|
84 FT_ULong entryTable, |
|
85 FT_ULong* classTable_length_p, |
|
86 FT_ULong* stateArray_length_p, |
|
87 FT_ULong* entryTable_length_p, |
|
88 GXV_Validator valid ) |
|
89 { |
|
90 FT_ULong o[4]; |
|
91 FT_ULong* l[4]; |
|
92 FT_ULong buff[5]; |
|
93 |
|
94 GXV_morx_subtable_type5_StateOptRecData optdata = |
|
95 (GXV_morx_subtable_type5_StateOptRecData)valid->xstatetable.optdata; |
|
96 |
|
97 |
|
98 o[0] = classTable; |
|
99 o[1] = stateArray; |
|
100 o[2] = entryTable; |
|
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); |
|
106 |
|
107 gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, valid ); |
|
108 } |
|
109 |
|
110 |
|
111 static void |
|
112 gxv_morx_subtable_type5_InsertList_validate( FT_UShort table_index, |
|
113 FT_UShort count, |
|
114 FT_Bytes table, |
|
115 FT_Bytes limit, |
|
116 GXV_Validator valid ) |
|
117 { |
|
118 FT_Bytes p = table + table_index * 2; |
|
119 |
|
120 |
|
121 while ( p < table + count * 2 + table_index * 2 ) |
|
122 { |
|
123 FT_UShort insert_glyphID; |
|
124 |
|
125 |
|
126 GXV_LIMIT_CHECK( 2 ); |
|
127 insert_glyphID = FT_NEXT_USHORT( p ); |
|
128 GXV_TRACE(( " 0x%04x", insert_glyphID )); |
|
129 } |
|
130 |
|
131 GXV_TRACE(( "\n" )); |
|
132 } |
|
133 |
|
134 |
|
135 static void |
|
136 gxv_morx_subtable_type5_entry_validate( |
|
137 FT_UShort state, |
|
138 FT_UShort flags, |
|
139 GXV_StateTable_GlyphOffsetCPtr glyphOffset_p, |
|
140 FT_Bytes table, |
|
141 FT_Bytes limit, |
|
142 GXV_Validator valid ) |
|
143 { |
|
144 FT_Bool setMark; |
|
145 FT_Bool dontAdvance; |
|
146 FT_Bool currentIsKashidaLike; |
|
147 FT_Bool markedIsKashidaLike; |
|
148 FT_Bool currentInsertBefore; |
|
149 FT_Bool markedInsertBefore; |
|
150 FT_Byte currentInsertCount; |
|
151 FT_Byte markedInsertCount; |
|
152 FT_Byte currentInsertList; |
|
153 FT_UShort markedInsertList; |
|
154 |
|
155 FT_UNUSED( state ); |
|
156 |
|
157 |
|
158 setMark = FT_BOOL( ( flags >> 15 ) & 1 ); |
|
159 dontAdvance = FT_BOOL( ( flags >> 14 ) & 1 ); |
|
160 currentIsKashidaLike = FT_BOOL( ( flags >> 13 ) & 1 ); |
|
161 markedIsKashidaLike = FT_BOOL( ( flags >> 12 ) & 1 ); |
|
162 currentInsertBefore = FT_BOOL( ( flags >> 11 ) & 1 ); |
|
163 markedInsertBefore = FT_BOOL( ( flags >> 10 ) & 1 ); |
|
164 |
|
165 currentInsertCount = (FT_Byte)( ( flags >> 5 ) & 0x1F ); |
|
166 markedInsertCount = (FT_Byte)( flags & 0x001F ); |
|
167 |
|
168 currentInsertList = (FT_Byte) ( glyphOffset_p->ul >> 16 ); |
|
169 markedInsertList = (FT_UShort)( glyphOffset_p->ul ); |
|
170 |
|
171 if ( currentInsertList && 0 != currentInsertCount ) |
|
172 gxv_morx_subtable_type5_InsertList_validate( currentInsertList, |
|
173 currentInsertCount, |
|
174 table, limit, |
|
175 valid ); |
|
176 |
|
177 if ( markedInsertList && 0 != markedInsertCount ) |
|
178 gxv_morx_subtable_type5_InsertList_validate( markedInsertList, |
|
179 markedInsertCount, |
|
180 table, limit, |
|
181 valid ); |
|
182 } |
|
183 |
|
184 |
|
185 FT_LOCAL_DEF( void ) |
|
186 gxv_morx_subtable_type5_validate( FT_Bytes table, |
|
187 FT_Bytes limit, |
|
188 GXV_Validator valid ) |
|
189 { |
|
190 FT_Bytes p = table; |
|
191 |
|
192 GXV_morx_subtable_type5_StateOptRec et_rec; |
|
193 GXV_morx_subtable_type5_StateOptRecData et = &et_rec; |
|
194 |
|
195 |
|
196 GXV_NAME_ENTER( "morx chain subtable type5 (Glyph Insertion)" ); |
|
197 |
|
198 GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE ); |
|
199 |
|
200 valid->xstatetable.optdata = |
|
201 et; |
|
202 valid->xstatetable.optdata_load_func = |
|
203 gxv_morx_subtable_type5_insertionGlyphList_load; |
|
204 valid->xstatetable.subtable_setup_func = |
|
205 gxv_morx_subtable_type5_subtable_setup; |
|
206 valid->xstatetable.entry_glyphoffset_fmt = |
|
207 GXV_GLYPHOFFSET_ULONG; |
|
208 valid->xstatetable.entry_validate_func = |
|
209 gxv_morx_subtable_type5_entry_validate; |
|
210 |
|
211 gxv_XStateTable_validate( p, limit, valid ); |
|
212 |
|
213 GXV_EXIT; |
|
214 } |
|
215 |
|
216 |
|
217 /* END */ |
|