Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
aftypes.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* aftypes.h */
4 /* */
5 /* Auto-fitter types (specification only). */
6 /* */
7 /* Copyright 2003-2009, 2011-2012 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 /***************************************************************************/
17 
18 
19  /*************************************************************************
20  *
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.
24  *
25  * The code has also been compartmentized into several entities that
26  * should make algorithmic experimentation easier than with the old
27  * code.
28  *
29  * Finally, we get rid of the Catharon license, since this code is
30  * released under the FreeType one.
31  *
32  *************************************************************************/
33 
34 
35 #ifndef __AFTYPES_H__
36 #define __AFTYPES_H__
37 
38 #include <ft2build.h>
39 
40 #include FT_FREETYPE_H
41 #include FT_OUTLINE_H
42 #include FT_INTERNAL_OBJECTS_H
43 #include FT_INTERNAL_DEBUG_H
44 
45 
47 
48  /*************************************************************************/
49  /*************************************************************************/
50  /***** *****/
51  /***** D E B U G G I N G *****/
52  /***** *****/
53  /*************************************************************************/
54  /*************************************************************************/
55 
56 #ifdef FT_DEBUG_AUTOFIT
57 
58 #include FT_CONFIG_STANDARD_LIBRARY_H
59 
60 extern int _af_debug_disable_horz_hints;
61 extern int _af_debug_disable_vert_hints;
62 extern int _af_debug_disable_blue_hints;
63 extern void* _af_debug_hints;
64 
65 #endif /* FT_DEBUG_AUTOFIT */
66 
67 
68  /*************************************************************************/
69  /*************************************************************************/
70  /***** *****/
71  /***** U T I L I T Y S T U F F *****/
72  /***** *****/
73  /*************************************************************************/
74  /*************************************************************************/
75 
76  typedef struct AF_WidthRec_
77  {
78  FT_Pos org; /* original position/width in font units */
79  FT_Pos cur; /* current/scaled position/width in device sub-pixels */
80  FT_Pos fit; /* current/fitted position/width in device sub-pixels */
81 
83 
84 
85  FT_LOCAL( void )
87  FT_Pos* table );
88 
89  FT_LOCAL( void )
91  AF_Width widths,
92  FT_Pos threshold );
93 
94 
95  /*************************************************************************/
96  /*************************************************************************/
97  /***** *****/
98  /***** A N G L E T Y P E S *****/
99  /***** *****/
100  /*************************************************************************/
101  /*************************************************************************/
102 
103  /*
104  * The auto-fitter doesn't need a very high angular accuracy;
105  * this allows us to speed up some computations considerably with a
106  * light Cordic algorithm (see afangles.c).
107  */
108 
109  typedef FT_Int AF_Angle;
110 
111 
112 #define AF_ANGLE_PI 256
113 #define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 )
114 #define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 )
115 #define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 )
116 
117 
118 #if 0
119  /*
120  * compute the angle of a given 2-D vector
121  */
122  FT_LOCAL( AF_Angle )
123  af_angle_atan( FT_Pos dx,
124  FT_Pos dy );
125 
126 
127  /*
128  * compute `angle2 - angle1'; the result is always within
129  * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
130  */
131  FT_LOCAL( AF_Angle )
132  af_angle_diff( AF_Angle angle1,
133  AF_Angle angle2 );
134 #endif /* 0 */
135 
136 
137 #define AF_ANGLE_DIFF( result, angle1, angle2 ) \
138  FT_BEGIN_STMNT \
139  AF_Angle _delta = (angle2) - (angle1); \
140  \
141  \
142  _delta %= AF_ANGLE_2PI; \
143  if ( _delta < 0 ) \
144  _delta += AF_ANGLE_2PI; \
145  \
146  if ( _delta > AF_ANGLE_PI ) \
147  _delta -= AF_ANGLE_2PI; \
148  \
149  result = _delta; \
150  FT_END_STMNT
151 
152 
153  /* opaque handle to glyph-specific hints -- see `afhints.h' for more
154  * details
155  */
157 
158 
159  /*************************************************************************/
160  /*************************************************************************/
161  /***** *****/
162  /***** S C A L E R S *****/
163  /***** *****/
164  /*************************************************************************/
165  /*************************************************************************/
166 
167  /*
168  * A scaler models the target pixel device that will receive the
169  * auto-hinted glyph image.
170  */
171 
172  typedef enum AF_ScalerFlags_
173  {
174  AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */
175  AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */
176  AF_SCALER_FLAG_NO_ADVANCE = 4 /* disable advance hinting */
177 
178  } AF_ScalerFlags;
179 
180 
181  typedef struct AF_ScalerRec_
182  {
183  FT_Face face; /* source font face */
184  FT_Fixed x_scale; /* from font units to 1/64th device pixels */
185  FT_Fixed y_scale; /* from font units to 1/64th device pixels */
186  FT_Pos x_delta; /* in 1/64th device pixels */
187  FT_Pos y_delta; /* in 1/64th device pixels */
188  FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
189  FT_UInt32 flags; /* additional control flags, see above */
190 
192 
193 
194 #define AF_SCALER_EQUAL_SCALES( a, b ) \
195  ( (a)->x_scale == (b)->x_scale && \
196  (a)->y_scale == (b)->y_scale && \
197  (a)->x_delta == (b)->x_delta && \
198  (a)->y_delta == (b)->y_delta )
199 
200 
201  /*************************************************************************/
202  /*************************************************************************/
203  /***** *****/
204  /***** S C R I P T S *****/
205  /***** *****/
206  /*************************************************************************/
207  /*************************************************************************/
208 
209  /*
210  * The list of known scripts. Each different script corresponds to the
211  * following information:
212  *
213  * - A set of Unicode ranges to test whether the face supports the
214  * script.
215  *
216  * - A specific global analyzer that will compute global metrics
217  * specific to the script.
218  *
219  * - A specific glyph analyzer that will compute segments and
220  * edges for each glyph covered by the script.
221  *
222  * - A specific grid-fitting algorithm that will distort the
223  * scaled glyph outline according to the results of the glyph
224  * analyzer.
225  *
226  * Note that a given analyzer and/or grid-fitting algorithm can be
227  * used by more than one script.
228  */
229 
230  typedef enum AF_Script_
231  {
236 #ifdef FT_OPTION_AUTOFIT2
237  AF_SCRIPT_LATIN2 = 4,
238 #endif
239 
240  /* add new scripts here. Don't forget to update the list in */
241  /* `afglobal.c'. */
242 
243  AF_SCRIPT_MAX /* do not remove */
244 
245  } AF_Script;
246 
247 
250 
251  typedef struct AF_ScriptMetricsRec_
252  {
253  AF_ScriptClass clazz;
256 
257  AF_FaceGlobals globals; /* to access properties */
258 
260 
261 
262  /* This function parses an FT_Face to compute global metrics for
263  * a specific script.
264  */
265  typedef FT_Error
266  (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
267  FT_Face face );
268 
269  typedef void
270  (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
271  AF_Scaler scaler );
272 
273  typedef void
274  (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
275 
276 
277  typedef FT_Error
278  (*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
279  AF_ScriptMetrics metrics );
280 
281  typedef void
282  (*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
283  FT_Outline* outline,
284  AF_ScriptMetrics metrics );
285 
286 
287  typedef struct AF_Script_UniRangeRec_
288  {
291 
293 
294 #define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
295 
297 
298 
299  typedef struct AF_ScriptClassRec_
300  {
302  AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
303  FT_UInt32 standard_char; /* for default width and height */
304 
309 
312 
314 
315 
316  /* Declare and define vtables for classes */
317 #ifndef FT_CONFIG_OPTION_PIC
318 
319 #define AF_DECLARE_SCRIPT_CLASS( script_class ) \
320  FT_CALLBACK_TABLE const AF_ScriptClassRec \
321  script_class;
322 
323 #define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, def_char, \
324  m_size, \
325  m_init, m_scale, m_done, h_init, h_apply ) \
326  FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec script_class = \
327  { \
328  script_, \
329  ranges, \
330  def_char, \
331  \
332  m_size, \
333  \
334  m_init, \
335  m_scale, \
336  m_done, \
337  \
338  h_init, \
339  h_apply \
340  };
341 
342 #else /* FT_CONFIG_OPTION_PIC */
343 
344 #define AF_DECLARE_SCRIPT_CLASS( script_class ) \
345  FT_LOCAL( void ) \
346  FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac );
347 
348 #define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, def_char, \
349  m_size, \
350  m_init, m_scale, m_done, h_init, h_apply ) \
351  FT_LOCAL_DEF( void ) \
352  FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
353  { \
354  ac->script = script_; \
355  ac->script_uni_ranges = ranges; \
356  ac->default_char = def_char; \
357  \
358  ac->script_metrics_size = m_size; \
359  \
360  ac->script_metrics_init = m_init; \
361  ac->script_metrics_scale = m_scale; \
362  ac->script_metrics_done = m_done; \
363  \
364  ac->script_hints_init = h_init; \
365  ac->script_hints_apply = h_apply; \
366  }
367 
368 #endif /* FT_CONFIG_OPTION_PIC */
369 
370 
371 /* */
372 
374 
375 #endif /* __AFTYPES_H__ */
376 
377 
378 /* END */
enum AF_Script_ AF_Script
int FT_Error
Definition: fttypes.h:296
af_sort_and_quantize_widths(FT_UInt *count, AF_Width widths, FT_Pos threshold)
Definition: afangles.c:270
angle2
Definition: cordic.py:18
struct AF_ScriptMetricsRec_ AF_ScriptMetricsRec
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
FT_Bool digits_have_same_width
Definition: aftypes.h:255
AF_Script_ScaleMetricsFunc script_metrics_scale
Definition: aftypes.h:307
#define FT_END_HEADER
Definition: ftheader.h:54
struct AF_GlyphHintsRec_ * AF_GlyphHints
Definition: aftypes.h:156
AF_Script_InitMetricsFunc script_metrics_init
Definition: aftypes.h:306
signed int FT_Int
Definition: fttypes.h:216
FT_Pos y_delta
Definition: aftypes.h:187
enum FT_Render_Mode_ FT_Render_Mode
void(* AF_Script_DoneMetricsFunc)(AF_ScriptMetrics metrics)
Definition: aftypes.h:274
FT_Pos x_delta
Definition: aftypes.h:186
unsigned int FT_UInt32
Definition: ftconfig.h:133
FT_UInt32 flags
Definition: aftypes.h:189
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
FT_Pos cur
Definition: aftypes.h:79
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
FT_Error(* AF_Script_InitHintsFunc)(AF_GlyphHints hints, AF_ScriptMetrics metrics)
Definition: aftypes.h:278
FT_Pos org
Definition: aftypes.h:78
FT_Offset script_metrics_size
Definition: aftypes.h:305
GLenum GLuint GLint GLenum face
#define const
Definition: zconf.h:91
AF_Script script
Definition: aftypes.h:301
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
struct AF_ScriptMetricsRec_ * AF_ScriptMetrics
const AF_Script_UniRangeRec * AF_Script_UniRange
Definition: aftypes.h:296
struct AF_Script_UniRangeRec_ AF_Script_UniRangeRec
struct AF_ScriptClassRec_ const * AF_ScriptClass
Definition: aftypes.h:248
AF_ScalerRec scaler
Definition: aftypes.h:254
FT_Face face
Definition: aftypes.h:183
FT_Fixed x_scale
Definition: aftypes.h:184
AF_FaceGlobals globals
Definition: aftypes.h:257
#define FT_LOCAL(x)
Definition: ftconfig.h:235
AF_Script_InitHintsFunc script_hints_init
Definition: aftypes.h:310
AF_Script_UniRange script_uni_ranges
Definition: aftypes.h:302
void(* AF_Script_ApplyHintsFunc)(AF_GlyphHints hints, FT_Outline *outline, AF_ScriptMetrics metrics)
Definition: aftypes.h:282
AF_Script_DoneMetricsFunc script_metrics_done
Definition: aftypes.h:308
FT_Fixed y_scale
Definition: aftypes.h:185
FT_Int AF_Angle
Definition: aftypes.h:109
af_sort_pos(FT_UInt count, FT_Pos *table)
Definition: afangles.c:247
enum AF_ScalerFlags_ AF_ScalerFlags
FT_Pos fit
Definition: aftypes.h:80
struct AF_ScalerRec_ * AF_Scaler
AF_Script_
Definition: aftypes.h:230
signed long FT_Fixed
Definition: fttypes.h:284
struct AF_ScalerRec_ AF_ScalerRec
FT_BEGIN_HEADER struct AF_WidthRec_ * AF_Width
struct AF_FaceGlobalsRec_ * AF_FaceGlobals
Definition: aftypes.h:249
unsigned int FT_UInt
Definition: fttypes.h:227
AF_Script_ApplyHintsFunc script_hints_apply
Definition: aftypes.h:311
struct AF_ScriptClassRec_ AF_ScriptClassRec
FT_Error(* AF_Script_InitMetricsFunc)(AF_ScriptMetrics metrics, FT_Face face)
Definition: aftypes.h:266
FT_BEGIN_HEADER struct AF_WidthRec_ AF_WidthRec
AF_ScriptClass clazz
Definition: aftypes.h:253
GLuint GLuint GLsizei count
FT_UInt32 standard_char
Definition: aftypes.h:303
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
FT_Render_Mode render_mode
Definition: aftypes.h:188
AF_ScalerFlags_
Definition: aftypes.h:172
void(* AF_Script_ScaleMetricsFunc)(AF_ScriptMetrics metrics, AF_Scaler scaler)
Definition: aftypes.h:270
GLenum GLsizei GLenum GLenum const GLvoid * table
size_t FT_Offset
Definition: fttypes.h:320