diff options
Diffstat (limited to 'src/gxvalid/gxvmort5.c')
-rw-r--r-- | src/gxvalid/gxvmort5.c | 86 |
1 files changed, 55 insertions, 31 deletions
diff --git a/src/gxvalid/gxvmort5.c b/src/gxvalid/gxvmort5.c index e2848bf3e..70529b86f 100644 --- a/src/gxvalid/gxvmort5.c +++ b/src/gxvalid/gxvmort5.c @@ -17,13 +17,17 @@ /***************************************************************************/ /***************************************************************************/ +/* */ /* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout was support of Information-technology Promotion */ -/* Agency(IPA), Japan. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ /***************************************************************************/ + #include "gxvmort.h" + /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ @@ -34,23 +38,26 @@ #define FT_COMPONENT trace_gxvmort -/* - * mort subtable type5 (Contextual Glyph Insertion) - * has format of StateTable with insertion-glyph-list - * without name. the offset is given by glyphOffset in - * entryTable. there's no table location declaration - * like xxxTable. - */ + /* + * mort subtable type5 (Contextual Glyph Insertion) + * has the format of StateTable with insertion-glyph-list, + * but without name. The offset is given by glyphOffset in + * entryTable. There is no table location declaration + * like xxxTable. + */ typedef struct GXV_mort_subtable_type5_StateOptRec_ { FT_UShort classTable; FT_UShort stateArray; FT_UShort entryTable; -#define GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE GXV_STATETABLE_HEADER_SIZE + +#define GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE GXV_STATETABLE_HEADER_SIZE + FT_UShort* classTable_length_p; FT_UShort* stateArray_length_p; FT_UShort* entryTable_length_p; + } GXV_mort_subtable_type5_StateOptRec, *GXV_mort_subtable_type5_StateOptRecData; @@ -65,7 +72,10 @@ FT_UShort* entryTable_length_p, GXV_Validator valid ) { - GXV_mort_subtable_type5_StateOptRecData optdata = valid->statetable.optdata; + GXV_mort_subtable_type5_StateOptRecData optdata = + valid->statetable.optdata; + + gxv_StateTable_subtable_setup( table_size, classTable, stateArray, @@ -78,13 +88,13 @@ optdata->classTable = classTable; optdata->stateArray = stateArray; optdata->entryTable = entryTable; + optdata->classTable_length_p = classTable_length_p; optdata->stateArray_length_p = stateArray_length_p; optdata->entryTable_length_p = entryTable_length_p; } - static void gxv_mort_subtable_type5_InsertList_validate( FT_UShort offset, FT_UShort count, @@ -93,19 +103,21 @@ GXV_Validator valid ) { /* - * we don't know the range of insertion-glyph-list. - * set range by whole of state table + * We don't know the range of insertion-glyph-list. + * Set range by whole of state table. */ FT_Bytes p = table + offset; - GXV_mort_subtable_type5_StateOptRecData optdata = valid->statetable.optdata; - if ( optdata->classTable < offset && + GXV_mort_subtable_type5_StateOptRecData optdata = + valid->statetable.optdata; + + if ( optdata->classTable < offset && offset < optdata->classTable + *(optdata->classTable_length_p) ) GXV_TRACE(( " offset runs into ClassTable" )); - if ( optdata->stateArray < offset && + if ( optdata->stateArray < offset && offset < optdata->stateArray + *(optdata->stateArray_length_p) ) GXV_TRACE(( " offset runs into StateArray" )); - if ( optdata->entryTable < offset && + if ( optdata->entryTable < offset && offset < optdata->entryTable + *(optdata->entryTable_length_p) ) GXV_TRACE(( " offset runs into EntryTable" )); @@ -113,6 +125,7 @@ { FT_UShort insert_glyphID; + GXV_LIMIT_CHECK( 2 ); insert_glyphID = FT_NEXT_USHORT( p ); GXV_TRACE(( " 0x%04x", insert_glyphID )); @@ -123,12 +136,13 @@ static void - gxv_mort_subtable_type5_entry_validate( FT_Byte state, - FT_UShort flags, - GXV_StateTable_GlyphOffsetDesc glyphOffset, - FT_Bytes table, - FT_Bytes limit, - GXV_Validator valid ) + gxv_mort_subtable_type5_entry_validate( + FT_Byte state, + FT_UShort flags, + GXV_StateTable_GlyphOffsetDesc glyphOffset, + FT_Bytes table, + FT_Bytes limit, + GXV_Validator valid ) { FT_Bool setMark; FT_Bool dontAdvance; @@ -141,6 +155,8 @@ FT_UShort currentInsertList; FT_UShort markedInsertList; + FT_UNUSED( state ); + setMark = ( flags >> 15 ) & 1; dontAdvance = ( flags >> 14 ) & 1; @@ -150,8 +166,8 @@ markedInsertBefore = ( flags >> 10 ) & 1; currentInsertCount = ( flags & 0x03E0 ) / 0x0020; markedInsertCount = ( flags & 0x001F ); - currentInsertList = glyphOffset.ul / 0x00010000; - markedInsertList = glyphOffset.ul & 0x0000FFFF; + currentInsertList = glyphOffset.ul / 0x00010000UL; + markedInsertList = glyphOffset.ul & 0x0000FFFFUL; if ( 0 != currentInsertList && 0 != currentInsertCount ) { @@ -179,6 +195,7 @@ GXV_Validator valid ) { FT_Bytes p = table; + GXV_mort_subtable_type5_StateOptRec et_rec; GXV_mort_subtable_type5_StateOptRecData et = &et_rec; @@ -187,12 +204,19 @@ GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE ); - valid->statetable.optdata = et; - valid->statetable.optdata_load_func = NULL; - valid->statetable.subtable_setup_func = gxv_mort_subtable_type5_subtable_setup; - valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_ULONG; - valid->statetable.entry_validate_func = gxv_mort_subtable_type5_entry_validate; + valid->statetable.optdata = + et; + valid->statetable.optdata_load_func = + NULL; + valid->statetable.subtable_setup_func = + gxv_mort_subtable_type5_subtable_setup; + valid->statetable.entry_glyphoffset_fmt = + GXV_GLYPHOFFSET_ULONG; + valid->statetable.entry_validate_func = + gxv_mort_subtable_type5_entry_validate; + gxv_StateTable_validate( p, limit, valid ); + GXV_EXIT; } |