Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
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  {
52 
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;
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;
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 )
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 
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 );
207 
208  if ( version != 0x00010000UL)
210 
211  if ( GXV_LCAR_DATA( format ) > 1 )
213 
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 */
gxv_lcar_validate(FT_Bytes table, FT_Face face, FT_Validator ftvalid)
Definition: gxvlcar.c:182
GLfloat GLfloat p
gxv_ctlPoint_validate(FT_UShort gid, FT_Short ctl_point, GXV_Validator valid)
Definition: gxvcommn.c:846
#define FT_INVALID_FORMAT
Definition: ftvalid.h:133
#define GXV_NAME_ENTER(name)
Definition: gxvcommn.h:301
sizeof(AF_ModuleRec)
#define FT_UNUSED(arg)
Definition: ftconfig.h:76
void * table_data
Definition: gxvcommn.h:242
png_uint_32 i
Definition: png.h:2640
GLenum GLuint GLint GLenum face
struct GXV_lcar_DataRec_ * GXV_lcar_Data
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
#define GXV_EXIT
Definition: gxvcommn.h:302
typedefFT_BEGIN_HEADER struct FT_ValidatorRec_ volatile * FT_Validator
Definition: ftvalid.h:42
int const char * version
Definition: zlib.h:813
const FT_Byte * FT_Bytes
Definition: fttypes.h:161
GLintptr offset
#define GXV_LCAR_DATA(FIELD)
Definition: gxvlcar.c:56
GLsizei const GLfloat * value
signed short FT_Short
Definition: fttypes.h:194
gxv_LookupTable_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator valid)
Definition: gxvcommn.c:755
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
#define FT_TRACE3(varformat)
Definition: ftdebug.h:160
signed long FT_Fixed
Definition: fttypes.h:284
#define FT_NEXT_ULONG(buffer)
Definition: ftstream.h:238
GXV_Lookup_Fmt4_Transit_Func lookupfmt4_trans
Definition: gxvcommn.h:248
FT_Validator root
Definition: gxvcommn.h:239
struct GXV_lcar_DataRec_ GXV_lcar_DataRec
GLuint GLuint GLsizei count
#define FT_NEXT_SHORT(buffer)
Definition: ftstream.h:223
GXV_Lookup_Value_Validate_Func lookupval_func
Definition: gxvcommn.h:247
GXV_LookupValue_SignSpec lookupval_sign
Definition: gxvcommn.h:246
unsigned short FT_UShort
Definition: fttypes.h:205
GLenum GLsizei GLenum GLenum const GLvoid * table
#define GXV_INIT
Definition: gxvcommn.h:300
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLint limit
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:236
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272