1
/***************************************************************************/
5
/* PostScript hinting algorithm (specification). */
7
/* Copyright 2001, 2002, 2003 by */
8
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16
/***************************************************************************/
25
#include FT_TRIGONOMETRY_H
31
/* handle to Hint structure */
32
typedef struct PSH_HintRec_* PSH_Hint;
37
PSH_HINT_GHOST = PS_HINT_FLAG_GHOST,
38
PSH_HINT_BOTTOM = PS_HINT_FLAG_BOTTOM,
45
#define psh_hint_is_active( x ) ( ( (x)->flags & PSH_HINT_ACTIVE ) != 0 )
46
#define psh_hint_is_ghost( x ) ( ( (x)->flags & PSH_HINT_GHOST ) != 0 )
47
#define psh_hint_is_fitted( x ) ( ( (x)->flags & PSH_HINT_FITTED ) != 0 )
49
#define psh_hint_activate( x ) (x)->flags |= PSH_HINT_ACTIVE
50
#define psh_hint_deactivate( x ) (x)->flags &= ~PSH_HINT_ACTIVE
51
#define psh_hint_set_fitted( x ) (x)->flags |= PSH_HINT_FITTED
54
typedef struct PSH_HintRec_
67
/* this is an interpolation zone used for strong points; */
68
/* weak points are interpolated according to their strong */
70
typedef struct PSH_ZoneRec_
77
} PSH_ZoneRec, *PSH_Zone;
80
typedef struct PSH_Hint_TableRec_
86
PSH_Hint* sort_global;
90
PS_Mask_Table hint_masks;
91
PS_Mask_Table counter_masks;
93
} PSH_Hint_TableRec, *PSH_Hint_Table;
96
typedef struct PSH_PointRec_* PSH_Point;
97
typedef struct PSH_ContourRec_* PSH_Contour;
108
#define PSH_DIR_HORIZONTAL 2
109
#define PSH_DIR_VERTICAL 1
111
#define PSH_DIR_COMPARE( d1, d2 ) ( (d1) == (d2) || (d1) == -(d2) )
112
#define PSH_DIR_IS_HORIZONTAL( d ) PSH_DIR_COMPARE( d, PSH_DIR_HORIZONTAL )
113
#define PSH_DIR_IS_VERTICAL( d ) PSH_DIR_COMPARE( d, PSH_DIR_VERTICAL )
116
/* the following bit-flags are computed once by the glyph */
117
/* analyzer, for both dimensions */
120
PSH_POINT_OFF = 1, /* point is off the curve */
121
PSH_POINT_SMOOTH = 2, /* point is smooth */
122
PSH_POINT_INFLEX = 4 /* point is inflection */
125
#define psh_point_is_smooth( p ) ( (p)->flags & PSH_POINT_SMOOTH )
126
#define psh_point_is_off( p ) ( (p)->flags & PSH_POINT_OFF )
127
#define psh_point_is_inflex( p ) ( (p)->flags & PSH_POINT_INFLEX )
129
#define psh_point_set_smooth( p ) (p)->flags |= PSH_POINT_SMOOTH
130
#define psh_point_set_off( p ) (p)->flags |= PSH_POINT_OFF
131
#define psh_point_set_inflex( p ) (p)->flags |= PSH_POINT_INFLEX
133
/* the following bit-flags are re-computed for each dimension */
136
PSH_POINT_STRONG = 16, /* point is strong */
137
PSH_POINT_FITTED = 32, /* point is already fitted */
138
PSH_POINT_EXTREMUM = 64, /* point is local extremum */
139
PSH_POINT_POSITIVE = 128, /* extremum has positive contour flow */
140
PSH_POINT_NEGATIVE = 256, /* extremum has negative contour flow */
141
PSH_POINT_EDGE_MIN = 512, /* point is aligned to left/bottom stem edge */
142
PSH_POINT_EDGE_MAX = 1024 /* point is aligned to top/right stem edge */
145
#define psh_point_is_strong( p ) ( (p)->flags2 & PSH_POINT_STRONG )
146
#define psh_point_is_fitted( p ) ( (p)->flags2 & PSH_POINT_FITTED )
147
#define psh_point_is_extremum( p ) ( (p)->flags2 & PSH_POINT_EXTREMUM )
148
#define psh_point_is_positive( p ) ( (p)->flags2 & PSH_POINT_POSITIVE )
149
#define psh_point_is_negative( p ) ( (p)->flags2 & PSH_POINT_NEGATIVE )
150
#define psh_point_is_edge_min( p ) ( (p)->flags2 & PSH_POINT_EDGE_MIN )
151
#define psh_point_is_edge_max( p ) ( (p)->flags2 & PSH_POINT_EDGE_MAX )
153
#define psh_point_set_strong( p ) (p)->flags2 |= PSH_POINT_STRONG
154
#define psh_point_set_fitted( p ) (p)->flags2 |= PSH_POINT_FITTED
155
#define psh_point_set_extremum( p ) (p)->flags2 |= PSH_POINT_EXTREMUM
156
#define psh_point_set_positive( p ) (p)->flags2 |= PSH_POINT_POSITIVE
157
#define psh_point_set_negative( p ) (p)->flags2 |= PSH_POINT_NEGATIVE
158
#define psh_point_set_edge_min( p ) (p)->flags2 |= PSH_POINT_EDGE_MIN
159
#define psh_point_set_edge_max( p ) (p)->flags2 |= PSH_POINT_EDGE_MAX
162
typedef struct PSH_PointRec_
189
#define PSH_POINT_EQUAL_ORG( a, b ) ( (a)->org_u == (b)->org_u && \
190
(a)->org_v == (b)->org_v )
192
#define PSH_POINT_ANGLE( a, b ) FT_Atan2( (b)->org_u - (a)->org_u, \
193
(b)->org_v - (a)->org_v )
195
typedef struct PSH_ContourRec_
203
typedef struct PSH_GlyphRec_
206
FT_UInt num_contours;
209
PSH_Contour contours;
214
PSH_Hint_TableRec hint_tables[2];
220
FT_Bool do_horz_hints;
221
FT_Bool do_vert_hints;
222
FT_Bool do_horz_snapping;
223
FT_Bool do_vert_snapping;
224
FT_Bool do_stem_adjust;
226
} PSH_GlyphRec, *PSH_Glyph;
230
extern PSH_Hint_Table ps_debug_hint_table;
233
(*PSH_HintFunc)( PSH_Hint hint,
236
extern PSH_HintFunc ps_debug_hint_func;
238
extern PSH_Glyph ps_debug_glyph;
243
ps_hints_apply( PS_Hints ps_hints,
246
FT_Render_Mode hint_mode );
252
#endif /* __PSHALGO_H__ */