Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
gxvmorx5.c
Go to the documentation of this file.
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 
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,
67  GXV_Validator valid )
68  {
69  FT_Bytes p = table;
70 
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 
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,
114  FT_Bytes table,
115  FT_Bytes limit,
116  GXV_Validator valid )
117  {
118  FT_Bytes p = table + table_index * 2;
119 
120 
121 #ifndef GXV_LOAD_TRACE_VARS
122  GXV_LIMIT_CHECK( count * 2 );
123 #else
124  while ( p < table + count * 2 + table_index * 2 )
125  {
126  FT_UShort insert_glyphID;
127 
128 
129  GXV_LIMIT_CHECK( 2 );
130  insert_glyphID = FT_NEXT_USHORT( p );
131  GXV_TRACE(( " 0x%04x", insert_glyphID ));
132  }
133 
134  GXV_TRACE(( "\n" ));
135 #endif
136  }
137 
138 
139  static void
140  gxv_morx_subtable_type5_entry_validate(
141  FT_UShort state,
143  GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
144  FT_Bytes table,
145  FT_Bytes limit,
146  GXV_Validator valid )
147  {
148 #ifdef GXV_LOAD_UNUSED_VARS
149  FT_Bool setMark;
150  FT_Bool dontAdvance;
151  FT_Bool currentIsKashidaLike;
152  FT_Bool markedIsKashidaLike;
153  FT_Bool currentInsertBefore;
154  FT_Bool markedInsertBefore;
155 #endif
156  FT_Byte currentInsertCount;
157  FT_Byte markedInsertCount;
158  FT_Byte currentInsertList;
159  FT_UShort markedInsertList;
160 
161  FT_UNUSED( state );
162 
163 
164 #ifdef GXV_LOAD_UNUSED_VARS
165  setMark = FT_BOOL( ( flags >> 15 ) & 1 );
166  dontAdvance = FT_BOOL( ( flags >> 14 ) & 1 );
167  currentIsKashidaLike = FT_BOOL( ( flags >> 13 ) & 1 );
168  markedIsKashidaLike = FT_BOOL( ( flags >> 12 ) & 1 );
169  currentInsertBefore = FT_BOOL( ( flags >> 11 ) & 1 );
170  markedInsertBefore = FT_BOOL( ( flags >> 10 ) & 1 );
171 #endif
172 
173  currentInsertCount = (FT_Byte)( ( flags >> 5 ) & 0x1F );
174  markedInsertCount = (FT_Byte)( flags & 0x001F );
175 
176  currentInsertList = (FT_Byte) ( glyphOffset_p->ul >> 16 );
177  markedInsertList = (FT_UShort)( glyphOffset_p->ul );
178 
179  if ( currentInsertList && 0 != currentInsertCount )
180  gxv_morx_subtable_type5_InsertList_validate( currentInsertList,
181  currentInsertCount,
182  table, limit,
183  valid );
184 
185  if ( markedInsertList && 0 != markedInsertCount )
186  gxv_morx_subtable_type5_InsertList_validate( markedInsertList,
187  markedInsertCount,
188  table, limit,
189  valid );
190  }
191 
192 
193  FT_LOCAL_DEF( void )
195  FT_Bytes limit,
196  GXV_Validator valid )
197  {
198  FT_Bytes p = table;
199 
202 
203 
204  GXV_NAME_ENTER( "morx chain subtable type5 (Glyph Insertion)" );
205 
207 
208  valid->xstatetable.optdata =
209  et;
211  gxv_morx_subtable_type5_insertionGlyphList_load;
213  gxv_morx_subtable_type5_subtable_setup;
217  gxv_morx_subtable_type5_entry_validate;
218 
219  gxv_XStateTable_validate( p, limit, valid );
220 
221  GXV_EXIT;
222  }
223 
224 
225 /* END */
unsigned long FT_ULong
Definition: fttypes.h:249
GLfloat GLfloat p
#define GXV_NAME_ENTER(name)
Definition: gxvcommn.h:301
#define GXV_TRACE(s)
Definition: gxvcommn.h:304
#define FT_UNUSED(arg)
Definition: ftconfig.h:76
gxv_XStateTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
Definition: gxvcommn.c:1558
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
GXV_XStateTable_Entry_Validate_Func entry_validate_func
Definition: gxvcommn.h:226
unsigned char FT_Byte
Definition: fttypes.h:150
struct GXV_morx_subtable_type5_StateOptRec_ * GXV_morx_subtable_type5_StateOptRecData
#define GXV_EXIT
Definition: gxvcommn.h:302
GLbitfield flags
GXV_XStateTable_Subtable_Setup_Func subtable_setup_func
Definition: gxvcommn.h:225
gxv_morx_subtable_type5_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
Definition: gxvmorx5.c:194
GXV_XStateTable_ValidatorRec xstatetable
Definition: gxvcommn.h:255
const FT_Byte * FT_Bytes
Definition: fttypes.h:161
#define GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE
Definition: gxvmorx5.c:60
struct GXV_morx_subtable_type5_StateOptRec_ GXV_morx_subtable_type5_StateOptRec
#define FT_BOOL(x)
Definition: fttypes.h:574
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
GXV_XStateTable_OptData_Load_Func optdata_load_func
Definition: gxvcommn.h:227
#define FT_NEXT_ULONG(buffer)
Definition: ftstream.h:238
GLuint GLuint GLsizei count
unsigned short FT_UShort
Definition: fttypes.h:205
GLenum GLsizei GLenum GLenum const GLvoid * table
GLint limit
gxv_set_length_by_ulong_offset(FT_ULong *offset, FT_ULong **length, FT_ULong *buff, FT_UInt nmemb, FT_ULong limit, GXV_Validator valid)
Definition: gxvcommn.c:128
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:236
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272