1
/***************************************************************************/
5
/* OpenType GDEF table validation (body). */
7
/* Copyright 2004, 2005, 2007 by */
8
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10
/* This file is part of the FreeType project, and may only be used, */
11
/* modified, and distributed under the terms of the FreeType project */
12
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13
/* this file you indicate that you have read the license and */
14
/* understand and accept it fully. */
16
/***************************************************************************/
23
/*************************************************************************/
25
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
26
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
27
/* messages during execution. */
30
#define FT_COMPONENT trace_otvgdef
33
/*************************************************************************/
34
/*************************************************************************/
36
/***** UTILITY FUNCTIONS *****/
38
/*************************************************************************/
39
/*************************************************************************/
41
#define AttachListFunc otv_O_x_Ox
42
#define LigCaretListFunc otv_O_x_Ox
44
/* sets valid->extra1 (0) */
47
otv_O_x_Ox( FT_Bytes table,
53
OTV_Validate_Func func;
59
Coverage = table + FT_NEXT_USHORT( p );
60
GlyphCount = FT_NEXT_USHORT( p );
62
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
64
otv_Coverage_validate( Coverage, valid, GlyphCount );
65
if ( GlyphCount != otv_Coverage_get_count( Coverage ) )
68
OTV_LIMIT_CHECK( GlyphCount * 2 );
70
valid->nesting_level++;
71
func = valid->func[valid->nesting_level];
74
for ( ; GlyphCount > 0; GlyphCount-- )
75
func( table + FT_NEXT_USHORT( p ), valid );
77
valid->nesting_level--;
83
/*************************************************************************/
84
/*************************************************************************/
86
/***** LIGATURE CARETS *****/
88
/*************************************************************************/
89
/*************************************************************************/
91
#define CaretValueFunc otv_CaretValue_validate
94
otv_CaretValue_validate( FT_Bytes table,
98
FT_UInt CaretValueFormat;
103
OTV_LIMIT_CHECK( 4 );
105
CaretValueFormat = FT_NEXT_USHORT( p );
107
OTV_TRACE(( " (format = %d)\n", CaretValueFormat ));
109
switch ( CaretValueFormat )
111
case 1: /* CaretValueFormat1 */
112
/* skip Coordinate, no test */
115
case 2: /* CaretValueFormat2 */
116
/* skip CaretValuePoint, no test */
119
case 3: /* CaretValueFormat3 */
120
p += 2; /* skip Coordinate */
122
OTV_LIMIT_CHECK( 2 );
125
otv_Device_validate( table + FT_NEXT_USHORT( p ), valid );
136
/*************************************************************************/
137
/*************************************************************************/
139
/***** GDEF TABLE *****/
141
/*************************************************************************/
142
/*************************************************************************/
144
/* sets valid->glyph_count */
147
otv_GDEF_validate( FT_Bytes table,
151
FT_Validator ftvalid )
153
OTV_ValidatorRec validrec;
154
OTV_Validator valid = &validrec;
157
FT_Bool need_MarkAttachClassDef;
159
OTV_OPTIONAL_TABLE( GlyphClassDef );
160
OTV_OPTIONAL_TABLE( AttachListOffset );
161
OTV_OPTIONAL_TABLE( LigCaretListOffset );
162
OTV_OPTIONAL_TABLE( MarkAttachClassDef );
165
valid->root = ftvalid;
167
FT_TRACE3(( "validating GDEF table\n" ));
170
OTV_LIMIT_CHECK( 12 );
172
if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
175
/* MarkAttachClassDef has been added to the OpenType */
176
/* specification without increasing GDEF's version, */
177
/* so we use this ugly hack to find out whether the */
178
/* table is needed actually. */
180
need_MarkAttachClassDef = FT_BOOL(
181
otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) ||
182
otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) );
184
if ( need_MarkAttachClassDef )
185
table_size = 12; /* OpenType >= 1.2 */
187
table_size = 10; /* OpenType < 1.2 */
189
valid->glyph_count = glyph_count;
191
OTV_OPTIONAL_OFFSET( GlyphClassDef );
192
OTV_SIZE_CHECK( GlyphClassDef );
194
otv_ClassDef_validate( table + GlyphClassDef, valid );
196
OTV_OPTIONAL_OFFSET( AttachListOffset );
197
OTV_SIZE_CHECK( AttachListOffset );
198
if ( AttachListOffset )
200
OTV_NEST2( AttachList, AttachPoint );
201
OTV_RUN( table + AttachListOffset, valid );
204
OTV_OPTIONAL_OFFSET( LigCaretListOffset );
205
OTV_SIZE_CHECK( LigCaretListOffset );
206
if ( LigCaretListOffset )
208
OTV_NEST3( LigCaretList, LigGlyph, CaretValue );
209
OTV_RUN( table + LigCaretListOffset, valid );
212
if ( need_MarkAttachClassDef )
214
OTV_OPTIONAL_OFFSET( MarkAttachClassDef );
215
OTV_SIZE_CHECK( MarkAttachClassDef );
216
if ( MarkAttachClassDef )
217
otv_ClassDef_validate( table + MarkAttachClassDef, valid );