Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / freetype2 / src / autofit / aftypes.h
blob56811f0e42f6ab3875e8bb3cbc6b5ca04ed8f070
1 /***************************************************************************/
2 /* */
3 /* aftypes.h */
4 /* */
5 /* Auto-fitter types (specification only). */
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 /*************************************************************************
21 * The auto-fitter is a complete rewrite of the old auto-hinter.
22 * Its main feature is the ability to differentiate between different
23 * scripts in order to apply language-specific rules.
25 * The code has also been compartmentized into several entities that
26 * should make algorithmic experimentation easier than with the old
27 * code.
29 * Finally, we get rid of the Catharon license, since this code is
30 * released under the FreeType one.
32 *************************************************************************/
35 #ifndef __AFTYPES_H__
36 #define __AFTYPES_H__
38 #include <ft2build.h>
40 #include FT_FREETYPE_H
41 #include FT_OUTLINE_H
42 #include FT_INTERNAL_OBJECTS_H
43 #include FT_INTERNAL_DEBUG_H
46 FT_BEGIN_HEADER
48 /*************************************************************************/
49 /*************************************************************************/
50 /***** *****/
51 /***** D E B U G G I N G *****/
52 /***** *****/
53 /*************************************************************************/
54 /*************************************************************************/
56 #define xxAF_USE_WARPER /* only define to use warp hinting */
57 #define xxAF_DEBUG
59 #ifdef AF_DEBUG
61 #include <stdio.h>
62 #define AF_LOG( x ) do { if ( _af_debug ) printf x; } while ( 0 )
64 extern int _af_debug;
65 extern int _af_debug_disable_horz_hints;
66 extern int _af_debug_disable_vert_hints;
67 extern int _af_debug_disable_blue_hints;
68 extern void* _af_debug_hints;
70 #else /* !AF_DEBUG */
72 #define AF_LOG( x ) do ; while ( 0 ) /* nothing */
74 #endif /* !AF_DEBUG */
77 /*************************************************************************/
78 /*************************************************************************/
79 /***** *****/
80 /***** U T I L I T Y S T U F F *****/
81 /***** *****/
82 /*************************************************************************/
83 /*************************************************************************/
85 typedef struct AF_WidthRec_
87 FT_Pos org; /* original position/width in font units */
88 FT_Pos cur; /* current/scaled position/width in device sub-pixels */
89 FT_Pos fit; /* current/fitted position/width in device sub-pixels */
91 } AF_WidthRec, *AF_Width;
94 FT_LOCAL( void )
95 af_sort_pos( FT_UInt count,
96 FT_Pos* table );
98 FT_LOCAL( void )
99 af_sort_widths( FT_UInt count,
100 AF_Width widths );
103 /*************************************************************************/
104 /*************************************************************************/
105 /***** *****/
106 /***** A N G L E T Y P E S *****/
107 /***** *****/
108 /*************************************************************************/
109 /*************************************************************************/
112 * The auto-fitter doesn't need a very high angular accuracy;
113 * this allows us to speed up some computations considerably with a
114 * light Cordic algorithm (see afangles.c).
117 typedef FT_Int AF_Angle;
120 #define AF_ANGLE_PI 256
121 #define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 )
122 #define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 )
123 #define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 )
126 #if 0
128 * compute the angle of a given 2-D vector
130 FT_LOCAL( AF_Angle )
131 af_angle_atan( FT_Pos dx,
132 FT_Pos dy );
136 * compute `angle2 - angle1'; the result is always within
137 * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
139 FT_LOCAL( AF_Angle )
140 af_angle_diff( AF_Angle angle1,
141 AF_Angle angle2 );
142 #endif /* 0 */
145 #define AF_ANGLE_DIFF( result, angle1, angle2 ) \
146 FT_BEGIN_STMNT \
147 AF_Angle _delta = (angle2) - (angle1); \
150 _delta %= AF_ANGLE_2PI; \
151 if ( _delta < 0 ) \
152 _delta += AF_ANGLE_2PI; \
154 if ( _delta > AF_ANGLE_PI ) \
155 _delta -= AF_ANGLE_2PI; \
157 result = _delta; \
158 FT_END_STMNT
161 /*************************************************************************/
162 /*************************************************************************/
163 /***** *****/
164 /***** O U T L I N E S *****/
165 /***** *****/
166 /*************************************************************************/
167 /*************************************************************************/
169 /* opaque handle to glyph-specific hints -- see `afhints.h' for more
170 * details
172 typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
174 /* This structure is used to model an input glyph outline to
175 * the auto-hinter. The latter will set the `hints' field
176 * depending on the glyph's script.
178 typedef struct AF_OutlineRec_
180 FT_Face face;
181 FT_Outline outline;
182 FT_UInt outline_resolution;
184 FT_Int advance;
185 FT_UInt metrics_resolution;
187 AF_GlyphHints hints;
189 } AF_OutlineRec;
192 /*************************************************************************/
193 /*************************************************************************/
194 /***** *****/
195 /***** S C A L E R S *****/
196 /***** *****/
197 /*************************************************************************/
198 /*************************************************************************/
201 * A scaler models the target pixel device that will receive the
202 * auto-hinted glyph image.
205 typedef enum AF_ScalerFlags_
207 AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */
208 AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */
209 AF_SCALER_FLAG_NO_ADVANCE = 4 /* disable advance hinting */
211 } AF_ScalerFlags;
214 typedef struct AF_ScalerRec_
216 FT_Face face; /* source font face */
217 FT_Fixed x_scale; /* from font units to 1/64th device pixels */
218 FT_Fixed y_scale; /* from font units to 1/64th device pixels */
219 FT_Pos x_delta; /* in 1/64th device pixels */
220 FT_Pos y_delta; /* in 1/64th device pixels */
221 FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
222 FT_UInt32 flags; /* additional control flags, see above */
224 } AF_ScalerRec, *AF_Scaler;
227 #define AF_SCALER_EQUAL_SCALES( a, b ) \
228 ( (a)->x_scale == (b)->x_scale && \
229 (a)->y_scale == (b)->y_scale && \
230 (a)->x_delta == (b)->x_delta && \
231 (a)->y_delta == (b)->y_delta )
234 /*************************************************************************/
235 /*************************************************************************/
236 /***** *****/
237 /***** S C R I P T S *****/
238 /***** *****/
239 /*************************************************************************/
240 /*************************************************************************/
243 * The list of know scripts. Each different script corresponds to the
244 * following information:
246 * - A set of Unicode ranges to test whether the face supports the
247 * script.
249 * - A specific global analyzer that will compute global metrics
250 * specific to the script.
252 * - A specific glyph analyzer that will compute segments and
253 * edges for each glyph covered by the script.
255 * - A specific grid-fitting algorithm that will distort the
256 * scaled glyph outline according to the results of the glyph
257 * analyzer.
259 * Note that a given analyzer and/or grid-fitting algorithm can be
260 * used by more than one script.
263 typedef enum AF_Script_
265 AF_SCRIPT_NONE = 0,
266 AF_SCRIPT_LATIN = 1,
267 AF_SCRIPT_CJK = 2,
268 AF_SCRIPT_INDIC = 3,
269 #ifdef FT_OPTION_AUTOFIT2
270 AF_SCRIPT_LATIN2,
271 #endif
273 /* add new scripts here. Don't forget to update the list in */
274 /* `afglobal.c'. */
276 AF_SCRIPT_MAX /* do not remove */
278 } AF_Script;
281 typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
283 typedef struct AF_ScriptMetricsRec_
285 AF_ScriptClass clazz;
286 AF_ScalerRec scaler;
288 } AF_ScriptMetricsRec, *AF_ScriptMetrics;
291 /* This function parses an FT_Face to compute global metrics for
292 * a specific script.
294 typedef FT_Error
295 (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
296 FT_Face face );
298 typedef void
299 (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
300 AF_Scaler scaler );
302 typedef void
303 (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
306 typedef FT_Error
307 (*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
308 AF_ScriptMetrics metrics );
310 typedef void
311 (*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
312 FT_Outline* outline,
313 AF_ScriptMetrics metrics );
316 typedef struct AF_Script_UniRangeRec_
318 FT_UInt32 first;
319 FT_UInt32 last;
321 } AF_Script_UniRangeRec;
323 typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
326 typedef struct AF_ScriptClassRec_
328 AF_Script script;
329 AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
331 FT_UInt script_metrics_size;
332 AF_Script_InitMetricsFunc script_metrics_init;
333 AF_Script_ScaleMetricsFunc script_metrics_scale;
334 AF_Script_DoneMetricsFunc script_metrics_done;
336 AF_Script_InitHintsFunc script_hints_init;
337 AF_Script_ApplyHintsFunc script_hints_apply;
339 } AF_ScriptClassRec;
342 /* */
344 FT_END_HEADER
346 #endif /* __AFTYPES_H__ */
349 /* END */