1
/***************************************************************************/
5
/* TrueTypeGX/AAT lcar table validation (body). */
7
/* Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
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
/***************************************************************************/
18
/***************************************************************************/
20
/* gxvalid is derived from both gxlayout module and otvalid module. */
21
/* Development of gxlayout is supported by the Information-technology */
22
/* Promotion Agency(IPA), Japan. */
24
/***************************************************************************/
31
/*************************************************************************/
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. */
38
#define FT_COMPONENT trace_gxvlcar
41
/*************************************************************************/
42
/*************************************************************************/
44
/***** Data and Types *****/
46
/*************************************************************************/
47
/*************************************************************************/
49
typedef struct GXV_lcar_DataRec_
53
} GXV_lcar_DataRec, *GXV_lcar_Data;
56
#define GXV_LCAR_DATA( FIELD ) GXV_TABLE_DATA( lcar, FIELD )
59
/*************************************************************************/
60
/*************************************************************************/
62
/***** UTILITY FUNCTIONS *****/
64
/*************************************************************************/
65
/*************************************************************************/
68
gxv_lcar_partial_validate( FT_UShort partial,
72
GXV_NAME_ENTER( "partial" );
74
if ( GXV_LCAR_DATA( format ) != 1 )
77
gxv_ctlPoint_validate( glyph, partial, valid );
85
gxv_lcar_LookupValue_validate( FT_UShort glyph,
86
GXV_LookupValueCPtr value_p,
89
FT_Bytes p = valid->root->base + value_p->u;
90
FT_Bytes limit = valid->root->limit;
96
GXV_NAME_ENTER( "element in lookupTable" );
99
count = FT_NEXT_USHORT( p );
101
GXV_LIMIT_CHECK( 2 * count );
102
for ( i = 0; i < count; i++ )
104
partial = FT_NEXT_SHORT( p );
105
gxv_lcar_partial_validate( partial, glyph, valid );
113
+------ lcar --------------------+
115
| +===============+ |
117
| +===============+ |
118
| | BinSrchHeader | |
119
| +===============+ |
121
| +---------------+ |
122
| | firstGlyph[0] | | head of lcar sfnt table
123
| +---------------+ | +
124
| | offset[0] | -> | offset [byte]
125
| +===============+ | +
126
| | lastGlyph[1] | | (glyphID - firstGlyph) * 2 [byte]
127
| +---------------+ |
128
| | firstGlyph[1] | |
129
| +---------------+ |
131
| +===============+ |
135
| 16bit value array |
136
| +===============+ |
137
+------| value | <-------+
144
+----> lcar values...handled by lcar callback function
147
static GXV_LookupValueDesc
148
gxv_lcar_LookupFmt4_transit( FT_UShort relative_gindex,
149
GXV_LookupValueCPtr base_value_p,
150
FT_Bytes lookuptbl_limit,
151
GXV_Validator valid )
156
GXV_LookupValueDesc value;
158
FT_UNUSED( lookuptbl_limit );
160
/* XXX: check range? */
161
offset = (FT_UShort)( base_value_p->u +
162
relative_gindex * sizeof ( FT_UShort ) );
163
p = valid->root->base + offset;
164
limit = valid->root->limit;
166
GXV_LIMIT_CHECK ( 2 );
167
value.u = FT_NEXT_USHORT( p );
173
/*************************************************************************/
174
/*************************************************************************/
176
/***** lcar TABLE *****/
178
/*************************************************************************/
179
/*************************************************************************/
182
gxv_lcar_validate( FT_Bytes table,
184
FT_Validator ftvalid )
188
GXV_ValidatorRec validrec;
189
GXV_Validator valid = &validrec;
191
GXV_lcar_DataRec lcarrec;
192
GXV_lcar_Data lcar = &lcarrec;
197
valid->root = ftvalid;
198
valid->table_data = lcar;
201
FT_TRACE3(( "validating `lcar' table\n" ));
204
GXV_LIMIT_CHECK( 4 + 2 );
205
version = FT_NEXT_ULONG( p );
206
GXV_LCAR_DATA( format ) = FT_NEXT_USHORT( p );
208
if ( version != 0x00010000UL)
211
if ( GXV_LCAR_DATA( format ) > 1 )
214
valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
215
valid->lookupval_func = gxv_lcar_LookupValue_validate;
216
valid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit;
217
gxv_LookupTable_validate( p, limit, valid );