17 |
/***************************************************************************/ |
/***************************************************************************/ |
18 |
|
|
19 |
/***************************************************************************/ |
/***************************************************************************/ |
20 |
|
/* */ |
21 |
/* gxvalid is derived from both gxlayout module and otvalid module. */ |
/* gxvalid is derived from both gxlayout module and otvalid module. */ |
22 |
/* Development of gxlayout was support of Information-technology Promotion */ |
/* Development of gxlayout is supported by the Information-technology */ |
23 |
/* Agency(IPA), Japan. */ |
/* Promotion Agency(IPA), Japan. */ |
24 |
|
/* */ |
25 |
/***************************************************************************/ |
/***************************************************************************/ |
26 |
|
|
27 |
|
|
28 |
#include "gxvmorx.h" |
#include "gxvmorx.h" |
29 |
|
|
30 |
|
|
31 |
/*************************************************************************/ |
/*************************************************************************/ |
32 |
/* */ |
/* */ |
33 |
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
47 |
} GXV_morx_subtable_type1_StateOptRec, |
} GXV_morx_subtable_type1_StateOptRec, |
48 |
*GXV_morx_subtable_type1_StateOptRecData; |
*GXV_morx_subtable_type1_StateOptRecData; |
49 |
|
|
50 |
#define GXV_MORX_SUBTABLE_TYPE1_HEADER_SIZE ( GXV_STATETABLE_HEADER_SIZE + 2 ) |
|
51 |
|
#define GXV_MORX_SUBTABLE_TYPE1_HEADER_SIZE \ |
52 |
|
( GXV_STATETABLE_HEADER_SIZE + 2 ) |
53 |
|
|
54 |
|
|
55 |
static void |
static void |
56 |
gxv_morx_subtable_type1_substitutionTable_load( FT_Bytes table, |
gxv_morx_subtable_type1_substitutionTable_load( FT_Bytes table, |
57 |
FT_Bytes limit, |
FT_Bytes limit, |
58 |
GXV_Validator valid ) |
GXV_Validator valid ) |
59 |
{ |
{ |
60 |
FT_Bytes p = table; |
FT_Bytes p = table; |
61 |
GXV_morx_subtable_type1_StateOptRecData optdata = valid->xstatetable.optdata; |
|
62 |
|
GXV_morx_subtable_type1_StateOptRecData optdata = |
63 |
|
valid->xstatetable.optdata; |
64 |
|
|
65 |
|
|
66 |
GXV_LIMIT_CHECK( 2 ); |
GXV_LIMIT_CHECK( 2 ); |
67 |
optdata->substitutionTable = FT_NEXT_USHORT( p ); |
optdata->substitutionTable = FT_NEXT_USHORT( p ); |
81 |
FT_ULong o[4]; |
FT_ULong o[4]; |
82 |
FT_ULong *l[4]; |
FT_ULong *l[4]; |
83 |
FT_ULong buff[5]; |
FT_ULong buff[5]; |
84 |
GXV_morx_subtable_type1_StateOptRecData optdata = valid->xstatetable.optdata; |
|
85 |
|
GXV_morx_subtable_type1_StateOptRecData optdata = |
86 |
|
valid->xstatetable.optdata; |
87 |
|
|
88 |
|
|
89 |
o[0] = classTable; |
o[0] = classTable; |
100 |
|
|
101 |
|
|
102 |
static void |
static void |
103 |
gxv_morx_subtable_type1_entry_validate( FT_UShort state, |
gxv_morx_subtable_type1_entry_validate( |
104 |
FT_UShort flags, |
FT_UShort state, |
105 |
GXV_StateTable_GlyphOffsetDesc |
FT_UShort flags, |
106 |
glyphOffset, |
GXV_StateTable_GlyphOffsetDesc glyphOffset, |
107 |
FT_Bytes table, |
FT_Bytes table, |
108 |
FT_Bytes limit, |
FT_Bytes limit, |
109 |
GXV_Validator valid ) |
GXV_Validator valid ) |
110 |
{ |
{ |
111 |
FT_UShort setMark; |
FT_UShort setMark; |
112 |
FT_UShort dontAdvance; |
FT_UShort dontAdvance; |
113 |
FT_UShort reserved; |
FT_UShort reserved; |
114 |
FT_Short markIndex; |
FT_Short markIndex; |
115 |
FT_Short currentIndex; |
FT_Short currentIndex; |
116 |
GXV_morx_subtable_type1_StateOptRecData optdata = valid->xstatetable.optdata; |
|
117 |
|
GXV_morx_subtable_type1_StateOptRecData optdata = |
118 |
|
valid->xstatetable.optdata; |
119 |
|
|
120 |
|
FT_UNUSED( state ); |
121 |
|
FT_UNUSED( table ); |
122 |
|
FT_UNUSED( limit ); |
123 |
|
|
124 |
|
|
125 |
setMark = flags / 0x8000; |
setMark = flags / 0x8000U; |
126 |
dontAdvance = ( flags & 0x4000 ) / 0x4000; |
dontAdvance = ( flags & 0x4000 ) / 0x4000; |
127 |
reserved = flags & 0x3FFF; |
reserved = flags & 0x3FFF; |
128 |
markIndex = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000 ); |
markIndex = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000UL ); |
129 |
currentIndex = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFF ); |
currentIndex = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFFUL ); |
130 |
|
|
131 |
GXV_TRACE(( " setMark=%01d dontAdvance=%01d\n", |
GXV_TRACE(( " setMark=%01d dontAdvance=%01d\n", |
132 |
setMark, dontAdvance )); |
setMark, dontAdvance )); |
133 |
|
|
134 |
if ( 0 < reserved ) |
if ( 0 < reserved ) |
135 |
{ |
{ |
136 |
GXV_TRACE(( " non-zero bits found in reserved range\n" )); |
GXV_TRACE(( " non-zero bits found in reserved range\n" )); |
138 |
FT_INVALID_DATA; |
FT_INVALID_DATA; |
139 |
} |
} |
140 |
|
|
141 |
GXV_TRACE(( "markIndex = %d, currentIndex = %d\n", markIndex, currentIndex )); |
GXV_TRACE(( "markIndex = %d, currentIndex = %d\n", |
142 |
|
markIndex, currentIndex )); |
143 |
|
|
144 |
if ( optdata->substitutionTable_num_lookupTables < markIndex + 1 ) |
if ( optdata->substitutionTable_num_lookupTables < markIndex + 1 ) |
145 |
optdata->substitutionTable_num_lookupTables = markIndex + 1; |
optdata->substitutionTable_num_lookupTables = markIndex + 1; |
146 |
|
|
147 |
if ( optdata->substitutionTable_num_lookupTables < currentIndex + 1 ) |
if ( optdata->substitutionTable_num_lookupTables < currentIndex + 1 ) |
148 |
optdata->substitutionTable_num_lookupTables = currentIndex + 1; |
optdata->substitutionTable_num_lookupTables = currentIndex + 1; |
|
|
|
149 |
} |
} |
150 |
|
|
151 |
|
|
161 |
|
|
162 |
|
|
163 |
static GXV_LookupValueDesc |
static GXV_LookupValueDesc |
164 |
gxv_morx_subtable_type1_LookupFmt4_transit( FT_UShort relative_gindex, |
gxv_morx_subtable_type1_LookupFmt4_transit( |
165 |
GXV_LookupValueDesc base_value, |
FT_UShort relative_gindex, |
166 |
FT_Bytes lookuptbl_limit, |
GXV_LookupValueDesc base_value, |
167 |
GXV_Validator valid ) |
FT_Bytes lookuptbl_limit, |
168 |
|
GXV_Validator valid ) |
169 |
{ |
{ |
170 |
FT_Bytes p; |
FT_Bytes p; |
171 |
FT_Bytes limit; |
FT_Bytes limit; |
173 |
GXV_LookupValueDesc value; |
GXV_LookupValueDesc value; |
174 |
|
|
175 |
|
|
176 |
offset = base_value.u + ( relative_gindex * sizeof( FT_UShort ) ); |
offset = base_value.u + relative_gindex * sizeof ( FT_UShort ); |
177 |
|
|
178 |
p = valid->lookuptbl_head + offset; |
p = valid->lookuptbl_head + offset; |
179 |
limit = lookuptbl_limit; |
limit = lookuptbl_limit; |
193 |
FT_Bytes limit, |
FT_Bytes limit, |
194 |
GXV_Validator valid ) |
GXV_Validator valid ) |
195 |
{ |
{ |
196 |
FT_Bytes p = table; |
FT_Bytes p = table; |
|
GXV_morx_subtable_type1_StateOptRecData optdata = valid->xstatetable.optdata; |
|
197 |
FT_UShort i; |
FT_UShort i; |
198 |
|
|
199 |
|
GXV_morx_subtable_type1_StateOptRecData optdata = |
200 |
|
valid->xstatetable.optdata; |
201 |
|
|
202 |
|
|
203 |
/* TODO: calculate offset/length for each lookupTables */ |
/* TODO: calculate offset/length for each lookupTables */ |
204 |
valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED; |
valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED; |
221 |
|
|
222 |
|
|
223 |
/* |
/* |
224 |
* subtable for Contextual glyph substition is modified StateTable. |
* subtable for Contextual glyph substition is a modified StateTable. |
225 |
* In addition classTable, stateArray, entryTable, "substitutionTable" |
* In addition to classTable, stateArray, entryTable, the field |
226 |
* is added. |
* `substitutionTable' is added. |
227 |
*/ |
*/ |
228 |
static void |
static void |
229 |
gxv_morx_subtable_type1_validate( FT_Bytes table, |
gxv_morx_subtable_type1_validate( FT_Bytes table, |
231 |
GXV_Validator valid ) |
GXV_Validator valid ) |
232 |
{ |
{ |
233 |
FT_Bytes p = table; |
FT_Bytes p = table; |
234 |
|
|
235 |
GXV_morx_subtable_type1_StateOptRec st_rec; |
GXV_morx_subtable_type1_StateOptRec st_rec; |
236 |
|
|
237 |
|
|
241 |
|
|
242 |
st_rec.substitutionTable_num_lookupTables = 0; |
st_rec.substitutionTable_num_lookupTables = 0; |
243 |
|
|
244 |
valid->xstatetable.optdata = &st_rec; |
valid->xstatetable.optdata = |
245 |
valid->xstatetable.optdata_load_func = gxv_morx_subtable_type1_substitutionTable_load; |
&st_rec; |
246 |
valid->xstatetable.subtable_setup_func = gxv_morx_subtable_type1_subtable_setup; |
valid->xstatetable.optdata_load_func = |
247 |
valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_ULONG; |
gxv_morx_subtable_type1_substitutionTable_load; |
248 |
valid->xstatetable.entry_validate_func = gxv_morx_subtable_type1_entry_validate; |
valid->xstatetable.subtable_setup_func = |
249 |
|
gxv_morx_subtable_type1_subtable_setup; |
250 |
|
valid->xstatetable.entry_glyphoffset_fmt = |
251 |
|
GXV_GLYPHOFFSET_ULONG; |
252 |
|
valid->xstatetable.entry_validate_func = |
253 |
|
gxv_morx_subtable_type1_entry_validate; |
254 |
|
|
255 |
gxv_XStateTable_validate( p, limit, valid ); |
gxv_XStateTable_validate( p, limit, valid ); |
256 |
|
|
257 |
gxv_morx_subtable_type1_substitutionTable_validate( table |
gxv_morx_subtable_type1_substitutionTable_validate( |
258 |
+ st_rec.substitutionTable, |
table + st_rec.substitutionTable, |
259 |
table |
table + st_rec.substitutionTable + st_rec.substitutionTable_length, |
260 |
+ st_rec.substitutionTable |
valid ); |
261 |
+ st_rec.substitutionTable_length, |
|
|
valid ); |
|
262 |
GXV_EXIT; |
GXV_EXIT; |
263 |
} |
} |
264 |
|
|