zenilib: zenilib/jni/external/freetype2/src/gxvalid/gxvlcar.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gxvlcar.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* gxvlcar.c */
4 /* */
5 /* TrueTypeGX/AAT lcar 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 /***************************************************************************/
17
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 /***************************************************************************/
25
26
27 #include "gxvalid.h"
28 #include "gxvcommn.h"
29
30
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_gxvlcar
39
40
41 /*************************************************************************/
42 /*************************************************************************/
43 /***** *****/
44 /***** Data and Types *****/
45 /***** *****/
46 /*************************************************************************/
47 /*************************************************************************/
48
49 typedef struct GXV_lcar_DataRec_
50 {
51 FT_UShort format;
52
53 } GXV_lcar_DataRec, *GXV_lcar_Data;
54
55
56 #define GXV_LCAR_DATA( FIELD ) GXV_TABLE_DATA( lcar, FIELD )
57
58
59 /*************************************************************************/
60 /*************************************************************************/
61 /***** *****/
62 /***** UTILITY FUNCTIONS *****/
63 /***** *****/
64 /*************************************************************************/
65 /*************************************************************************/
66
67 static void
68 gxv_lcar_partial_validate( FT_UShort partial,
69 FT_UShort glyph,
70 GXV_Validator valid )
71 {
72 GXV_NAME_ENTER( "partial" );
73
74 if ( GXV_LCAR_DATA( format ) != 1 )
75 goto Exit;
76
77 gxv_ctlPoint_validate( glyph, partial, valid );
78
79 Exit:
80 GXV_EXIT;
81 }
82
83
84 static void
85 gxv_lcar_LookupValue_validate( FT_UShort glyph,
86 GXV_LookupValueCPtr value_p,
87 GXV_Validator valid )
88 {
89 FT_Bytes p = valid->root->base + value_p->u;
90 FT_Bytes limit = valid->root->limit;
91 FT_UShort count;
92 FT_Short partial;
93 FT_UShort i;
94
95
96 GXV_NAME_ENTER( "element in lookupTable" );
97
98 GXV_LIMIT_CHECK( 2 );
99 count = FT_NEXT_USHORT( p );
100
101 GXV_LIMIT_CHECK( 2 * count );
102 for ( i = 0; i < count; i++ )
103 {
104 partial = FT_NEXT_SHORT( p );
105 gxv_lcar_partial_validate( partial, glyph, valid );
106 }
107
108 GXV_EXIT;
109 }
110
111
112 /*
113 +------ lcar --------------------+
114 | |
115 | +===============+ |
116 | | looup header | |
117 | +===============+ |
118 | | BinSrchHeader | |
119 | +===============+ |
120 | | lastGlyph[0] | |
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 | +---------------+ |
130 | | offset[1] | |
131 | +===============+ |
132 | |
133 | .... |
134 | |
135 | 16bit value array |
136 | +===============+ |
137 +------| value | <-------+
138 | ....
139 |
140 |
141 |
142 |
143 |
144 +----> lcar values...handled by lcar callback function
145 */
146
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 )
152 {
153 FT_Bytes p;
154 FT_Bytes limit;
155 FT_UShort offset;
156 GXV_LookupValueDesc value;
157
158 FT_UNUSED( lookuptbl_limit );
159
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;
165
166 GXV_LIMIT_CHECK ( 2 );
167 value.u = FT_NEXT_USHORT( p );
168
169 return value;
170 }
171
172
173 /*************************************************************************/
174 /*************************************************************************/
175 /***** *****/
176 /***** lcar TABLE *****/
177 /***** *****/
178 /*************************************************************************/
179 /*************************************************************************/
180
181 FT_LOCAL_DEF( void )
182 gxv_lcar_validate( FT_Bytes table,
183 FT_Face face,
184 FT_Validator ftvalid )
185 {
186 FT_Bytes p = table;
187 FT_Bytes limit = 0;
188 GXV_ValidatorRec validrec;
189 GXV_Validator valid = &validrec;
190
191 GXV_lcar_DataRec lcarrec;
192 GXV_lcar_Data lcar = &lcarrec;
193
194 FT_Fixed version;
195
196
197 valid->root = ftvalid;
198 valid->table_data = lcar;
199 valid->face = face;
200
201 FT_TRACE3(( "validating `lcar' table\n" ));
202 GXV_INIT;
203
204 GXV_LIMIT_CHECK( 4 + 2 );
205 version = FT_NEXT_ULONG( p );
206 GXV_LCAR_DATA( format ) = FT_NEXT_USHORT( p );
207
208 if ( version != 0x00010000UL)
209 FT_INVALID_FORMAT;
210
211 if ( GXV_LCAR_DATA( format ) > 1 )
212 FT_INVALID_FORMAT;
213
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 );
218
219 FT_TRACE4(( "\n" ));
220 }
221
222
223 /* END */
table
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glew.h:4422
gxv_ctlPoint_validate
gxv_ctlPoint_validate(FT_UShort gid, FT_Short ctl_point, GXV_Validator valid)
Definition: gxvcommn.c:846
FT_INVALID_FORMAT
#define FT_INVALID_FORMAT
Definition: ftvalid.h:133
GXV_NAME_ENTER
#define GXV_NAME_ENTER(name)
Definition: gxvcommn.h:301
gxv_lcar_LookupValue_validate
static void gxv_lcar_LookupValue_validate(FT_UShort glyph, GXV_LookupValueCPtr value_p, GXV_Validator valid)
Definition: gxvlcar.c:85
GXV_ValidatorRec_::face
FT_Face face
Definition: gxvcommn.h:241
GXV_LookupValueDesc_::u
FT_UShort u
Definition: gxvcommn.h:91
gxvalid.h
version
int const char * version
Definition: zlib.h:813
gxv_lcar_validate
gxv_lcar_validate(FT_Bytes table, FT_Face face, FT_Validator valid)
Definition: gxvlcar.c:182
gxv_lcar_partial_validate
static void gxv_lcar_partial_validate(FT_UShort partial, FT_UShort glyph, GXV_Validator valid)
Definition: gxvlcar.c:68
GXV_ValidatorRec_::table_data
void * table_data
Definition: gxvcommn.h:242
GXV_lcar_Data
struct GXV_lcar_DataRec_ * GXV_lcar_Data
FT_TRACE4
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
GXV_EXIT
#define GXV_EXIT
Definition: gxvcommn.h:302
FT_LOCAL_DEF
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:467
FT_FaceRec_
Definition: freetype.h:912
count
GLint GLsizei count
Definition: gl2ext.h:1011
face
GLenum face
Definition: gl2ext.h:1490
p
GLfloat GLfloat p
Definition: glew.h:14938
FT_Validator
typedefFT_BEGIN_HEADER struct FT_ValidatorRec_ volatile * FT_Validator
Definition: ftvalid.h:42
format
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl2ext.h:845
limit
GLint limit
Definition: glew.h:11829
FT_Bytes
const FT_Byte * FT_Bytes
Definition: fttypes.h:161
gxv_lcar_LookupFmt4_transit
static GXV_LookupValueDesc gxv_lcar_LookupFmt4_transit(FT_UShort relative_gindex, GXV_LookupValueCPtr base_value_p, FT_Bytes lookuptbl_limit, GXV_Validator valid)
Definition: gxvlcar.c:148
GXV_LCAR_DATA
#define GXV_LCAR_DATA(FIELD)
Definition: gxvlcar.c:56
FT_Short
signed short FT_Short
Definition: fttypes.h:194
gxv_LookupTable_validate
gxv_LookupTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
Definition: gxvcommn.c:755
sizeof
sizeof(FT_AutofitterRec)
FT_NEXT_USHORT
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:233
FT_TRACE3
#define FT_TRACE3(varformat)
Definition: ftdebug.h:160
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
GXV_LookupValueDesc_
Definition: gxvcommn.h:89
offset
GLintptr offset
Definition: glew.h:1668
FT_Fixed
signed long FT_Fixed
Definition: fttypes.h:284
FT_NEXT_ULONG
#define FT_NEXT_ULONG(buffer)
Definition: ftstream.h:245
GXV_ValidatorRec_::lookupfmt4_trans
GXV_Lookup_Fmt4_Transit_Func lookupfmt4_trans
Definition: gxvcommn.h:248
GXV_ValidatorRec_::root
FT_Validator root
Definition: gxvcommn.h:239
GXV_lcar_DataRec
struct GXV_lcar_DataRec_ GXV_lcar_DataRec
GXV_LOOKUPVALUE_UNSIGNED
Definition: gxvcommn.h:100
i
int i
Definition: pngrutil.c:1377
gxvcommn.h
FT_NEXT_SHORT
#define FT_NEXT_SHORT(buffer)
Definition: ftstream.h:230
GXV_ValidatorRec_::lookupval_func
GXV_Lookup_Value_Validate_Func lookupval_func
Definition: gxvcommn.h:247
GXV_ValidatorRec_::lookupval_sign
GXV_LookupValue_SignSpec lookupval_sign
Definition: gxvcommn.h:246
FT_UShort
unsigned short FT_UShort
Definition: fttypes.h:205
GXV_INIT
#define GXV_INIT
Definition: gxvcommn.h:300
FT_UNUSED
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
GXV_ValidatorRec_
Definition: gxvcommn.h:237
GXV_LIMIT_CHECK
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272