ReactOS 0.4.15-dev-7942-gd23573b
gxvmort1.c
Go to the documentation of this file.
1/***************************************************************************/
2/* */
3/* gxvmort1.c */
4/* */
5/* TrueTypeGX/AAT mort table validation */
6/* body for type1 (Contextual Substitution) subtable. */
7/* */
8/* Copyright 2005-2018 by */
9/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
10/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11/* */
12/* This file is part of the FreeType project, and may only be used, */
13/* modified, and distributed under the terms of the FreeType project */
14/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15/* this file you indicate that you have read the license and */
16/* understand and accept it fully. */
17/* */
18/***************************************************************************/
19
20/***************************************************************************/
21/* */
22/* gxvalid is derived from both gxlayout module and otvalid module. */
23/* Development of gxlayout is supported by the Information-technology */
24/* Promotion Agency(IPA), Japan. */
25/* */
26/***************************************************************************/
27
28
29#include "gxvmort.h"
30
31
32 /*************************************************************************/
33 /* */
34 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
35 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
36 /* messages during execution. */
37 /* */
38#undef FT_COMPONENT
39#define FT_COMPONENT trace_gxvmort
40
41
43 {
46
49
50#define GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE \
51 ( GXV_STATETABLE_HEADER_SIZE + 2 )
52
53
54 static void
57 GXV_Validator gxvalid )
58 {
60
63
64
65 GXV_LIMIT_CHECK( 2 );
67 }
68
69
70 static void
72 FT_UShort classTable,
73 FT_UShort stateArray,
74 FT_UShort entryTable,
75 FT_UShort* classTable_length_p,
76 FT_UShort* stateArray_length_p,
77 FT_UShort* entryTable_length_p,
78 GXV_Validator gxvalid )
79 {
80 FT_UShort o[4];
81 FT_UShort *l[4];
82 FT_UShort buff[5];
83
86
87
88 o[0] = classTable;
89 o[1] = stateArray;
90 o[2] = entryTable;
91 o[3] = optdata->substitutionTable;
92 l[0] = classTable_length_p;
93 l[1] = stateArray_length_p;
94 l[2] = entryTable_length_p;
95 l[3] = &( optdata->substitutionTable_length );
96
98 }
99
100
101 static void
103 FT_Short wordOffset,
104 const FT_String* tag,
106 GXV_Validator gxvalid )
107 {
108 FT_UShort substTable;
109 FT_UShort substTable_limit;
110
111 FT_UNUSED( tag );
112 FT_UNUSED( state );
113
114
115 substTable =
117 (gxvalid->statetable.optdata))->substitutionTable;
118 substTable_limit =
119 (FT_UShort)( substTable +
121 (gxvalid->statetable.optdata))->substitutionTable_length );
122
123 gxvalid->min_gid = (FT_UShort)( ( substTable - wordOffset * 2 ) / 2 );
124 gxvalid->max_gid = (FT_UShort)( ( substTable_limit - wordOffset * 2 ) / 2 );
125 gxvalid->max_gid = (FT_UShort)( FT_MAX( gxvalid->max_gid,
126 gxvalid->face->num_glyphs ) );
127
128 /* XXX: check range? */
129
130 /* TODO: min_gid & max_gid comparison with ClassTable contents */
131 }
132
133
134 static void
138 GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
141 GXV_Validator gxvalid )
142 {
143#ifdef GXV_LOAD_UNUSED_VARS
144 FT_UShort setMark;
145 FT_UShort dontAdvance;
146#endif
148 FT_Short markOffset;
149 FT_Short currentOffset;
150
151 FT_UNUSED( table );
152 FT_UNUSED( limit );
153
154
155#ifdef GXV_LOAD_UNUSED_VARS
156 setMark = (FT_UShort)( flags >> 15 );
157 dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
158#endif
159 reserved = (FT_UShort)( flags & 0x3FFF );
160
161 markOffset = (FT_Short)( glyphOffset_p->ul >> 16 );
162 currentOffset = (FT_Short)( glyphOffset_p->ul );
163
164 if ( 0 < reserved )
165 {
166 GXV_TRACE(( " non-zero bits found in reserved range\n" ));
168 }
169
171 "markOffset",
172 state,
173 gxvalid );
174
176 "currentOffset",
177 state,
178 gxvalid );
179 }
180
181
182 static void
185 GXV_Validator gxvalid )
186 {
187 FT_Bytes p = table;
188 FT_UShort num_gids = (FT_UShort)(
190 (gxvalid->statetable.optdata))->substitutionTable_length / 2 );
191 FT_UShort i;
192
193
194 GXV_NAME_ENTER( "validating contents of substitutionTable" );
195 for ( i = 0; i < num_gids; i++ )
196 {
197 FT_UShort dst_gid;
198
199
200 GXV_LIMIT_CHECK( 2 );
201 dst_gid = FT_NEXT_USHORT( p );
202
203 if ( dst_gid >= 0xFFFFU )
204 continue;
205
206 if ( dst_gid < gxvalid->min_gid || gxvalid->max_gid < dst_gid )
207 {
208 GXV_TRACE(( "substTable include a strange gid[%d]=%d >"
209 " out of define range (%d..%d)\n",
210 i, dst_gid, gxvalid->min_gid, gxvalid->max_gid ));
212 }
213 }
214
215 GXV_EXIT;
216 }
217
218
219 /*
220 * subtable for Contextual glyph substitution is a modified StateTable.
221 * In addition to classTable, stateArray, and entryTable, the field
222 * `substitutionTable' is added.
223 */
224 FT_LOCAL_DEF( void )
227 GXV_Validator gxvalid )
228 {
229 FT_Bytes p = table;
230
232
233
234 GXV_NAME_ENTER( "mort chain subtable type1 (Contextual Glyph Subst)" );
235
237
238 gxvalid->statetable.optdata =
239 &st_rec;
240 gxvalid->statetable.optdata_load_func =
242 gxvalid->statetable.subtable_setup_func =
244 gxvalid->statetable.entry_glyphoffset_fmt =
246 gxvalid->statetable.entry_validate_func =
247
249 gxv_StateTable_validate( p, limit, gxvalid );
250
252 table + st_rec.substitutionTable,
254 gxvalid );
255
256 GXV_EXIT;
257 }
258
259
260/* END */
static int state
Definition: maze.c:121
r l[0]
Definition: byte_order.h:168
r reserved
Definition: btrfs.c:3006
static unsigned char buff[32768]
Definition: fatten.c:17
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:388
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define FT_MAX(a, b)
Definition: ftobjs.h:72
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
unsigned char FT_Byte
Definition: fttypes.h:154
unsigned short FT_UShort
Definition: fttypes.h:209
char FT_String
Definition: fttypes.h:187
signed short FT_Short
Definition: fttypes.h:198
const FT_Byte * FT_Bytes
Definition: fttypes.h:165
#define FT_INVALID_DATA
Definition: ftvalid.h:150
#define FT_INVALID_GLYPH_ID
Definition: ftvalid.h:146
GLint limit
Definition: glext.h:10326
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
gxv_set_length_by_ushort_offset(FT_UShort *offset, FT_UShort **length, FT_UShort *buff, FT_UInt nmemb, FT_UShort limit, GXV_Validator gxvalid)
Definition: gxvcommn.c:63
gxv_StateTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
Definition: gxvcommn.c:1208
#define GXV_NAME_ENTER(name)
Definition: gxvcommn.h:301
#define GXV_SET_ERR_IF_PARANOID(err)
Definition: gxvcommn.h:66
#define GXV_TRACE(s)
Definition: gxvcommn.h:304
@ GXV_GLYPHOFFSET_ULONG
Definition: gxvcommn.h:127
#define GXV_EXIT
Definition: gxvcommn.h:302
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272
#define GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE
Definition: gxvmort1.c:50
static void gxv_mort_subtable_type1_subtable_setup(FT_UShort table_size, FT_UShort classTable, FT_UShort stateArray, FT_UShort entryTable, FT_UShort *classTable_length_p, FT_UShort *stateArray_length_p, FT_UShort *entryTable_length_p, GXV_Validator gxvalid)
Definition: gxvmort1.c:71
gxv_mort_subtable_type1_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
Definition: gxvmort1.c:225
struct GXV_mort_subtable_type1_StateOptRec_ * GXV_mort_subtable_type1_StateOptRecData
static void gxv_mort_subtable_type1_entry_validate(FT_Byte state, FT_UShort flags, GXV_StateTable_GlyphOffsetCPtr glyphOffset_p, FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
Definition: gxvmort1.c:135
static void gxv_mort_subtable_type1_substitutionTable_load(FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
Definition: gxvmort1.c:55
static void gxv_mort_subtable_type1_offset_to_subst_validate(FT_Short wordOffset, const FT_String *tag, FT_Byte state, GXV_Validator gxvalid)
Definition: gxvmort1.c:102
struct GXV_mort_subtable_type1_StateOptRec_ GXV_mort_subtable_type1_StateOptRec
static void gxv_mort_subtable_type1_substTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
Definition: gxvmort1.c:183
LOCAL int table_size
Definition: write.c:65
FT_Long num_glyphs
Definition: freetype.h:1076
GXV_StateTable_ValidatorRec statetable
Definition: gxvcommn.h:254
FT_UShort max_gid
Definition: gxvcommn.h:252
FT_UShort min_gid
Definition: gxvcommn.h:251
Definition: ecma_167.h:138