mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / autofit / aftypes.h
blob5574f0c302b3a60548a835e396e156970ac782e3
1 /***************************************************************************/
2 /* */
3 /* aftypes.h */
4 /* */
5 /* Auto-fitter types (specification only). */
6 /* */
7 /* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 FT_CONFIG_STANDARD_LIBRARY_H
63 #define AF_LOG( x ) do { if ( _af_debug ) printf x; } while ( 0 )
65 extern int _af_debug;
66 extern int _af_debug_disable_horz_hints;
67 extern int _af_debug_disable_vert_hints;
68 extern int _af_debug_disable_blue_hints;
69 extern void* _af_debug_hints;
71 #else /* !AF_DEBUG */
73 #define AF_LOG( x ) do { } while ( 0 ) /* nothing */
75 #endif /* !AF_DEBUG */
78 /*************************************************************************/
79 /*************************************************************************/
80 /***** *****/
81 /***** U T I L I T Y S T U F F *****/
82 /***** *****/
83 /*************************************************************************/
84 /*************************************************************************/
86 typedef struct AF_WidthRec_
88 FT_Pos org; /* original position/width in font units */
89 FT_Pos cur; /* current/scaled position/width in device sub-pixels */
90 FT_Pos fit; /* current/fitted position/width in device sub-pixels */
92 } AF_WidthRec, *AF_Width;
95 FT_LOCAL( void )
96 af_sort_pos( FT_UInt count,
97 FT_Pos* table );
99 FT_LOCAL( void )
100 af_sort_widths( FT_UInt count,
101 AF_Width widths );
104 /*************************************************************************/
105 /*************************************************************************/
106 /***** *****/
107 /***** A N G L E T Y P E S *****/
108 /***** *****/
109 /*************************************************************************/
110 /*************************************************************************/
113 * The auto-fitter doesn't need a very high angular accuracy;
114 * this allows us to speed up some computations considerably with a
115 * light Cordic algorithm (see afangles.c).
118 typedef FT_Int AF_Angle;
121 #define AF_ANGLE_PI 256
122 #define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 )
123 #define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 )
124 #define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 )
127 #if 0
129 * compute the angle of a given 2-D vector
131 FT_LOCAL( AF_Angle )
132 af_angle_atan( FT_Pos dx,
133 FT_Pos dy );
137 * compute `angle2 - angle1'; the result is always within
138 * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
140 FT_LOCAL( AF_Angle )
141 af_angle_diff( AF_Angle angle1,
142 AF_Angle angle2 );
143 #endif /* 0 */
146 #define AF_ANGLE_DIFF( result, angle1, angle2 ) \
147 FT_BEGIN_STMNT \
148 AF_Angle _delta = (angle2) - (angle1); \
151 _delta %= AF_ANGLE_2PI; \
152 if ( _delta < 0 ) \
153 _delta += AF_ANGLE_2PI; \
155 if ( _delta > AF_ANGLE_PI ) \
156 _delta -= AF_ANGLE_2PI; \
158 result = _delta; \
159 FT_END_STMNT
162 /*************************************************************************/
163 /*************************************************************************/
164 /***** *****/
165 /***** O U T L I N E S *****/
166 /***** *****/
167 /*************************************************************************/
168 /*************************************************************************/
170 /* opaque handle to glyph-specific hints -- see `afhints.h' for more
171 * details
173 typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
175 /* This structure is used to model an input glyph outline to
176 * the auto-hinter. The latter will set the `hints' field
177 * depending on the glyph's script.
179 typedef struct AF_OutlineRec_
181 FT_Face face;
182 FT_Outline outline;
183 FT_UInt outline_resolution;
185 FT_Int advance;
186 FT_UInt metrics_resolution;
188 AF_GlyphHints hints;
190 } AF_OutlineRec;
193 /*************************************************************************/
194 /*************************************************************************/
195 /***** *****/
196 /***** S C A L E R S *****/
197 /***** *****/
198 /*************************************************************************/
199 /*************************************************************************/
202 * A scaler models the target pixel device that will receive the
203 * auto-hinted glyph image.
206 typedef enum AF_ScalerFlags_
208 AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */
209 AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */
210 AF_SCALER_FLAG_NO_ADVANCE = 4 /* disable advance hinting */
212 } AF_ScalerFlags;
215 typedef struct AF_ScalerRec_
217 FT_Face face; /* source font face */
218 FT_Fixed x_scale; /* from font units to 1/64th device pixels */
219 FT_Fixed y_scale; /* from font units to 1/64th device pixels */
220 FT_Pos x_delta; /* in 1/64th device pixels */
221 FT_Pos y_delta; /* in 1/64th device pixels */
222 FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
223 FT_UInt32 flags; /* additional control flags, see above */
225 } AF_ScalerRec, *AF_Scaler;
228 #define AF_SCALER_EQUAL_SCALES( a, b ) \
229 ( (a)->x_scale == (b)->x_scale && \
230 (a)->y_scale == (b)->y_scale && \
231 (a)->x_delta == (b)->x_delta && \
232 (a)->y_delta == (b)->y_delta )
235 /*************************************************************************/
236 /*************************************************************************/
237 /***** *****/
238 /***** S C R I P T S *****/
239 /***** *****/
240 /*************************************************************************/
241 /*************************************************************************/
244 * The list of know scripts. Each different script corresponds to the
245 * following information:
247 * - A set of Unicode ranges to test whether the face supports the
248 * script.
250 * - A specific global analyzer that will compute global metrics
251 * specific to the script.
253 * - A specific glyph analyzer that will compute segments and
254 * edges for each glyph covered by the script.
256 * - A specific grid-fitting algorithm that will distort the
257 * scaled glyph outline according to the results of the glyph
258 * analyzer.
260 * Note that a given analyzer and/or grid-fitting algorithm can be
261 * used by more than one script.
264 typedef enum AF_Script_
266 AF_SCRIPT_NONE = 0,
267 AF_SCRIPT_LATIN = 1,
268 AF_SCRIPT_CJK = 2,
269 AF_SCRIPT_INDIC = 3,
270 #ifdef FT_OPTION_AUTOFIT2
271 AF_SCRIPT_LATIN2,
272 #endif
274 /* add new scripts here. Don't forget to update the list in */
275 /* `afglobal.c'. */
277 AF_SCRIPT_MAX /* do not remove */
279 } AF_Script;
282 typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
284 typedef struct AF_ScriptMetricsRec_
286 AF_ScriptClass clazz;
287 AF_ScalerRec scaler;
288 FT_Bool digits_have_same_width;
290 } AF_ScriptMetricsRec, *AF_ScriptMetrics;
293 /* This function parses an FT_Face to compute global metrics for
294 * a specific script.
296 typedef FT_Error
297 (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
298 FT_Face face );
300 typedef void
301 (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
302 AF_Scaler scaler );
304 typedef void
305 (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
308 typedef FT_Error
309 (*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
310 AF_ScriptMetrics metrics );
312 typedef void
313 (*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
314 FT_Outline* outline,
315 AF_ScriptMetrics metrics );
318 typedef struct AF_Script_UniRangeRec_
320 FT_UInt32 first;
321 FT_UInt32 last;
323 } AF_Script_UniRangeRec;
325 #define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
327 typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
330 typedef struct AF_ScriptClassRec_
332 AF_Script script;
333 AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
335 FT_Offset script_metrics_size;
336 AF_Script_InitMetricsFunc script_metrics_init;
337 AF_Script_ScaleMetricsFunc script_metrics_scale;
338 AF_Script_DoneMetricsFunc script_metrics_done;
340 AF_Script_InitHintsFunc script_hints_init;
341 AF_Script_ApplyHintsFunc script_hints_apply;
343 } AF_ScriptClassRec;
345 /* Declare and define vtables for classes */
346 #ifndef FT_CONFIG_OPTION_PIC
348 #define AF_DECLARE_SCRIPT_CLASS(script_class) \
349 FT_CALLBACK_TABLE const AF_ScriptClassRec \
350 script_class;
352 #define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
353 m_init, m_scale, m_done, h_init, h_apply) \
354 FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec \
355 script_class = \
357 script_, \
358 ranges, \
360 m_size, \
362 m_init, \
363 m_scale, \
364 m_done, \
366 h_init, \
367 h_apply \
370 #else
372 #define AF_DECLARE_SCRIPT_CLASS(script_class) \
373 FT_LOCAL(void) \
374 FT_Init_Class_##script_class(AF_ScriptClassRec* ac);
376 #define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
377 m_init, m_scale, m_done, h_init, h_apply) \
378 FT_LOCAL_DEF(void) \
379 FT_Init_Class_##script_class(AF_ScriptClassRec* ac) \
381 ac->script = script_; \
382 ac->script_uni_ranges = ranges; \
384 ac->script_metrics_size = m_size; \
386 ac->script_metrics_init = m_init; \
387 ac->script_metrics_scale = m_scale; \
388 ac->script_metrics_done = m_done; \
390 ac->script_hints_init = h_init; \
391 ac->script_hints_apply = h_apply; \
393 #endif
396 /* */
398 FT_END_HEADER
400 #endif /* __AFTYPES_H__ */
403 /* END */