~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/freetype/src/autofit/afhints.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __AFHINTS_H__
 
2
#define __AFHINTS_H__
 
3
 
 
4
#include "aftypes.h"
 
5
 
 
6
FT_BEGIN_HEADER
 
7
 
 
8
 /*
 
9
  *  The definition of outline glyph hints. These are shared by all
 
10
  *  script analysis routines (until now)
 
11
  *
 
12
  */
 
13
 
 
14
  typedef enum
 
15
  {
 
16
    AF_DIMENSION_HORZ = 0,  /* x coordinates, i.e. vertical segments & edges   */
 
17
    AF_DIMENSION_VERT = 1,  /* y coordinates, i.e. horizontal segments & edges */
 
18
 
 
19
    AF_DIMENSION_MAX  /* do not remove */
 
20
 
 
21
  } AF_Dimension;
 
22
 
 
23
 
 
24
  /* hint directions -- the values are computed so that two vectors are */
 
25
  /* in opposite directions iff `dir1+dir2 == 0'                        */
 
26
  typedef enum
 
27
  {
 
28
    AF_DIR_NONE  =  4,
 
29
    AF_DIR_RIGHT =  1,
 
30
    AF_DIR_LEFT  = -1,
 
31
    AF_DIR_UP    =  2,
 
32
    AF_DIR_DOWN  = -2
 
33
 
 
34
  } AF_Direction;
 
35
 
 
36
 
 
37
  /* point hint flags */
 
38
  typedef enum
 
39
  {
 
40
    AF_FLAG_NONE    = 0,
 
41
 
 
42
   /* point type flags */
 
43
    AF_FLAG_CONIC   = (1 << 0),
 
44
    AF_FLAG_CUBIC   = (1 << 1),
 
45
    AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
 
46
 
 
47
   /* point extremum flags */
 
48
    AF_FLAG_EXTREMA_X = (1 << 2),
 
49
    AF_FLAG_EXTREMA_Y = (1 << 3),
 
50
 
 
51
   /* point roundness flags */
 
52
    AF_FLAG_ROUND_X = (1 << 4),
 
53
    AF_FLAG_ROUND_Y = (1 << 5),
 
54
 
 
55
   /* point touch flags */
 
56
    AF_FLAG_TOUCH_X = (1 << 6),
 
57
    AF_FLAG_TOUCH_Y = (1 << 7),
 
58
 
 
59
   /* candidates for weak interpolation have this flag set */
 
60
    AF_FLAG_WEAK_INTERPOLATION = (1 << 8),
 
61
 
 
62
   /* all inflection points in the outline have this flag set */
 
63
    AF_FLAG_INFLECTION         = (1 << 9)
 
64
 
 
65
  } AF_Flags;
 
66
 
 
67
 
 
68
  /* edge hint flags */
 
69
  typedef enum
 
70
  {
 
71
    AF_EDGE_NORMAL = 0,
 
72
    AF_EDGE_ROUND  = (1 << 0),
 
73
    AF_EDGE_SERIF  = (1 << 1),
 
74
    AF_EDGE_DONE   = (1 << 2)
 
75
 
 
76
  } AF_Edge_Flags;
 
77
 
 
78
 
 
79
 
 
80
  typedef struct AF_PointRec_*    AF_Point;
 
81
  typedef struct AF_SegmentRec_*  AF_Segment;
 
82
  typedef struct AF_EdgeRec_*     AF_Edge;
 
83
 
 
84
 
 
85
  typedef struct  AF_PointRec_
 
86
  {
 
87
    AF_Flags      flags;    /* point flags used by hinter */
 
88
    FT_Pos        ox, oy;   /* original, scaled position  */
 
89
    FT_Pos        fx, fy;   /* original, unscaled position (font units) */
 
90
    FT_Pos        x,  y;    /* current position */
 
91
    FT_Pos        u,  v;    /* current (x,y) or (y,x) depending on context */
 
92
 
 
93
    AF_Direction  in_dir;   /* direction of inwards vector  */
 
94
    AF_Direction  out_dir;  /* direction of outwards vector */
 
95
 
 
96
    AF_Point      next;     /* next point in contour     */
 
97
    AF_Point      prev;     /* previous point in contour */
 
98
 
 
99
  } AF_PointRec;
 
100
 
 
101
 
 
102
  typedef struct  AF_SegmentRec_
 
103
  {
 
104
    AF_Edge_Flags  flags;       /* edge/segment flags for this segment */
 
105
    AF_Direction   dir;         /* segment direction                   */
 
106
    FT_Pos         pos;         /* position of segment                 */
 
107
    FT_Pos         min_coord;   /* minimum coordinate of segment       */
 
108
    FT_Pos         max_coord;   /* maximum coordinate of segment       */
 
109
 
 
110
    AF_Edge        edge;        /* the segment's parent edge */
 
111
    AF_Segment     edge_next;   /* link to next segment in parent edge */
 
112
 
 
113
    AF_Segment     link;        /* (stem) link segment        */
 
114
    AF_Segment     serif;       /* primary segment for serifs */
 
115
    FT_Pos         num_linked;  /* number of linked segments  */
 
116
    FT_Pos         score;       /* used during stem matching  */
 
117
 
 
118
    AF_Point       first;       /* first point in edge segment             */
 
119
    AF_Point       last;        /* last point in edge segment              */
 
120
    AF_Point*      contour;     /* ptr to first point of segment's contour */
 
121
 
 
122
  } AF_SegmentRec;
 
123
 
 
124
 
 
125
  typedef struct  AF_EdgeRec_
 
126
  {
 
127
    FT_Pos         fpos;       /* original, unscaled position (font units) */
 
128
    FT_Pos         opos;       /* original, scaled position                */
 
129
    FT_Pos         pos;        /* current position                         */
 
130
 
 
131
    AF_Edge_Flags  flags;      /* edge flags */
 
132
    AF_Direction   dir;        /* edge direction */
 
133
    FT_Fixed       scale;      /* used to speed up interpolation between edges */
 
134
    AF_Width       blue_edge;  /* non-NULL if this is a blue edge              */
 
135
 
 
136
    AF_Edge        link;
 
137
    AF_Edge        serif;
 
138
    FT_Int         num_linked;
 
139
 
 
140
    FT_Int         score;
 
141
 
 
142
    AF_Segment     first;
 
143
    AF_Segment     last;
 
144
 
 
145
  } AF_EdgeRec;
 
146
 
 
147
 
 
148
  typedef struct AF_AxisHintsRec_
 
149
  {
 
150
    FT_Int        num_segments;
 
151
    AF_Segment    segments;
 
152
 
 
153
    FT_Int        num_edges;
 
154
    AF_Edge       edges;
 
155
 
 
156
    AF_Direction  major_dir;
 
157
 
 
158
  } AF_AxisHintsRec, *AF_AxisHints;
 
159
 
 
160
 
 
161
  typedef struct AF_GlyphHintsRec_
 
162
  {
 
163
    FT_Memory     memory;
 
164
 
 
165
    FT_Fixed      x_scale;
 
166
    FT_Pos        x_delta;
 
167
 
 
168
    FT_Fixed      y_scale;
 
169
    FT_Pos        y_delta;
 
170
 
 
171
    FT_Pos        edge_distance_threshold;
 
172
 
 
173
    FT_Int        max_points;
 
174
    FT_Int        num_points;
 
175
    AF_Point      points;
 
176
 
 
177
    FT_Int        max_contours;
 
178
    FT_Int        num_contours;
 
179
    AF_Point*     contours;
 
180
 
 
181
    AF_AxisHintsRec  axis[ AF_DIMENSION_MAX ];
 
182
    
 
183
    FT_UInt32         scaler_flags;  /* copy of scaler flags */
 
184
    FT_UInt32         other_flags;   /* free for script-specific implementations */
 
185
    AF_ScriptMetrics  metrics;
 
186
 
 
187
  } AF_GlyphHintsRec;
 
188
 
 
189
 
 
190
#define  AF_HINTS_TEST_SCALER(h,f)  ( (h)->scaler_flags & (f) )
 
191
#define  AF_HINTS_TEST_OTHER(h,f)   ( (h)->other_flags  & (f) )
 
192
 
 
193
#define  AF_HINTS_DO_HORIZONTAL(h)  \
 
194
            !AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_HORIZONTAL)
 
195
 
 
196
#define  AF_HINTS_DO_VERTICAL(h)    \
 
197
            !AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_VERTICAL)
 
198
 
 
199
#define  AF_HINTS_DO_ADVANCE(h)     \
 
200
            !AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_ADVANCE)
 
201
 
 
202
 
 
203
  FT_LOCAL( AF_Direction )
 
204
  af_direction_compute( FT_Pos  dx,
 
205
                        FT_Pos  dy );
 
206
 
 
207
 
 
208
  FT_LOCAL( void )
 
209
  af_glyph_hints_init( AF_GlyphHints  hints,
 
210
                       FT_Memory      memory );
 
211
 
 
212
 
 
213
 
 
214
 /*  recomputes all AF_Point in a AF_GlyphHints from the definitions
 
215
  *  in a source outline
 
216
  */
 
217
  FT_LOCAL( void )
 
218
  af_glyph_hints_rescale( AF_GlyphHints     hints,
 
219
                          AF_ScriptMetrics  metrics );
 
220
 
 
221
  FT_LOCAL( FT_Error )
 
222
  af_glyph_hints_reload( AF_GlyphHints     hints,
 
223
                         FT_Outline*       outline );
 
224
 
 
225
  FT_LOCAL( void )
 
226
  af_glyph_hints_save( AF_GlyphHints   hints,
 
227
                       FT_Outline*     outline );
 
228
 
 
229
  FT_LOCAL( void )
 
230
  af_glyph_hints_align_edge_points( AF_GlyphHints  hints,
 
231
                                    AF_Dimension   dim );
 
232
 
 
233
  FT_LOCAL( void )
 
234
  af_glyph_hints_align_strong_points( AF_GlyphHints  hints,
 
235
                                      AF_Dimension   dim );
 
236
 
 
237
  FT_LOCAL( void )
 
238
  af_glyph_hints_align_weak_points( AF_GlyphHints  hints,
 
239
                                    AF_Dimension   dim );
 
240
 
 
241
  FT_LOCAL( void )
 
242
  af_glyph_hints_done( AF_GlyphHints  hints );
 
243
 
 
244
/* */
 
245
 
 
246
FT_END_HEADER
 
247
 
 
248
#endif /* __AFHINTS_H__ */