1 /***************************************************************************/
5 /* General types and definitions for the auto-hint module */
6 /* (specification only). */
8 /* Copyright 2000-2001 Catharon Productions Inc. */
9 /* Author: David Turner */
11 /* This file is part of the Catharon Typography Project and shall only */
12 /* be used, modified, and distributed under the terms of the Catharon */
13 /* Open Source License that should come with this file under the name */
14 /* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
15 /* this file you indicate that you have read the license and */
16 /* understand and accept it fully. */
18 /* Note that this license is compatible with the FreeType license. */
20 /***************************************************************************/
28 #include FT_INTERNAL_OBJECTS_H
38 #define AH_LOG( x ) printf ## x
42 #define AH_LOG( x ) do ; while ( 0 ) /* nothing */
50 /*************************************************************************/
51 /*************************************************************************/
52 /*************************************************************************/
54 /**** COMPILE-TIME BUILD OPTIONS ****/
56 /**** Toggle these configuration macros to experiment with `features' ****/
57 /**** of the auto-hinter. ****/
59 /*************************************************************************/
60 /*************************************************************************/
61 /*************************************************************************/
64 /*************************************************************************/
66 /* If this option is defined, only strong interpolation will be used to */
67 /* place the points between edges. Otherwise, `smooth' points are */
68 /* detected and later hinted through weak interpolation to correct some */
69 /* unpleasant artefacts. */
71 #undef AH_OPTION_NO_WEAK_INTERPOLATION
74 /*************************************************************************/
76 /* If this option is defined, only weak interpolation will be used to */
77 /* place the points between edges. Otherwise, `strong' points are */
78 /* detected and later hinted through strong interpolation to correct */
79 /* some unpleasant artefacts. */
81 #undef AH_OPTION_NO_STRONG_INTERPOLATION
84 /*************************************************************************/
86 /* Undefine this macro if you don't want to hint the metrics. There is */
87 /* no reason to do this (at least for non-CJK scripts), except for */
88 /* experimentation. */
90 #define AH_HINT_METRICS
93 /*************************************************************************/
95 /* Define this macro if you do not want to insert extra edges at a */
96 /* glyph's x and y extremum (if there isn't one already available). */
97 /* This helps to reduce a number of artefacts and allows hinting of */
100 #undef AH_OPTION_NO_EXTREMUM_EDGES
103 /* don't touch for now */
104 #define AH_MAX_WIDTHS 12
105 #define AH_MAX_HEIGHTS 12
108 /*************************************************************************/
109 /*************************************************************************/
110 /*************************************************************************/
112 /**** TYPE DEFINITIONS ****/
114 /*************************************************************************/
115 /*************************************************************************/
116 /*************************************************************************/
120 typedef FT_Int AH_Angle;
124 #define ah_flah_none 0
126 /* bezier control points flags */
127 #define ah_flah_conic 1
128 #define ah_flah_cubic 2
129 #define ah_flah_control ( ah_flah_conic | ah_flah_cubic )
132 #define ah_flah_extrema_x 4
133 #define ah_flah_extrema_y 8
136 #define ah_flah_round_x 16
137 #define ah_flah_round_y 32
140 #define ah_flah_touch_x 64
141 #define ah_flah_touch_y 128
143 /* weak interpolation */
144 #define ah_flah_weak_interpolation 256
146 typedef FT_Int AH_Flags;
149 /* edge hint flags */
150 #define ah_edge_normal 0
151 #define ah_edge_round 1
152 #define ah_edge_serif 2
153 #define ah_edge_done 4
155 typedef FT_Int AH_Edge_Flags;
158 /* hint directions -- the values are computed so that two vectors are */
159 /* in opposite directions iff `dir1+dir2 == 0' */
160 #define ah_dir_none 4
161 #define ah_dir_right 1
162 #define ah_dir_left -1
164 #define ah_dir_down -2
166 typedef FT_Int AH_Direction;
169 typedef struct AH_Point AH_Point;
170 typedef struct AH_Segment AH_Segment;
171 typedef struct AH_Edge AH_Edge;
174 /*************************************************************************/
180 /* A structure used to model an outline point to the AH_Outline type. */
183 /* flags :: The current point hint flags. */
185 /* ox, oy :: The current original scaled coordinates. */
187 /* fx, fy :: The current coordinates in font units. */
189 /* x, y :: The current hinter coordinates. */
191 /* u, v :: Point coordinates -- meaning varies with context. */
193 /* in_dir :: The direction of the inwards vector (prev->point). */
195 /* out_dir :: The direction of the outwards vector (point->next). */
197 /* in_angle :: The angle of the inwards vector. */
199 /* out_angle :: The angle of the outwards vector. */
201 /* next :: The next point in same contour. */
203 /* prev :: The previous point in same contour. */
207 AH_Flags flags; /* point flags used by hinter */
213 AH_Direction in_dir; /* direction of inwards vector */
214 AH_Direction out_dir; /* direction of outwards vector */
219 AH_Point* next; /* next point in contour */
220 AH_Point* prev; /* previous point in contour */
224 /*************************************************************************/
230 /* A structure used to describe an edge segment to the auto-hinter. */
231 /* A segment is simply a sequence of successive points located on the */
232 /* same horizontal or vertical `position', in a given direction. */
235 /* flags :: The segment edge flags (straight, rounded, etc.). */
237 /* dir :: The segment direction. */
239 /* first :: The first point in the segment. */
241 /* last :: The last point in the segment. */
243 /* contour :: A pointer to the first point of the segment's */
246 /* pos :: The segment position in font units. */
248 /* size :: The segment size. */
250 /* edge :: The edge of the current segment. */
252 /* edge_next :: The next segment on the same edge. */
254 /* link :: The pairing segment for this edge. */
256 /* serif :: The primary segment for serifs. */
258 /* num_linked :: The number of other segments that link to this one. */
260 /* score :: Used to score the segment when selecting them. */
267 AH_Point* first; /* first point in edge segment */
268 AH_Point* last; /* last point in edge segment */
269 AH_Point** contour; /* ptr to first point of segment's contour */
271 FT_Pos pos; /* position of segment */
272 FT_Pos min_coord; /* minimum coordinate of segment */
273 FT_Pos max_coord; /* maximum coordinate of segment */
276 AH_Segment* edge_next;
278 AH_Segment* link; /* link segment */
279 AH_Segment* serif; /* primary segment for serifs */
280 FT_Pos num_linked; /* number of linked segments */
285 /*************************************************************************/
291 /* A structure used to describe an edge, which really is a horizontal */
292 /* or vertical coordinate to be hinted depending on the segments */
296 /* flags :: The segment edge flags (straight, rounded, etc.). */
298 /* dir :: The main segment direction on this edge. */
300 /* first :: The first edge segment. */
302 /* last :: The last edge segment. */
304 /* fpos :: The original edge position in font units. */
306 /* opos :: The original scaled edge position. */
308 /* pos :: The hinted edge position. */
310 /* link :: The linked edge. */
312 /* serif :: The serif edge. */
314 /* num_paired :: The number of other edges that pair to this one. */
316 /* score :: Used to score the edge when selecting them. */
318 /* blue_edge :: Indicate the blue zone edge this edge is related to. */
319 /* Only set for some of the horizontal edges in a Latin */
343 /* an outline as seen by the hinter */
344 typedef struct AH_Outline_
348 AH_Direction vert_major_dir; /* vertical major direction */
349 AH_Direction horz_major_dir; /* horizontal major direction */
353 FT_Pos edge_distance_threshold;
369 FT_Int num_hsegments;
370 AH_Segment* horz_segments;
372 FT_Int num_vsegments;
373 AH_Segment* vert_segments;
378 #define ah_blue_capital_top 0 /* THEZOCQS */
379 #define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */
380 #define ah_blue_small_top ( ah_blue_capital_bottom + 1 ) /* xzroesc */
381 #define ah_blue_small_bottom ( ah_blue_small_top + 1 ) /* xzroesc */
382 #define ah_blue_small_minor ( ah_blue_small_bottom + 1 ) /* pqgjy */
383 #define ah_blue_max ( ah_blue_small_minor + 1 )
385 typedef FT_Int AH_Blue;
388 #define ah_hinter_monochrome 1
389 #define ah_hinter_optimize 2
391 typedef FT_Int AH_Hinter_Flags;
394 /*************************************************************************/
400 /* Holds the global metrics for a given font face (be it in design */
401 /* units or scaled pixel values). */
404 /* num_widths :: The number of widths. */
406 /* num_heights :: The number of heights. */
408 /* widths :: Snap widths, including standard one. */
410 /* heights :: Snap height, including standard one. */
412 /* blue_refs :: The reference positions of blue zones. */
414 /* blue_shoots :: The overshoot positions of blue zones. */
416 typedef struct AH_Globals_
421 FT_Pos widths [AH_MAX_WIDTHS];
422 FT_Pos heights[AH_MAX_HEIGHTS];
424 FT_Pos blue_refs [ah_blue_max];
425 FT_Pos blue_shoots[ah_blue_max];
430 /*************************************************************************/
433 /* AH_Face_Globals */
436 /* Holds the complete global metrics for a given font face (i.e., the */
437 /* design units version + a scaled version + the current scales */
441 /* face :: A handle to the source face object */
443 /* design :: The globals in font design units. */
445 /* scaled :: Scaled globals in sub-pixel values. */
447 /* x_scale :: The current horizontal scale. */
449 /* y_scale :: The current vertical scale. */
451 typedef struct AH_Face_Globals_
458 FT_Bool control_overshoot;
463 typedef struct AH_Hinter
466 AH_Hinter_Flags flags;
471 AH_Face_Globals* globals;
480 FT_Vector trans_delta;
481 FT_Matrix trans_matrix;
483 FT_Bool disable_horz_edges;
484 FT_Bool disable_vert_edges;
490 #endif /* __AHTYPES_H__ */