1 /****************************************************************************
5 * TrueTypeGX/AAT lcar table validation (body).
7 * Copyright (C) 2004-2020 by
8 * suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
9 * David Turner, Robert Wilhelm, and Werner Lemberg.
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.
19 /****************************************************************************
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.
32 /**************************************************************************
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.
39 #define FT_COMPONENT gxvlcar
42 /*************************************************************************/
43 /*************************************************************************/
45 /***** Data and Types *****/
47 /*************************************************************************/
48 /*************************************************************************/
50 typedef struct GXV_lcar_DataRec_
54 } GXV_lcar_DataRec, *GXV_lcar_Data;
57 #define GXV_LCAR_DATA( FIELD ) GXV_TABLE_DATA( lcar, FIELD )
60 /*************************************************************************/
61 /*************************************************************************/
63 /***** UTILITY FUNCTIONS *****/
65 /*************************************************************************/
66 /*************************************************************************/
69 gxv_lcar_partial_validate( FT_Short partial,
71 GXV_Validator gxvalid )
73 GXV_NAME_ENTER( "partial" );
75 if ( GXV_LCAR_DATA( format ) != 1 )
78 gxv_ctlPoint_validate( glyph, (FT_UShort)partial, gxvalid );
86 gxv_lcar_LookupValue_validate( FT_UShort glyph,
87 GXV_LookupValueCPtr value_p,
88 GXV_Validator gxvalid )
90 FT_Bytes p = gxvalid->root->base + value_p->u;
91 FT_Bytes limit = gxvalid->root->limit;
97 GXV_NAME_ENTER( "element in lookupTable" );
100 count = FT_NEXT_USHORT( p );
102 GXV_LIMIT_CHECK( 2 * count );
103 for ( i = 0; i < count; i++ )
105 partial = FT_NEXT_SHORT( p );
106 gxv_lcar_partial_validate( partial, glyph, gxvalid );
114 +------ lcar --------------------+
116 | +===============+ |
117 | | lookup header | |
118 | +===============+ |
119 | | BinSrchHeader | |
120 | +===============+ |
122 | +---------------+ |
123 | | firstGlyph[0] | | head of lcar sfnt table
124 | +---------------+ | +
125 | | offset[0] | -> | offset [byte]
126 | +===============+ | +
127 | | lastGlyph[1] | | (glyphID - firstGlyph) * 2 [byte]
128 | +---------------+ |
129 | | firstGlyph[1] | |
130 | +---------------+ |
132 | +===============+ |
136 | 16bit value array |
137 | +===============+ |
138 +------| value | <-------+
145 +----> lcar values...handled by lcar callback function
148 static GXV_LookupValueDesc
149 gxv_lcar_LookupFmt4_transit( FT_UShort relative_gindex,
150 GXV_LookupValueCPtr base_value_p,
151 FT_Bytes lookuptbl_limit,
152 GXV_Validator gxvalid )
157 GXV_LookupValueDesc value;
159 FT_UNUSED( lookuptbl_limit );
161 /* XXX: check range? */
162 offset = (FT_UShort)( base_value_p->u +
163 relative_gindex * sizeof ( FT_UShort ) );
164 p = gxvalid->root->base + offset;
165 limit = gxvalid->root->limit;
167 GXV_LIMIT_CHECK ( 2 );
168 value.u = FT_NEXT_USHORT( p );
174 /*************************************************************************/
175 /*************************************************************************/
177 /***** lcar TABLE *****/
179 /*************************************************************************/
180 /*************************************************************************/
183 gxv_lcar_validate( FT_Bytes table,
185 FT_Validator ftvalid )
189 GXV_ValidatorRec gxvalidrec;
190 GXV_Validator gxvalid = &gxvalidrec;
192 GXV_lcar_DataRec lcarrec;
193 GXV_lcar_Data lcar = &lcarrec;
198 gxvalid->root = ftvalid;
199 gxvalid->table_data = lcar;
200 gxvalid->face = face;
202 FT_TRACE3(( "validating `lcar' table\n" ));
205 GXV_LIMIT_CHECK( 4 + 2 );
206 version = FT_NEXT_LONG( p );
207 GXV_LCAR_DATA( format ) = FT_NEXT_USHORT( p );
209 if ( version != 0x00010000UL)
212 if ( GXV_LCAR_DATA( format ) > 1 )
215 gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
216 gxvalid->lookupval_func = gxv_lcar_LookupValue_validate;
217 gxvalid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit;
218 gxv_LookupTable_validate( p, limit, gxvalid );