~ubuntu-branches/ubuntu/utopic/hedgewars/utopic

« back to all changes in this revision

Viewing changes to misc/libfreetype/src/gxvalid/gxvlcar.c

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2014-01-02 12:37:23 UTC
  • mfrom: (19.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20140102123723-6pdhmyj8tb5y8xbg
Tags: 0.9.20.3-1
New upstream minor release, suitable for unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */