mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / gxvalid / gxvopbd.c
blobe1250609460ac1bc6fcafce25c89cb8b68579664
1 /***************************************************************************/
2 /* */
3 /* gxvopbd.c */
4 /* */
5 /* TrueTypeGX/AAT opbd table validation (body). */
6 /* */
7 /* Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
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. */
15 /* */
16 /***************************************************************************/
18 /***************************************************************************/
19 /* */
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. */
23 /* */
24 /***************************************************************************/
27 #include "gxvalid.h"
28 #include "gxvcommn.h"
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_gxvopbd
41 /*************************************************************************/
42 /*************************************************************************/
43 /***** *****/
44 /***** Data and Types *****/
45 /***** *****/
46 /*************************************************************************/
47 /*************************************************************************/
49 typedef struct GXV_opbd_DataRec_
51 FT_UShort format;
52 FT_UShort valueOffset_min;
54 } GXV_opbd_DataRec, *GXV_opbd_Data;
57 #define GXV_OPBD_DATA( FIELD ) GXV_TABLE_DATA( opbd, FIELD )
60 /*************************************************************************/
61 /*************************************************************************/
62 /***** *****/
63 /***** UTILITY FUNCTIONS *****/
64 /***** *****/
65 /*************************************************************************/
66 /*************************************************************************/
68 static void
69 gxv_opbd_LookupValue_validate( FT_UShort glyph,
70 GXV_LookupValueCPtr value_p,
71 GXV_Validator valid )
73 /* offset in LookupTable is measured from the head of opbd table */
74 FT_Bytes p = valid->root->base + value_p->u;
75 FT_Bytes limit = valid->root->limit;
76 FT_Short delta_value;
77 int i;
80 if ( value_p->u < GXV_OPBD_DATA( valueOffset_min ) )
81 GXV_OPBD_DATA( valueOffset_min ) = value_p->u;
83 for ( i = 0; i < 4; i++ )
85 GXV_LIMIT_CHECK( 2 );
86 delta_value = FT_NEXT_SHORT( p );
88 if ( GXV_OPBD_DATA( format ) ) /* format 1, value is ctrl pt. */
90 if ( delta_value == -1 )
91 continue;
93 gxv_ctlPoint_validate( glyph, delta_value, valid );
95 else /* format 0, value is distance */
96 continue;
102 opbd ---------------------+
104 +===============+ |
105 | lookup header | |
106 +===============+ |
107 | BinSrchHeader | |
108 +===============+ |
109 | lastGlyph[0] | |
110 +---------------+ |
111 | firstGlyph[0] | | head of opbd sfnt table
112 +---------------+ | +
113 | offset[0] | -> | offset [byte]
114 +===============+ | +
115 | lastGlyph[1] | | (glyphID - firstGlyph) * 4 * sizeof(FT_Short) [byte]
116 +---------------+ |
117 | firstGlyph[1] | |
118 +---------------+ |
119 | offset[1] | |
120 +===============+ |
122 .... |
124 48bit value array |
125 +===============+ |
126 | value | <-------+
130 +---------------+
131 .... */
133 static GXV_LookupValueDesc
134 gxv_opbd_LookupFmt4_transit( FT_UShort relative_gindex,
135 GXV_LookupValueCPtr base_value_p,
136 FT_Bytes lookuptbl_limit,
137 GXV_Validator valid )
139 GXV_LookupValueDesc value;
141 FT_UNUSED( lookuptbl_limit );
142 FT_UNUSED( valid );
144 /* XXX: check range? */
145 value.u = (FT_UShort)( base_value_p->u +
146 relative_gindex * 4 * sizeof ( FT_Short ) );
148 return value;
152 /*************************************************************************/
153 /*************************************************************************/
154 /***** *****/
155 /***** opbd TABLE *****/
156 /***** *****/
157 /*************************************************************************/
158 /*************************************************************************/
160 FT_LOCAL_DEF( void )
161 gxv_opbd_validate( FT_Bytes table,
162 FT_Face face,
163 FT_Validator ftvalid )
165 GXV_ValidatorRec validrec;
166 GXV_Validator valid = &validrec;
167 GXV_opbd_DataRec opbdrec;
168 GXV_opbd_Data opbd = &opbdrec;
169 FT_Bytes p = table;
170 FT_Bytes limit = 0;
172 FT_ULong version;
175 valid->root = ftvalid;
176 valid->table_data = opbd;
177 valid->face = face;
179 FT_TRACE3(( "validating `opbd' table\n" ));
180 GXV_INIT;
181 GXV_OPBD_DATA( valueOffset_min ) = 0xFFFFU;
184 GXV_LIMIT_CHECK( 4 + 2 );
185 version = FT_NEXT_ULONG( p );
186 GXV_OPBD_DATA( format ) = FT_NEXT_USHORT( p );
189 /* only 0x00010000 is defined (1996) */
190 GXV_TRACE(( "(version=0x%08x)\n", version ));
191 if ( 0x00010000UL != version )
192 FT_INVALID_FORMAT;
194 /* only values 0 and 1 are defined (1996) */
195 GXV_TRACE(( "(format=0x%04x)\n", GXV_OPBD_DATA( format ) ));
196 if ( 0x0001 < GXV_OPBD_DATA( format ) )
197 FT_INVALID_FORMAT;
199 valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
200 valid->lookupval_func = gxv_opbd_LookupValue_validate;
201 valid->lookupfmt4_trans = gxv_opbd_LookupFmt4_transit;
203 gxv_LookupTable_validate( p, limit, valid );
204 p += valid->subtable_length;
206 if ( p > table + GXV_OPBD_DATA( valueOffset_min ) )
208 GXV_TRACE((
209 "found overlap between LookupTable and opbd_value array\n" ));
210 FT_INVALID_OFFSET;
213 FT_TRACE4(( "\n" ));
217 /* END */