/[freetype]/freetype2/src/gxvalid/gxvmort1.c
ViewVC logotype

Diff of /freetype2/src/gxvalid/gxvmort1.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mpsuzuki, Wed Aug 24 04:31:31 2005 UTC revision 1.2 by wl, Wed Aug 31 22:39:23 2005 UTC
# Line 17  Line 17 
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 "gxvmort.h"  #include "gxvmort.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      */
# Line 42  Line 46 
46    }  GXV_mort_subtable_type1_StateOptRec,    }  GXV_mort_subtable_type1_StateOptRec,
47      *GXV_mort_subtable_type1_StateOptRecData;      *GXV_mort_subtable_type1_StateOptRecData;
48    
49  #define  GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE ( GXV_STATETABLE_HEADER_SIZE + 2 )  #define GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE  GXV_STATETABLE_HEADER_SIZE + 2
50    
51    
52    static void    static void
53    gxv_mort_subtable_type1_substitutionTable_load( FT_Bytes       table,    gxv_mort_subtable_type1_substitutionTable_load( FT_Bytes       table,
# Line 50  Line 55 
55                                                    GXV_Validator  valid )                                                    GXV_Validator  valid )
56    {    {
57      FT_Bytes  p = table;      FT_Bytes  p = table;
58      GXV_mort_subtable_type1_StateOptRecData  optdata = valid->statetable.optdata;  
59        GXV_mort_subtable_type1_StateOptRecData  optdata =
60                                                   valid->statetable.optdata;
61    
62    
63      GXV_LIMIT_CHECK( 2 );      GXV_LIMIT_CHECK( 2 );
# Line 71  Line 78 
78      FT_UShort  o[4];      FT_UShort  o[4];
79      FT_UShort  *l[4];      FT_UShort  *l[4];
80      FT_UShort  buff[5];      FT_UShort  buff[5];
81      GXV_mort_subtable_type1_StateOptRecData  optdata = valid->statetable.optdata;  
82        GXV_mort_subtable_type1_StateOptRecData  optdata =
83                                                   valid->statetable.optdata;
84    
85    
86      o[0] = classTable;      o[0] = classTable;
# Line 81  Line 90 
90      l[0] = classTable_length_p;      l[0] = classTable_length_p;
91      l[1] = stateArray_length_p;      l[1] = stateArray_length_p;
92      l[2] = entryTable_length_p;      l[2] = entryTable_length_p;
93      l[3] = &(optdata->substitutionTable_length);      l[3] = &( optdata->substitutionTable_length );
94    
95      gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, valid );      gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, valid );
96    }    }
97    
98    
99    static void    static void
100    gxv_mort_subtable_type1_offset_to_subst_validate( FT_Short       wordOffset,    gxv_mort_subtable_type1_offset_to_subst_validate(
101                                                      FT_String*     tag,      FT_Short          wordOffset,
102                                                      FT_Byte        state,      const FT_String*  tag,
103                                                      GXV_Validator  valid )      FT_Byte           state,
104        GXV_Validator     valid )
105    {    {
106      FT_UShort  substTable;      FT_UShort  substTable;
107      FT_UShort  substTable_limit;      FT_UShort  substTable_limit;
108      FT_UShort  min_gid;      FT_UShort  min_gid;
109      FT_UShort  max_gid;      FT_UShort  max_gid;
110    
111        FT_UNUSED( tag );
112        FT_UNUSED( state );
113    
114    
115      substTable       = ((GXV_mort_subtable_type1_StateOptRec *)      substTable       = ((GXV_mort_subtable_type1_StateOptRec *)
116                          (valid->statetable.optdata))->substitutionTable;                          (valid->statetable.optdata))->substitutionTable;
117      substTable_limit = substTable +      substTable_limit = substTable +
118                         ((GXV_mort_subtable_type1_StateOptRec *)                         ((GXV_mort_subtable_type1_StateOptRec *)
119                          (valid->statetable.optdata))->substitutionTable_length;                          (valid->statetable.optdata))->substitutionTable_length;
120    
121      min_gid = ( substTable       - ( wordOffset * 2 ) ) / 2;      min_gid = ( substTable       - wordOffset * 2 ) / 2;
122      max_gid = ( substTable_limit - ( wordOffset * 2 ) ) / 2;      max_gid = ( substTable_limit - wordOffset * 2 ) / 2;
123      max_gid = FT_MAX( max_gid, valid->face->num_glyphs );      max_gid = FT_MAX( max_gid, valid->face->num_glyphs );
124    
125      /* TODO: min_gid & max_gid comparison with ClassTable contents */      /* TODO: min_gid & max_gid comparison with ClassTable contents */
# Line 113  Line 127 
127    
128    
129    static void    static void
130    gxv_mort_subtable_type1_entry_validate( FT_Byte                         state,    gxv_mort_subtable_type1_entry_validate(
131                                            FT_UShort                       flags,      FT_Byte                         state,
132                                            GXV_StateTable_GlyphOffsetDesc  glyphOffset,      FT_UShort                       flags,
133                                            FT_Bytes                        table,      GXV_StateTable_GlyphOffsetDesc  glyphOffset,
134                                            FT_Bytes                        limit,      FT_Bytes                        table,
135                                            GXV_Validator                   valid )      FT_Bytes                        limit,
136    {      GXV_Validator                   valid )
137      FT_UShort setMark;    {
138      FT_UShort dontAdvance;      FT_UShort  setMark;
139      FT_UShort reserved;      FT_UShort  dontAdvance;
140      FT_Short  markOffset;      FT_UShort  reserved;
141      FT_Short  currentOffset;      FT_Short   markOffset;
142        FT_Short   currentOffset;
143    
144        FT_UNUSED( table );
145        FT_UNUSED( limit );
146    
147    
148      setMark     =   flags / 0x8000;      setMark     =   flags / 0x8000U;
149      dontAdvance = ( flags & 0x4000 ) / 0x4000;      dontAdvance = ( flags & 0x4000 ) / 0x4000;
150      reserved    =   flags & 0x3FFF;      reserved    =   flags & 0x3FFF;
151      markOffset    = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000 );      markOffset    = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000UL );
152      currentOffset = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFF );      currentOffset = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFFUL );
153    
154      if ( 0 < reserved )      if ( 0 < reserved )
155      {      {
# Line 151  Line 169 
169                                                        valid );                                                        valid );
170    }    }
171    
172    
173    static void    static void
174    gxv_mort_subtable_type1_substTable_validate( FT_Bytes       table,    gxv_mort_subtable_type1_substTable_validate( FT_Bytes       table,
175                                                 FT_Bytes       limit,                                                 FT_Bytes       limit,
176                                                 GXV_Validator  valid )                                                 GXV_Validator  valid )
177    {    {
178      FT_Bytes   p = table;      FT_Bytes   p = table;
179      FT_UShort  num_gids = ((GXV_mort_subtable_type1_StateOptRec *)      FT_UShort  num_gids =
180                             (valid->statetable.optdata))->substitutionTable_length                   ((GXV_mort_subtable_type1_StateOptRec *)
181                            / 2;                    (valid->statetable.optdata))->substitutionTable_length / 2;
182      FT_UShort  i;      FT_UShort  i;
183    
184    
185      GXV_NAME_ENTER(( "validate contents in substitionTable" ));      GXV_NAME_ENTER( "validate contents in substitionTable" );
186      for ( i = 0; i < num_gids ; i ++ )      for ( i = 0; i < num_gids ; i ++ )
187      {      {
188        FT_UShort  dst_gid;        FT_UShort  dst_gid;
# Line 172  Line 191 
191        GXV_LIMIT_CHECK( 2 );        GXV_LIMIT_CHECK( 2 );
192        dst_gid = FT_NEXT_USHORT( p );        dst_gid = FT_NEXT_USHORT( p );
193    
194        if ( dst_gid >= 0xFFFF )        if ( dst_gid >= 0xFFFFU )
195          continue;          continue;
196    
197        if ( dst_gid > valid->face->num_glyphs )        if ( dst_gid > valid->face->num_glyphs )
198        {        {
199          GXV_TRACE(( "substTable include too-large gid[%d]=%d > max defined gid #%d\n",          GXV_TRACE(( "substTable include toolarge gid[%d]=%d >"
200                       i, dst_gid, valid->face->num_glyphs ));                      " max defined gid #%d\n",
201                        i, dst_gid, valid->face->num_glyphs ));
202          if ( valid->root->level >= FT_VALIDATE_PARANOID )          if ( valid->root->level >= FT_VALIDATE_PARANOID )
203            FT_INVALID_GLYPH_ID;            FT_INVALID_GLYPH_ID;
204        }        }
# Line 187  Line 207 
207      GXV_EXIT;      GXV_EXIT;
208    }    }
209    
210    
211    /*    /*
212     * subtable for Contextual glyph substition is modified StateTable.     * subtable for Contextual glyph substition is a modified StateTable.
213     * In addition classTable, stateArray, entryTable, "substitutionTable"     * In addition to classTable, stateArray, and entryTable, the field
214     * is added.     * `substitutionTable' is added.
215     */     */
216    static void    static void
217    gxv_mort_subtable_type1_validate( FT_Bytes       table,    gxv_mort_subtable_type1_validate( FT_Bytes       table,
# Line 198  Line 219 
219                                      GXV_Validator  valid )                                      GXV_Validator  valid )
220    {    {
221      FT_Bytes  p = table;      FT_Bytes  p = table;
222    
223      GXV_mort_subtable_type1_StateOptRec  st_rec;      GXV_mort_subtable_type1_StateOptRec  st_rec;
224    
225    
# Line 205  Line 227 
227    
228      GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE );      GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE );
229    
230      valid->statetable.optdata               = &st_rec;      valid->statetable.optdata =
231      valid->statetable.optdata_load_func     = gxv_mort_subtable_type1_substitutionTable_load;        &st_rec;
232      valid->statetable.subtable_setup_func   = gxv_mort_subtable_type1_subtable_setup;      valid->statetable.optdata_load_func =
233      valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_ULONG;        gxv_mort_subtable_type1_substitutionTable_load;
234      valid->statetable.entry_validate_func   = gxv_mort_subtable_type1_entry_validate;      valid->statetable.subtable_setup_func =
235          gxv_mort_subtable_type1_subtable_setup;
236        valid->statetable.entry_glyphoffset_fmt =
237          GXV_GLYPHOFFSET_ULONG;
238        valid->statetable.entry_validate_func =
239    
240          gxv_mort_subtable_type1_entry_validate;
241      gxv_StateTable_validate( p, limit, valid );      gxv_StateTable_validate( p, limit, valid );
242    
243      gxv_mort_subtable_type1_substTable_validate( table      gxv_mort_subtable_type1_substTable_validate(
244                                                     + st_rec.substitutionTable,        table + st_rec.substitutionTable,
245                                                   table        table + st_rec.substitutionTable + st_rec.substitutionTable_length,
246                                                     + st_rec.substitutionTable        valid );
                                                    + st_rec.substitutionTable_length,  
                                                  valid );  
247    
248      GXV_EXIT;      GXV_EXIT;
249    }    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26