1 |
|
/***************************************************************************/ |
2 |
|
/* */ |
3 |
|
/* afhints.h */ |
4 |
|
/* */ |
5 |
|
/* Auto-fitter hinting routines (specification). */ |
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 |
#ifndef __AFHINTS_H__ |
#ifndef __AFHINTS_H__ |
20 |
#define __AFHINTS_H__ |
#define __AFHINTS_H__ |
21 |
|
|
22 |
#include "aftypes.h" |
#include "aftypes.h" |
23 |
|
|
24 |
|
|
25 |
FT_BEGIN_HEADER |
FT_BEGIN_HEADER |
26 |
|
|
27 |
/* |
/* |
28 |
* The definition of outline glyph hints. These are shared by all |
* The definition of outline glyph hints. These are shared by all |
29 |
* script analysis routines (until now) |
* script analysis routines (until now). |
|
* |
|
30 |
*/ |
*/ |
31 |
|
|
32 |
typedef enum |
typedef enum |
33 |
{ |
{ |
34 |
AF_DIMENSION_HORZ = 0, /* x coordinates, i.e. vertical segments & edges */ |
AF_DIMENSION_HORZ = 0, /* x coordinates, */ |
35 |
AF_DIMENSION_VERT = 1, /* y coordinates, i.e. horizontal segments & edges */ |
/* i.e., vertical segments & edges */ |
36 |
|
AF_DIMENSION_VERT = 1, /* y coordinates, */ |
37 |
|
/* i.e., horizontal segments & edges */ |
38 |
|
|
39 |
AF_DIMENSION_MAX /* do not remove */ |
AF_DIMENSION_MAX /* do not remove */ |
40 |
|
|
42 |
|
|
43 |
|
|
44 |
/* hint directions -- the values are computed so that two vectors are */ |
/* hint directions -- the values are computed so that two vectors are */ |
45 |
/* in opposite directions iff `dir1+dir2 == 0' */ |
/* in opposite directions iff `dir1 + dir2 == 0' */ |
46 |
typedef enum |
typedef enum |
47 |
{ |
{ |
48 |
AF_DIR_NONE = 4, |
AF_DIR_NONE = 4, |
57 |
/* point hint flags */ |
/* point hint flags */ |
58 |
typedef enum |
typedef enum |
59 |
{ |
{ |
60 |
AF_FLAG_NONE = 0, |
AF_FLAG_NONE = 0, |
61 |
|
|
62 |
/* point type flags */ |
/* point type flags */ |
63 |
AF_FLAG_CONIC = (1 << 0), |
AF_FLAG_CONIC = 1 << 0, |
64 |
AF_FLAG_CUBIC = (1 << 1), |
AF_FLAG_CUBIC = 1 << 1, |
65 |
AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC, |
AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC, |
66 |
|
|
67 |
/* point extremum flags */ |
/* point extremum flags */ |
68 |
AF_FLAG_EXTREMA_X = (1 << 2), |
AF_FLAG_EXTREMA_X = 1 << 2, |
69 |
AF_FLAG_EXTREMA_Y = (1 << 3), |
AF_FLAG_EXTREMA_Y = 1 << 3, |
70 |
|
|
71 |
/* point roundness flags */ |
/* point roundness flags */ |
72 |
AF_FLAG_ROUND_X = (1 << 4), |
AF_FLAG_ROUND_X = 1 << 4, |
73 |
AF_FLAG_ROUND_Y = (1 << 5), |
AF_FLAG_ROUND_Y = 1 << 5, |
74 |
|
|
75 |
/* point touch flags */ |
/* point touch flags */ |
76 |
AF_FLAG_TOUCH_X = (1 << 6), |
AF_FLAG_TOUCH_X = 1 << 6, |
77 |
AF_FLAG_TOUCH_Y = (1 << 7), |
AF_FLAG_TOUCH_Y = 1 << 7, |
78 |
|
|
79 |
/* candidates for weak interpolation have this flag set */ |
/* candidates for weak interpolation have this flag set */ |
80 |
AF_FLAG_WEAK_INTERPOLATION = (1 << 8), |
AF_FLAG_WEAK_INTERPOLATION = 1 << 8, |
81 |
|
|
82 |
/* all inflection points in the outline have this flag set */ |
/* all inflection points in the outline have this flag set */ |
83 |
AF_FLAG_INFLECTION = (1 << 9) |
AF_FLAG_INFLECTION = 1 << 9 |
84 |
|
|
85 |
} AF_Flags; |
} AF_Flags; |
86 |
|
|
89 |
typedef enum |
typedef enum |
90 |
{ |
{ |
91 |
AF_EDGE_NORMAL = 0, |
AF_EDGE_NORMAL = 0, |
92 |
AF_EDGE_ROUND = (1 << 0), |
AF_EDGE_ROUND = 1 << 0, |
93 |
AF_EDGE_SERIF = (1 << 1), |
AF_EDGE_SERIF = 1 << 1, |
94 |
AF_EDGE_DONE = (1 << 2) |
AF_EDGE_DONE = 1 << 2 |
95 |
|
|
96 |
} AF_Edge_Flags; |
} AF_Edge_Flags; |
97 |
|
|
98 |
|
|
|
|
|
99 |
typedef struct AF_PointRec_* AF_Point; |
typedef struct AF_PointRec_* AF_Point; |
100 |
typedef struct AF_SegmentRec_* AF_Segment; |
typedef struct AF_SegmentRec_* AF_Segment; |
101 |
typedef struct AF_EdgeRec_* AF_Edge; |
typedef struct AF_EdgeRec_* AF_Edge; |
103 |
|
|
104 |
typedef struct AF_PointRec_ |
typedef struct AF_PointRec_ |
105 |
{ |
{ |
106 |
FT_UShort flags; /* point flags used by hinter */ |
FT_UShort flags; /* point flags used by hinter */ |
107 |
FT_Char in_dir; /* direction of inwards vector */ |
FT_Char in_dir; /* direction of inwards vector */ |
108 |
FT_Char out_dir; /* direction of outwards vector */ |
FT_Char out_dir; /* direction of outwards vector */ |
109 |
|
|
110 |
FT_Pos ox, oy; /* original, scaled position */ |
FT_Pos ox, oy; /* original, scaled position */ |
111 |
FT_Short fx, fy; /* original, unscaled position (font units) */ |
FT_Short fx, fy; /* original, unscaled position (font units) */ |
112 |
FT_Pos x, y; /* current position */ |
FT_Pos x, y; /* current position */ |
113 |
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */ |
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */ |
114 |
|
|
115 |
AF_Point next; /* next point in contour */ |
AF_Point next; /* next point in contour */ |
116 |
AF_Point prev; /* previous point in contour */ |
AF_Point prev; /* previous point in contour */ |
117 |
|
|
118 |
} AF_PointRec; |
} AF_PointRec; |
119 |
|
|
120 |
|
|
121 |
typedef struct AF_SegmentRec_ |
typedef struct AF_SegmentRec_ |
122 |
{ |
{ |
123 |
FT_Byte flags; /* edge/segment flags for this segment */ |
FT_Byte flags; /* edge/segment flags for this segment */ |
124 |
FT_Char dir; /* segment direction */ |
FT_Char dir; /* segment direction */ |
125 |
FT_Short pos; /* position of segment */ |
FT_Short pos; /* position of segment */ |
126 |
FT_Short min_coord; /* minimum coordinate of segment */ |
FT_Short min_coord; /* minimum coordinate of segment */ |
127 |
FT_Short max_coord; /* maximum coordinate of segment */ |
FT_Short max_coord; /* maximum coordinate of segment */ |
128 |
|
|
129 |
AF_Edge edge; /* the segment's parent edge */ |
AF_Edge edge; /* the segment's parent edge */ |
130 |
AF_Segment edge_next; /* link to next segment in parent edge */ |
AF_Segment edge_next; /* link to next segment in parent edge */ |
131 |
|
|
132 |
AF_Segment link; /* (stem) link segment */ |
AF_Segment link; /* (stem) link segment */ |
133 |
AF_Segment serif; /* primary segment for serifs */ |
AF_Segment serif; /* primary segment for serifs */ |
134 |
FT_Pos num_linked; /* number of linked segments */ |
FT_Pos num_linked; /* number of linked segments */ |
135 |
FT_Pos score; /* used during stem matching */ |
FT_Pos score; /* used during stem matching */ |
136 |
|
|
137 |
AF_Point first; /* first point in edge segment */ |
AF_Point first; /* first point in edge segment */ |
138 |
AF_Point last; /* last point in edge segment */ |
AF_Point last; /* last point in edge segment */ |
139 |
AF_Point* contour; /* ptr to first point of segment's contour */ |
AF_Point* contour; /* ptr to first point of segment's contour */ |
140 |
|
|
141 |
} AF_SegmentRec; |
} AF_SegmentRec; |
142 |
|
|
143 |
|
|
144 |
typedef struct AF_EdgeRec_ |
typedef struct AF_EdgeRec_ |
145 |
{ |
{ |
146 |
FT_Short fpos; /* original, unscaled position (font units) */ |
FT_Short fpos; /* original, unscaled position (font units) */ |
147 |
FT_Pos opos; /* original, scaled position */ |
FT_Pos opos; /* original, scaled position */ |
148 |
FT_Pos pos; /* current position */ |
FT_Pos pos; /* current position */ |
149 |
|
|
150 |
FT_Byte flags; /* edge flags */ |
FT_Byte flags; /* edge flags */ |
151 |
FT_Char dir; /* edge direction */ |
FT_Char dir; /* edge direction */ |
152 |
FT_Fixed scale; /* used to speed up interpolation between edges */ |
FT_Fixed scale; /* used to speed up interpolation between edges */ |
153 |
AF_Width blue_edge; /* non-NULL if this is a blue edge */ |
AF_Width blue_edge; /* non-NULL if this is a blue edge */ |
154 |
|
|
155 |
AF_Edge link; |
AF_Edge link; |
156 |
AF_Edge serif; |
AF_Edge serif; |
157 |
FT_Short num_linked; |
FT_Short num_linked; |
158 |
|
|
159 |
FT_Int score; |
FT_Int score; |
160 |
|
|
161 |
AF_Segment first; |
AF_Segment first; |
162 |
AF_Segment last; |
AF_Segment last; |
163 |
|
|
164 |
} AF_EdgeRec; |
} AF_EdgeRec; |
165 |
|
|
166 |
|
|
167 |
typedef struct AF_AxisHintsRec_ |
typedef struct AF_AxisHintsRec_ |
168 |
{ |
{ |
169 |
FT_Int num_segments; |
FT_Int num_segments; |
170 |
FT_Int max_segments; |
FT_Int max_segments; |
179 |
} AF_AxisHintsRec, *AF_AxisHints; |
} AF_AxisHintsRec, *AF_AxisHints; |
180 |
|
|
181 |
|
|
182 |
typedef struct AF_GlyphHintsRec_ |
typedef struct AF_GlyphHintsRec_ |
183 |
{ |
{ |
184 |
FT_Memory memory; |
FT_Memory memory; |
185 |
|
|
186 |
FT_Fixed x_scale; |
FT_Fixed x_scale; |
187 |
FT_Pos x_delta; |
FT_Pos x_delta; |
188 |
|
|
189 |
FT_Fixed y_scale; |
FT_Fixed y_scale; |
190 |
FT_Pos y_delta; |
FT_Pos y_delta; |
191 |
|
|
192 |
FT_Pos edge_distance_threshold; |
FT_Pos edge_distance_threshold; |
193 |
|
|
194 |
FT_Int max_points; |
FT_Int max_points; |
195 |
FT_Int num_points; |
FT_Int num_points; |
196 |
AF_Point points; |
AF_Point points; |
197 |
|
|
198 |
FT_Int max_contours; |
FT_Int max_contours; |
199 |
FT_Int num_contours; |
FT_Int num_contours; |
200 |
AF_Point* contours; |
AF_Point* contours; |
201 |
|
|
202 |
AF_AxisHintsRec axis[ AF_DIMENSION_MAX ]; |
AF_AxisHintsRec axis[AF_DIMENSION_MAX]; |
203 |
|
|
204 |
FT_UInt32 scaler_flags; /* copy of scaler flags */ |
FT_UInt32 scaler_flags; /* copy of scaler flags */ |
205 |
FT_UInt32 other_flags; /* free for script-specific implementations */ |
FT_UInt32 other_flags; /* free for script-specific */ |
206 |
|
/* implementations */ |
207 |
AF_ScriptMetrics metrics; |
AF_ScriptMetrics metrics; |
208 |
|
|
209 |
} AF_GlyphHintsRec; |
} AF_GlyphHintsRec; |
210 |
|
|
211 |
|
|
212 |
#define AF_HINTS_TEST_SCALER(h,f) ( (h)->scaler_flags & (f) ) |
#define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) ) |
213 |
#define AF_HINTS_TEST_OTHER(h,f) ( (h)->other_flags & (f) ) |
#define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) ) |
214 |
|
|
215 |
#define AF_HINTS_DO_HORIZONTAL(h) \ |
#define AF_HINTS_DO_HORIZONTAL( h ) \ |
216 |
!AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_HORIZONTAL) |
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) |
217 |
|
|
218 |
#define AF_HINTS_DO_VERTICAL(h) \ |
#define AF_HINTS_DO_VERTICAL( h ) \ |
219 |
!AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_VERTICAL) |
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) |
220 |
|
|
221 |
#define AF_HINTS_DO_ADVANCE(h) \ |
#define AF_HINTS_DO_ADVANCE( h ) \ |
222 |
!AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_ADVANCE) |
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE ) |
223 |
|
|
224 |
|
|
225 |
FT_LOCAL( AF_Direction ) |
FT_LOCAL( AF_Direction ) |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
/* recomputes all AF_Point in a AF_GlyphHints from the definitions |
/* |
248 |
* in a source outline |
* recompute all AF_Point in a AF_GlyphHints from the definitions |
249 |
*/ |
* in a source outline |
250 |
|
*/ |
251 |
FT_LOCAL( void ) |
FT_LOCAL( void ) |
252 |
af_glyph_hints_rescale( AF_GlyphHints hints, |
af_glyph_hints_rescale( AF_GlyphHints hints, |
253 |
AF_ScriptMetrics metrics ); |
AF_ScriptMetrics metrics ); |
254 |
|
|
255 |
FT_LOCAL( FT_Error ) |
FT_LOCAL( FT_Error ) |
256 |
af_glyph_hints_reload( AF_GlyphHints hints, |
af_glyph_hints_reload( AF_GlyphHints hints, |
257 |
FT_Outline* outline ); |
FT_Outline* outline ); |
258 |
|
|
259 |
FT_LOCAL( void ) |
FT_LOCAL( void ) |
260 |
af_glyph_hints_save( AF_GlyphHints hints, |
af_glyph_hints_save( AF_GlyphHints hints, |
261 |
FT_Outline* outline ); |
FT_Outline* outline ); |
262 |
|
|
263 |
FT_LOCAL( void ) |
FT_LOCAL( void ) |
264 |
af_glyph_hints_align_edge_points( AF_GlyphHints hints, |
af_glyph_hints_align_edge_points( AF_GlyphHints hints, |
277 |
|
|
278 |
/* */ |
/* */ |
279 |
|
|
280 |
|
|
281 |
FT_END_HEADER |
FT_END_HEADER |
282 |
|
|
283 |
#endif /* __AFHINTS_H__ */ |
#endif /* __AFHINTS_H__ */ |
284 |
|
|
285 |
|
|
286 |
|
/* END */ |