/[freetype]/freetype2/src/autofit/aftypes.h
ViewVC logotype

Diff of /freetype2/src/autofit/aftypes.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by davidT, Fri Jun 4 17:41:59 2004 UTC revision 1.12 by wl, Thu Mar 3 17:09:07 2005 UTC
# Line 1  Line 1 
1    /***************************************************************************/
2    /*                                                                         */
3    /*  aftypes.h                                                              */
4    /*                                                                         */
5    /*    Auto-fitter types (specification only).                              */
6    /*                                                                         */
7    /*  Copyright 2003, 2004, 2005 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   *   *
  *  FreeType auto-fitter  
  *  
  *  (c) 2004 David Turner  
  *  
21   *  The auto-fitter is a complete rewrite of the old auto-hinter.   *  The auto-fitter is a complete rewrite of the old auto-hinter.
22   *  its main feature is the ability to differentiate between different   *  Its main feature is the ability to differentiate between different
23   *  scripts in order to apply language-specific rules.   *  scripts in order to apply language-specific rules.
24   *   *
25   *  the code has also been compartimentized into several entities that   *  The code has also been compartimentized into several entities that
26   *  should make algorithmic experimentation easier than with the old   *  should make algorithmic experimentation easier than with the old
27   *  code.   *  code.
28   *   *
29   *  finally, we get rid of the Catharon license, since this code is   *  Finally, we get rid of the Catharon license, since this code is
30   *  released under the FreeType one.   *  released under the FreeType one.
31   */   *
32     ***************************************************************************/
33    
34    
35  #ifndef __AFTYPES_H__  #ifndef __AFTYPES_H__
36  #define __AFTYPES_H__  #define __AFTYPES_H__
37    
38  #include <ft2build.h>  #include <ft2build.h>
39    
40  #include FT_FREETYPE_H  #include FT_FREETYPE_H
41  #include FT_OUTLINE_H  #include FT_OUTLINE_H
42  #include FT_INTERNAL_OBJECTS_H  #include FT_INTERNAL_OBJECTS_H
43  #include FT_INTERNAL_DEBUG_H  #include FT_INTERNAL_DEBUG_H
44    
45    
46  FT_BEGIN_HEADER  FT_BEGIN_HEADER
47    
48   /**************************************************************************/    /*************************************************************************/
49   /**************************************************************************/    /*************************************************************************/
50   /*****                                                                *****/    /*****                                                               *****/
51   /*****                D E B U G G I N G                               *****/    /*****                    D E B U G G I N G                          *****/
52   /*****                                                                *****/    /*****                                                               *****/
53   /**************************************************************************/    /*************************************************************************/
54   /**************************************************************************/    /*************************************************************************/
55    
56  #define xxAF_DEBUG  #define xxAF_DEBUG
57    
58  #ifdef AF_DEBUG  #ifdef AF_DEBUG
59    
60  #  include <stdio.h>  #include <stdio.h>
61  #  define AF_LOG( x )  printf x  
62    #define AF_LOG( x )  printf x
63    
64  #else  #else
65    
66  #  define AF_LOG( x )  do ; while ( 0 ) /* nothing */  #define AF_LOG( x )  do ; while ( 0 )        /* nothing */
67    
68  #endif /* AF_DEBUG */  #endif /* AF_DEBUG */
69    
  /**************************************************************************/  
  /**************************************************************************/  
  /*****                                                                *****/  
  /*****                U T I L I T Y                                   *****/  
  /*****                                                                *****/  
  /**************************************************************************/  
  /**************************************************************************/  
70    
71    typedef struct AF_WidthRec_    /*************************************************************************/
72      /*************************************************************************/
73      /*****                                                               *****/
74      /*****                 U T I L I T Y   S T U F F                     *****/
75      /*****                                                               *****/
76      /*************************************************************************/
77      /*************************************************************************/
78    
79      typedef struct  AF_WidthRec_
80    {    {
81      FT_Pos  org;  /* original position/width in font units              */      FT_Pos  org;  /* original position/width in font units              */
82      FT_Pos  cur;  /* current/scaled position/width in device sub-pixels */      FT_Pos  cur;  /* current/scaled position/width in device sub-pixels */
# Line 65  FT_BEGIN_HEADER Line 86  FT_BEGIN_HEADER
86    
87    
88    FT_LOCAL( void )    FT_LOCAL( void )
89    af_sort_pos( FT_UInt   count,    af_sort_pos( FT_UInt  count,
90                 FT_Pos*   table );                 FT_Pos*  table );
91    
92    FT_LOCAL( void )    FT_LOCAL( void )
93    af_sort_widths( FT_UInt   count,    af_sort_widths( FT_UInt   count,
94                    AF_Width  widths );                    AF_Width  widths );
95    
96    
97   /**************************************************************************/    /*************************************************************************/
98   /**************************************************************************/    /*************************************************************************/
99   /*****                                                                *****/    /*****                                                               *****/
100   /*****                A N G L E   T Y P E S                           *****/    /*****                   A N G L E   T Y P E S                       *****/
101   /*****                                                                *****/    /*****                                                               *****/
102   /**************************************************************************/    /*************************************************************************/
103   /**************************************************************************/    /*************************************************************************/
104    
105   /*    /*
106    *  Angle type. The auto-fitter doesn't need a very high angular accuracy,     *  The auto-fitter doesn't need a very high angular accuracy;
107    *  and this allows us to speed up some computations considerably with a     *  this allows us to speed up some computations considerably with a
108    *  light Cordic algorithm (see afangles.c)     *  light Cordic algorithm (see afangles.c).
109    *     */
110    */  
111      typedef FT_Int  AF_Angle;
112    typedef FT_Int    AF_Angle;  
113    
114  #define  AF_ANGLE_PI     256  #define AF_ANGLE_PI   256
115  #define  AF_ANGLE_2PI    (AF_ANGLE_PI*2)  #define AF_ANGLE_2PI  ( AF_ANGLE_PI * 2 )
116  #define  AF_ANGLE_PI2    (AF_ANGLE_PI/2)  #define AF_ANGLE_PI2  ( AF_ANGLE_PI / 2 )
117  #define  AF_ANGLE_PI4    (AF_ANGLE_PI/4)  #define AF_ANGLE_PI4  ( AF_ANGLE_PI / 4 )
118    
119   /*  
120    *  compute the angle of a given 2-D vector    /*
121    *     *  compute the angle of a given 2-D vector
122    */     */
123    FT_LOCAL( AF_Angle )    FT_LOCAL( AF_Angle )
124    af_angle_atan( FT_Pos  dx,    af_angle_atan( FT_Pos  dx,
125                   FT_Pos  dy );                   FT_Pos  dy );
126    
127    
128   /*    /*
129    *  computes "angle2 - angle1", the result is always within     *  compute `angle2 - angle1'; the result is always within
130    *  the range [ -AF_ANGLE_PI .. AF_ANGLE_PI-1 ]     *  the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
131    *     */
   */  
132    FT_LOCAL( AF_Angle )    FT_LOCAL( AF_Angle )
133    af_angle_diff( AF_Angle  angle1,    af_angle_diff( AF_Angle  angle1,
134                   AF_Angle  angle2 );                   AF_Angle  angle2 );
135    
136    
137   /**************************************************************************/    /*************************************************************************/
138   /**************************************************************************/    /*************************************************************************/
139   /*****                                                                *****/    /*****                                                               *****/
140   /*****                O U T L I N E S                                 *****/    /*****                    O U T L I N E S                            *****/
141   /*****                                                                *****/    /*****                                                               *****/
142   /**************************************************************************/    /*************************************************************************/
143   /**************************************************************************/    /*************************************************************************/
144    
145   /* opaque handle to glyph-specific hints. see "afhints.h" for more    /*  opaque handle to glyph-specific hints -- see `afhints.h' for more
146    * details     *  details
147    */     */
148    typedef struct AF_GlyphHintsRec_*     AF_GlyphHints;    typedef struct AF_GlyphHintsRec_*  AF_GlyphHints;
149    
150   /* this structure is used to model an input glyph outline to    /*  This structure is used to model an input glyph outline to
151    * the auto-hinter. The latter will set the "hints" field     *  the auto-hinter.  The latter will set the `hints' field
152    * depending on the glyph's script     *  depending on the glyph's script.
153    */     */
154    typedef struct AF_OutlineRec_    typedef struct  AF_OutlineRec_
155    {    {
156      FT_Face          face;      FT_Face        face;
157      FT_Outline       outline;      FT_Outline     outline;
158      FT_UInt          outline_resolution;      FT_UInt        outline_resolution;
159    
160      FT_Int           advance;      FT_Int         advance;
161      FT_UInt          metrics_resolution;      FT_UInt        metrics_resolution;
162    
163      AF_GlyphHints    hints;      AF_GlyphHints  hints;
164    
165    } AF_OutlineRec;    } AF_OutlineRec;
166    
167    
168   /**************************************************************************/    /*************************************************************************/
169   /**************************************************************************/    /*************************************************************************/
170   /*****                                                                *****/    /*****                                                               *****/
171   /*****                S C A L E R S                                   *****/    /*****                       S C A L E R S                           *****/
172   /*****                                                                *****/    /*****                                                               *****/
173   /**************************************************************************/    /*************************************************************************/
174   /**************************************************************************/    /*************************************************************************/
175    
176   /*    /*
177    *  A scaler models the target pixel device that will receive the     *  A scaler models the target pixel device that will receive the
178    *  auto-hinted glyph image     *  auto-hinted glyph image.
179    *     */
   */  
180    
181    typedef enum    typedef enum
182    {    {
# Line 168  FT_BEGIN_HEADER Line 187  FT_BEGIN_HEADER
187    } AF_ScalerFlags;    } AF_ScalerFlags;
188    
189    
190    typedef struct AF_ScalerRec_    typedef struct  AF_ScalerRec_
191    {    {
192      FT_Face         face;         /* source font face                        */      FT_Face         face;        /* source font face                        */
193      FT_Fixed        x_scale;      /* from font units to 1/64th device pixels */      FT_Fixed        x_scale;     /* from font units to 1/64th device pixels */
194      FT_Fixed        y_scale;      /* from font units to 1/64th device pixels */      FT_Fixed        y_scale;     /* from font units to 1/64th device pixels */
195      FT_Pos          x_delta;      /* in 1/64th device pixels                 */      FT_Pos          x_delta;     /* in 1/64th device pixels                 */
196      FT_Pos          y_delta;      /* in 1/64th device pixels                 */      FT_Pos          y_delta;     /* in 1/64th device pixels                 */
197      FT_Render_Mode  render_mode;  /* monochrome, anti-aliased, LCD, etc..    */      FT_Render_Mode  render_mode; /* monochrome, anti-aliased, LCD, etc.     */
198      FT_UInt32       flags;        /* additionnal control flags, see above    */      FT_UInt32       flags;       /* additional control flags, see above     */
199    
200    } AF_ScalerRec, *AF_Scaler;    } AF_ScalerRec, *AF_Scaler;
201    
202    
203  #define  AF_SCALER_EQUAL_SCALES(a,b)    \  #define AF_SCALER_EQUAL_SCALES( a, b )      \
204     ( (a)->x_scale == (b)->x_scale &&    \            ( (a)->x_scale == (b)->x_scale && \
205       (a)->y_scale == (b)->y_scale &&    \              (a)->y_scale == (b)->y_scale && \
206       (a)->x_delta == (b)->x_delta &&    \              (a)->x_delta == (b)->x_delta && \
207       (a)->y_delta == (b)->y_delta )              (a)->y_delta == (b)->y_delta )
208    
209    
210   /**************************************************************************/    /*************************************************************************/
211   /**************************************************************************/    /*************************************************************************/
212   /*****                                                                *****/    /*****                                                               *****/
213   /*****                S C R I P T S                                   *****/    /*****                       S C R I P T S                           *****/
214   /*****                                                                *****/    /*****                                                               *****/
215   /**************************************************************************/    /*************************************************************************/
216   /**************************************************************************/    /*************************************************************************/
217    
218   /*    /*
219    *  the list of know scripts. Each different script correspond to the     *  The list of know scripts.  Each different script corresponds to the
220    *  following information:     *  following information:
221    *     *
222    *   - a set of Unicode ranges to test weither the face supports the     *   - A set of Unicode ranges to test whether the face supports the
223    *     script     *     script.
224    *     *
225    *   - a specific global analyzer that will compute global metrics     *   - A specific global analyzer that will compute global metrics
226    *     specific to the script.     *     specific to the script.
227    *     *
228    *   - a specific glyph analyzer that will compute segments and     *   - A specific glyph analyzer that will compute segments and
229    *     edges for each glyph covered by the script     *     edges for each glyph covered by the script.
230    *     *
231    *   - a specific grid-fitting algorithm that will distort the     *   - A specific grid-fitting algorithm that will distort the
232    *     scaled glyph outline according to the results of the glyph     *     scaled glyph outline according to the results of the glyph
233    *     analyzer     *     analyzer.
234    *     *
235    *  note that a given analyzer and/or grid-fitting algorithm can be     *  Note that a given analyzer and/or grid-fitting algorithm can be
236    *  used by more than one script     *  used by more than one script.
237    */     */
238    
239    typedef enum    typedef enum
240    {    {
241      AF_SCRIPT_NONE  = 0,      AF_SCRIPT_NONE  = 0,
242      AF_SCRIPT_LATIN = 1,      AF_SCRIPT_LATIN = 1,
243      /* add new scripts here. don't forget to update the list in "afglobal.c" */      /* add new scripts here.  Don't forget to update the list in */
244        /* `afglobal.c'.                                             */
245    
246      AF_SCRIPT_MAX   /* do not remove */      AF_SCRIPT_MAX   /* do not remove */
247    
248    } AF_Script;    } AF_Script;
249    
250    
   
251    typedef struct AF_ScriptClassRec_ const*  AF_ScriptClass;    typedef struct AF_ScriptClassRec_ const*  AF_ScriptClass;
252    
253    typedef struct AF_ScriptMetricsRec_    typedef struct  AF_ScriptMetricsRec_
254    {    {
255      AF_ScriptClass    clazz;      AF_ScriptClass  clazz;
256      AF_ScalerRec      scaler;      AF_ScalerRec    scaler;
257    
258    } AF_ScriptMetricsRec, *AF_ScriptMetrics;    } AF_ScriptMetricsRec, *AF_ScriptMetrics;
259    
260    
261   /* this function parses a FT_Face to compute global metrics for    /*  This function parses an FT_Face to compute global metrics for
262    * a specific script     *  a specific script.
263    */     */
264    typedef FT_Error  (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics   metrics,    typedef FT_Error
265                                                    FT_Face            face );    (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics  metrics,
266                                    FT_Face           face );
267    
268    typedef void      (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics  metrics,    typedef void
269                                                     AF_Scaler         scaler );    (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics  metrics,
270                                     AF_Scaler         scaler );
271    
272    typedef void      (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics   metrics );    typedef void
273      (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics  metrics );
274    
275    
276    typedef FT_Error  (*AF_Script_InitHintsFunc)( AF_GlyphHints     hints,    typedef FT_Error
277                                                  AF_ScriptMetrics  metrics );    (*AF_Script_InitHintsFunc)( AF_GlyphHints     hints,
278                                  AF_ScriptMetrics  metrics );
279    
280    typedef void      (*AF_Script_ApplyHintsFunc)( AF_GlyphHints     hints,    typedef void
281                                                   FT_Outline*       outline,    (*AF_Script_ApplyHintsFunc)( AF_GlyphHints     hints,
282                                                   AF_ScriptMetrics  metrics );                                 FT_Outline*       outline,
283                                   AF_ScriptMetrics  metrics );
284    
285    
286    typedef struct AF_Script_UniRangeRec_    typedef struct  AF_Script_UniRangeRec_
287    {    {
288      FT_UInt32    first;      FT_UInt32  first;
289      FT_UInt32    last;      FT_UInt32  last;
290    
291    } AF_Script_UniRangeRec;    } AF_Script_UniRangeRec;
292    
293    typedef const AF_Script_UniRangeRec *  AF_Script_UniRange;    typedef const AF_Script_UniRangeRec  *AF_Script_UniRange;
294    
295    
296    typedef struct AF_ScriptClassRec_    typedef struct  AF_ScriptClassRec_
297    {    {
298      AF_Script                   script;      AF_Script                   script;
299      AF_Script_UniRange          script_uni_ranges;  /* last must be { 0, 0 } */      AF_Script_UniRange          script_uni_ranges; /* last must be { 0, 0 } */
300    
301      FT_UInt                     script_metrics_size;      FT_UInt                     script_metrics_size;
302      AF_Script_InitMetricsFunc   script_metrics_init;      AF_Script_InitMetricsFunc   script_metrics_init;
# Line 288  FT_BEGIN_HEADER Line 314  FT_BEGIN_HEADER
314  FT_END_HEADER  FT_END_HEADER
315    
316  #endif /* __AFTYPES_H__ */  #endif /* __AFTYPES_H__ */
317    
318    
319    /* END */

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26