mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / autofit / afhints.h
blob675826835ae286e0e77842887b33368289bcf578
1 /***************************************************************************/
2 /* */
3 /* afhints.h */
4 /* */
5 /* Auto-fitter hinting routines (specification). */
6 /* */
7 /* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
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 /***************************************************************************/
19 #ifndef __AFHINTS_H__
20 #define __AFHINTS_H__
22 #include "aftypes.h"
24 #define xxAF_SORT_SEGMENTS
26 FT_BEGIN_HEADER
29 * The definition of outline glyph hints. These are shared by all
30 * script analysis routines (until now).
33 typedef enum AF_Dimension_
35 AF_DIMENSION_HORZ = 0, /* x coordinates, */
36 /* i.e., vertical segments & edges */
37 AF_DIMENSION_VERT = 1, /* y coordinates, */
38 /* i.e., horizontal segments & edges */
40 AF_DIMENSION_MAX /* do not remove */
42 } AF_Dimension;
45 /* hint directions -- the values are computed so that two vectors are */
46 /* in opposite directions iff `dir1 + dir2 == 0' */
47 typedef enum AF_Direction_
49 AF_DIR_NONE = 4,
50 AF_DIR_RIGHT = 1,
51 AF_DIR_LEFT = -1,
52 AF_DIR_UP = 2,
53 AF_DIR_DOWN = -2
55 } AF_Direction;
58 /* point hint flags */
59 typedef enum AF_Flags_
61 AF_FLAG_NONE = 0,
63 /* point type flags */
64 AF_FLAG_CONIC = 1 << 0,
65 AF_FLAG_CUBIC = 1 << 1,
66 AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
68 /* point extremum flags */
69 AF_FLAG_EXTREMA_X = 1 << 2,
70 AF_FLAG_EXTREMA_Y = 1 << 3,
72 /* point roundness flags */
73 AF_FLAG_ROUND_X = 1 << 4,
74 AF_FLAG_ROUND_Y = 1 << 5,
76 /* point touch flags */
77 AF_FLAG_TOUCH_X = 1 << 6,
78 AF_FLAG_TOUCH_Y = 1 << 7,
80 /* candidates for weak interpolation have this flag set */
81 AF_FLAG_WEAK_INTERPOLATION = 1 << 8,
83 /* all inflection points in the outline have this flag set */
84 AF_FLAG_INFLECTION = 1 << 9
86 } AF_Flags;
89 /* edge hint flags */
90 typedef enum AF_Edge_Flags_
92 AF_EDGE_NORMAL = 0,
93 AF_EDGE_ROUND = 1 << 0,
94 AF_EDGE_SERIF = 1 << 1,
95 AF_EDGE_DONE = 1 << 2
97 } AF_Edge_Flags;
100 typedef struct AF_PointRec_* AF_Point;
101 typedef struct AF_SegmentRec_* AF_Segment;
102 typedef struct AF_EdgeRec_* AF_Edge;
105 typedef struct AF_PointRec_
107 FT_UShort flags; /* point flags used by hinter */
108 FT_Char in_dir; /* direction of inwards vector */
109 FT_Char out_dir; /* direction of outwards vector */
111 FT_Pos ox, oy; /* original, scaled position */
112 FT_Short fx, fy; /* original, unscaled position (font units) */
113 FT_Pos x, y; /* current position */
114 FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
116 AF_Point next; /* next point in contour */
117 AF_Point prev; /* previous point in contour */
119 } AF_PointRec;
122 typedef struct AF_SegmentRec_
124 FT_Byte flags; /* edge/segment flags for this segment */
125 FT_Char dir; /* segment direction */
126 FT_Short pos; /* position of segment */
127 FT_Short min_coord; /* minimum coordinate of segment */
128 FT_Short max_coord; /* maximum coordinate of segment */
129 FT_Short height; /* the hinted segment height */
131 AF_Edge edge; /* the segment's parent edge */
132 AF_Segment edge_next; /* link to next segment in parent edge */
134 AF_Segment link; /* (stem) link segment */
135 AF_Segment serif; /* primary segment for serifs */
136 FT_Pos num_linked; /* number of linked segments */
137 FT_Pos score; /* used during stem matching */
138 FT_Pos len; /* used during stem matching */
140 AF_Point first; /* first point in edge segment */
141 AF_Point last; /* last point in edge segment */
142 AF_Point* contour; /* ptr to first point of segment's contour */
144 } AF_SegmentRec;
147 typedef struct AF_EdgeRec_
149 FT_Short fpos; /* original, unscaled position (font units) */
150 FT_Pos opos; /* original, scaled position */
151 FT_Pos pos; /* current position */
153 FT_Byte flags; /* edge flags */
154 FT_Char dir; /* edge direction */
155 FT_Fixed scale; /* used to speed up interpolation between edges */
156 AF_Width blue_edge; /* non-NULL if this is a blue edge */
158 AF_Edge link;
159 AF_Edge serif;
160 FT_Short num_linked;
162 FT_Int score;
164 AF_Segment first;
165 AF_Segment last;
167 } AF_EdgeRec;
170 typedef struct AF_AxisHintsRec_
172 FT_Int num_segments;
173 FT_Int max_segments;
174 AF_Segment segments;
175 #ifdef AF_SORT_SEGMENTS
176 FT_Int mid_segments;
177 #endif
179 FT_Int num_edges;
180 FT_Int max_edges;
181 AF_Edge edges;
183 AF_Direction major_dir;
185 } AF_AxisHintsRec, *AF_AxisHints;
188 typedef struct AF_GlyphHintsRec_
190 FT_Memory memory;
192 FT_Fixed x_scale;
193 FT_Pos x_delta;
195 FT_Fixed y_scale;
196 FT_Pos y_delta;
198 FT_Pos edge_distance_threshold;
200 FT_Int max_points;
201 FT_Int num_points;
202 AF_Point points;
204 FT_Int max_contours;
205 FT_Int num_contours;
206 AF_Point* contours;
208 AF_AxisHintsRec axis[AF_DIMENSION_MAX];
210 FT_UInt32 scaler_flags; /* copy of scaler flags */
211 FT_UInt32 other_flags; /* free for script-specific */
212 /* implementations */
213 AF_ScriptMetrics metrics;
215 FT_Pos xmin_delta; /* used for warping */
216 FT_Pos xmax_delta;
218 } AF_GlyphHintsRec;
221 #define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) )
222 #define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) )
225 #ifdef AF_DEBUG
227 #define AF_HINTS_DO_HORIZONTAL( h ) \
228 ( !_af_debug_disable_horz_hints && \
229 !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) )
231 #define AF_HINTS_DO_VERTICAL( h ) \
232 ( !_af_debug_disable_vert_hints && \
233 !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) )
235 #define AF_HINTS_DO_ADVANCE( h ) \
236 !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
238 #define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
240 #else /* !AF_DEBUG */
242 #define AF_HINTS_DO_HORIZONTAL( h ) \
243 !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
245 #define AF_HINTS_DO_VERTICAL( h ) \
246 !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
248 #define AF_HINTS_DO_ADVANCE( h ) \
249 !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
251 #define AF_HINTS_DO_BLUES( h ) 1
253 #endif /* !AF_DEBUG */
256 FT_LOCAL( AF_Direction )
257 af_direction_compute( FT_Pos dx,
258 FT_Pos dy );
261 FT_LOCAL( FT_Error )
262 af_axis_hints_new_segment( AF_AxisHints axis,
263 FT_Memory memory,
264 AF_Segment *asegment );
266 FT_LOCAL( FT_Error)
267 af_axis_hints_new_edge( AF_AxisHints axis,
268 FT_Int fpos,
269 AF_Direction dir,
270 FT_Memory memory,
271 AF_Edge *edge );
273 FT_LOCAL( void )
274 af_glyph_hints_init( AF_GlyphHints hints,
275 FT_Memory memory );
280 * recompute all AF_Point in a AF_GlyphHints from the definitions
281 * in a source outline
283 FT_LOCAL( void )
284 af_glyph_hints_rescale( AF_GlyphHints hints,
285 AF_ScriptMetrics metrics );
287 FT_LOCAL( FT_Error )
288 af_glyph_hints_reload( AF_GlyphHints hints,
289 FT_Outline* outline,
290 FT_Bool get_inflections );
292 FT_LOCAL( void )
293 af_glyph_hints_save( AF_GlyphHints hints,
294 FT_Outline* outline );
296 FT_LOCAL( void )
297 af_glyph_hints_align_edge_points( AF_GlyphHints hints,
298 AF_Dimension dim );
300 FT_LOCAL( void )
301 af_glyph_hints_align_strong_points( AF_GlyphHints hints,
302 AF_Dimension dim );
304 FT_LOCAL( void )
305 af_glyph_hints_align_weak_points( AF_GlyphHints hints,
306 AF_Dimension dim );
308 #ifdef AF_USE_WARPER
309 FT_LOCAL( void )
310 af_glyph_hints_scale_dim( AF_GlyphHints hints,
311 AF_Dimension dim,
312 FT_Fixed scale,
313 FT_Pos delta );
314 #endif
316 FT_LOCAL( void )
317 af_glyph_hints_done( AF_GlyphHints hints );
319 /* */
321 #define AF_SEGMENT_LEN( seg ) ( (seg)->max_coord - (seg)->min_coord )
323 #define AF_SEGMENT_DIST( seg1, seg2 ) ( ( (seg1)->pos > (seg2)->pos ) \
324 ? (seg1)->pos - (seg2)->pos \
325 : (seg2)->pos - (seg1)->pos )
328 FT_END_HEADER
330 #endif /* __AFHINTS_H__ */
333 /* END */