zenilib: zenilib/jni/external/freetype2/src/pshinter/pshalgo.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pshalgo.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* pshalgo.h */
4 /* */
5 /* PostScript hinting algorithm (specification). */
6 /* */
7 /* Copyright 2001, 2002, 2003, 2008 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 __PSHALGO_H__
20 #define __PSHALGO_H__
21
22
23 #include "pshrec.h"
24 #include "pshglob.h"
25 #include FT_TRIGONOMETRY_H
26
27
28 FT_BEGIN_HEADER
29
30
31 /* handle to Hint structure */
32 typedef struct PSH_HintRec_* PSH_Hint;
33
34 /* hint bit-flags */
35 typedef enum PSH_Hint_Flags_
36 {
37 PSH_HINT_GHOST = PS_HINT_FLAG_GHOST,
38 PSH_HINT_BOTTOM = PS_HINT_FLAG_BOTTOM,
39 PSH_HINT_ACTIVE = 4,
40 PSH_HINT_FITTED = 8
41
42 } PSH_Hint_Flags;
43
44
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 )
48
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
52
53 /* hint structure */
54 typedef struct PSH_HintRec_
55 {
56 FT_Int org_pos;
57 FT_Int org_len;
58 FT_Pos cur_pos;
59 FT_Pos cur_len;
60 FT_UInt flags;
61 PSH_Hint parent;
62 FT_Int order;
63
64 } PSH_HintRec;
65
66
67 /* this is an interpolation zone used for strong points; */
68 /* weak points are interpolated according to their strong */
69 /* neighbours */
70 typedef struct PSH_ZoneRec_
71 {
72 FT_Fixed scale;
73 FT_Fixed delta;
74 FT_Pos min;
75 FT_Pos max;
76
77 } PSH_ZoneRec, *PSH_Zone;
78
79
80 typedef struct PSH_Hint_TableRec_
81 {
82 FT_UInt max_hints;
83 FT_UInt num_hints;
84 PSH_Hint hints;
85 PSH_Hint* sort;
86 PSH_Hint* sort_global;
87 FT_UInt num_zones;
88 PSH_ZoneRec* zones;
89 PSH_Zone zone;
90 PS_Mask_Table hint_masks;
91 PS_Mask_Table counter_masks;
92
93 } PSH_Hint_TableRec, *PSH_Hint_Table;
94
95
96 typedef struct PSH_PointRec_* PSH_Point;
97 typedef struct PSH_ContourRec_* PSH_Contour;
98
99 enum
100 {
101 PSH_DIR_NONE = 4,
102 PSH_DIR_UP = -1,
103 PSH_DIR_DOWN = 1,
104 PSH_DIR_LEFT = -2,
105 PSH_DIR_RIGHT = 2
106 };
107
108 #define PSH_DIR_HORIZONTAL 2
109 #define PSH_DIR_VERTICAL 1
110
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 )
114
115
116 /* the following bit-flags are computed once by the glyph */
117 /* analyzer, for both dimensions */
118 enum
119 {
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 */
123 };
124
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 )
128
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
132
133 /* the following bit-flags are re-computed for each dimension */
134 enum
135 {
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 */
143 };
144
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 )
152
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
160
161
162 typedef struct PSH_PointRec_
163 {
164 PSH_Point prev;
165 PSH_Point next;
166 PSH_Contour contour;
167 FT_UInt flags;
168 FT_UInt flags2;
169 FT_Char dir_in;
170 FT_Char dir_out;
171 FT_Angle angle_in;
172 FT_Angle angle_out;
173 PSH_Hint hint;
174 FT_Pos org_u;
175 FT_Pos org_v;
176 FT_Pos cur_u;
177 #ifdef DEBUG_HINTER
178 FT_Pos org_x;
179 FT_Pos cur_x;
180 FT_Pos org_y;
181 FT_Pos cur_y;
182 FT_UInt flags_x;
183 FT_UInt flags_y;
184 #endif
185
186 } PSH_PointRec;
187
188
189 #define PSH_POINT_EQUAL_ORG( a, b ) ( (a)->org_u == (b)->org_u && \
190 (a)->org_v == (b)->org_v )
191
192 #define PSH_POINT_ANGLE( a, b ) FT_Atan2( (b)->org_u - (a)->org_u, \
193 (b)->org_v - (a)->org_v )
194
195 typedef struct PSH_ContourRec_
196 {
197 PSH_Point start;
198 FT_UInt count;
199
200 } PSH_ContourRec;
201
202
203 typedef struct PSH_GlyphRec_
204 {
205 FT_UInt num_points;
206 FT_UInt num_contours;
207
208 PSH_Point points;
209 PSH_Contour contours;
210
211 FT_Memory memory;
212 FT_Outline* outline;
213 PSH_Globals globals;
214 PSH_Hint_TableRec hint_tables[2];
215
216 FT_Bool vertical;
217 FT_Int major_dir;
218 FT_Int minor_dir;
219
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;
225
226 } PSH_GlyphRec, *PSH_Glyph;
227
228
229 #ifdef DEBUG_HINTER
230 extern PSH_Hint_Table ps_debug_hint_table;
231
232 typedef void
233 (*PSH_HintFunc)( PSH_Hint hint,
234 FT_Bool vertical );
235
236 extern PSH_HintFunc ps_debug_hint_func;
237
238 extern PSH_Glyph ps_debug_glyph;
239 #endif
240
241
242 extern FT_Error
243 ps_hints_apply( PS_Hints ps_hints,
244 FT_Outline* outline,
245 PSH_Globals globals,
246 FT_Render_Mode hint_mode );
247
248
249 FT_END_HEADER
250
251
252 #endif /* __PSHALGO_H__ */
253
254
255 /* END */
PSH_POINT_OFF
Definition: pshalgo.h:120
PSH_Hint_TableRec_::sort
PSH_Hint * sort
Definition: pshalgo.h:85
PSH_Globals
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
Definition: pshints.h:41
PSH_ZoneRec_::delta
FT_Fixed delta
Definition: pshalgo.h:73
FT_Error
int FT_Error
Definition: fttypes.h:296
PS_HINT_FLAG_BOTTOM
Definition: pshrec.h:67
PSH_PointRec_::dir_in
FT_Char dir_in
Definition: pshalgo.h:169
PSH_GlyphRec_::outline
FT_Outline * outline
Definition: pshalgo.h:212
PSH_Hint_TableRec_::hint_masks
PS_Mask_Table hint_masks
Definition: pshalgo.h:90
PSH_POINT_SMOOTH
Definition: pshalgo.h:121
FT_Pos
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
PSH_GlyphRec_::contours
PSH_Contour contours
Definition: pshalgo.h:209
PSH_Hint_Flags
enum PSH_Hint_Flags_ PSH_Hint_Flags
pshglob.h
PSH_HINT_BOTTOM
Definition: pshalgo.h:38
PSH_Hint_Table
struct PSH_Hint_TableRec_ * PSH_Hint_Table
PSH_PointRec_::prev
PSH_Point prev
Definition: pshalgo.h:164
PSH_DIR_NONE
Definition: pshalgo.h:101
void
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
PSH_PointRec_::hint
PSH_Hint hint
Definition: pshalgo.h:173
FT_END_HEADER
#define FT_END_HEADER
Definition: ftheader.h:54
PS_HintsRec_
Definition: pshrec.h:131
PSH_HintRec_::org_pos
FT_Int org_pos
Definition: pshalgo.h:56
FT_Int
signed int FT_Int
Definition: fttypes.h:216
PSH_DIR_RIGHT
Definition: pshalgo.h:105
PSH_GlyphRec_::num_points
FT_UInt num_points
Definition: pshalgo.h:205
PSH_Hint_TableRec_::hints
PSH_Hint hints
Definition: pshalgo.h:84
FT_Render_Mode
enum FT_Render_Mode_ FT_Render_Mode
PSH_HintRec_::parent
PSH_Hint parent
Definition: pshalgo.h:61
PSH_GlyphRec_::globals
PSH_Globals globals
Definition: pshalgo.h:213
PSH_GlyphRec_::points
PSH_Point points
Definition: pshalgo.h:208
FT_Char
signed char FT_Char
Definition: fttypes.h:139
PSH_HintRec_::flags
FT_UInt flags
Definition: pshalgo.h:60
PS_HINT_FLAG_GHOST
Definition: pshrec.h:66
FT_Outline_
Definition: ftimage.h:383
PSH_PointRec_::flags2
FT_UInt flags2
Definition: pshalgo.h:168
PSH_HintRec_
Definition: pshalgo.h:54
PSH_GlyphRec_::do_horz_snapping
FT_Bool do_horz_snapping
Definition: pshalgo.h:222
PSH_DIR_LEFT
Definition: pshalgo.h:104
PSH_HintRec_::order
FT_Int order
Definition: pshalgo.h:62
PSH_GlyphRec_::major_dir
FT_Int major_dir
Definition: pshalgo.h:217
PSH_PointRec
struct PSH_PointRec_ PSH_PointRec
PSH_ZoneRec
struct PSH_ZoneRec_ PSH_ZoneRec
PSH_PointRec_::org_u
FT_Pos org_u
Definition: pshalgo.h:174
PSH_POINT_FITTED
Definition: pshalgo.h:137
FT_Bool
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
PSH_HINT_GHOST
Definition: pshalgo.h:37
PSH_GlyphRec_::memory
FT_Memory memory
Definition: pshalgo.h:211
PSH_POINT_EDGE_MAX
Definition: pshalgo.h:142
PSH_HintRec
struct PSH_HintRec_ PSH_HintRec
PSH_GlyphRec_::do_vert_snapping
FT_Bool do_vert_snapping
Definition: pshalgo.h:223
PSH_DIR_DOWN
Definition: pshalgo.h:103
PSH_ContourRec
struct PSH_ContourRec_ PSH_ContourRec
PSH_GlyphRec_::minor_dir
FT_Int minor_dir
Definition: pshalgo.h:218
PSH_ZoneRec_::min
FT_Pos min
Definition: pshalgo.h:74
PSH_PointRec_::contour
PSH_Contour contour
Definition: pshalgo.h:166
PSH_GlyphRec_::hint_tables
PSH_Hint_TableRec hint_tables[2]
Definition: pshalgo.h:214
FT_BEGIN_HEADER
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
PSH_ContourRec_
Definition: pshalgo.h:195
PSH_ZoneRec_::scale
FT_Fixed scale
Definition: pshalgo.h:72
PSH_Hint
typedefFT_BEGIN_HEADER struct PSH_HintRec_ * PSH_Hint
Definition: pshalgo.h:32
PSH_PointRec_::org_v
FT_Pos org_v
Definition: pshalgo.h:175
PSH_Zone
struct PSH_ZoneRec_ * PSH_Zone
PSH_PointRec_::cur_u
FT_Pos cur_u
Definition: pshalgo.h:176
PSH_GlyphRec_::vertical
FT_Bool vertical
Definition: pshalgo.h:216
PSH_ContourRec_::count
FT_UInt count
Definition: pshalgo.h:198
PSH_POINT_STRONG
Definition: pshalgo.h:136
PSH_Hint_TableRec_::max_hints
FT_UInt max_hints
Definition: pshalgo.h:82
PSH_PointRec_::flags
FT_UInt flags
Definition: pshalgo.h:167
PSH_Hint_TableRec_
Definition: pshalgo.h:80
PSH_DIR_UP
Definition: pshalgo.h:102
PSH_PointRec_::next
PSH_Point next
Definition: pshalgo.h:165
FT_Angle
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
PSH_ZoneRec_::max
FT_Pos max
Definition: pshalgo.h:75
PSH_PointRec_::angle_out
FT_Angle angle_out
Definition: pshalgo.h:172
PSH_Hint_TableRec_::num_hints
FT_UInt num_hints
Definition: pshalgo.h:83
PSH_Hint_Flags_
PSH_Hint_Flags_
Definition: pshalgo.h:35
PSH_Hint_TableRec_::zones
PSH_ZoneRec * zones
Definition: pshalgo.h:88
PSH_PointRec_::dir_out
FT_Char dir_out
Definition: pshalgo.h:170
PS_Mask_TableRec_
Definition: pshrec.h:109
PSH_Hint_TableRec_::sort_global
PSH_Hint * sort_global
Definition: pshalgo.h:86
PSH_POINT_INFLEX
Definition: pshalgo.h:122
FT_Memory
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
PSH_HintRec_::cur_pos
FT_Pos cur_pos
Definition: pshalgo.h:58
PSH_Point
struct PSH_PointRec_ * PSH_Point
Definition: pshalgo.h:96
PSH_ZoneRec_
Definition: pshalgo.h:70
ps_hints_apply
FT_Error ps_hints_apply(PS_Hints ps_hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshalgo.c:2181
PSH_GlyphRec_
Definition: pshalgo.h:203
PSH_POINT_POSITIVE
Definition: pshalgo.h:139
PSH_PointRec_::angle_in
FT_Angle angle_in
Definition: pshalgo.h:171
PSH_POINT_EDGE_MIN
Definition: pshalgo.h:141
PSH_ContourRec_::start
PSH_Point start
Definition: pshalgo.h:197
PSH_PointRec_
Definition: pshalgo.h:162
PSH_HintRec_::cur_len
FT_Pos cur_len
Definition: pshalgo.h:59
FT_Fixed
signed long FT_Fixed
Definition: fttypes.h:284
PSH_POINT_EXTREMUM
Definition: pshalgo.h:138
PSH_Hint_TableRec_::zone
PSH_Zone zone
Definition: pshalgo.h:89
FT_UInt
unsigned int FT_UInt
Definition: fttypes.h:227
PSH_POINT_NEGATIVE
Definition: pshalgo.h:140
PSH_GlyphRec_::do_stem_adjust
FT_Bool do_stem_adjust
Definition: pshalgo.h:224
PSH_Hint_TableRec_::counter_masks
PS_Mask_Table counter_masks
Definition: pshalgo.h:91
PSH_Glyph
struct PSH_GlyphRec_ * PSH_Glyph
PSH_Contour
struct PSH_ContourRec_ * PSH_Contour
Definition: pshalgo.h:97
PSH_GlyphRec_::num_contours
FT_UInt num_contours
Definition: pshalgo.h:206
PSH_Hint_TableRec_::num_zones
FT_UInt num_zones
Definition: pshalgo.h:87
pshrec.h
PSH_HintRec_::org_len
FT_Int org_len
Definition: pshalgo.h:57
PSH_GlyphRec
struct PSH_GlyphRec_ PSH_GlyphRec
PSH_Hint_TableRec
struct PSH_Hint_TableRec_ PSH_Hint_TableRec
PSH_HINT_ACTIVE
Definition: pshalgo.h:39
PSH_HINT_FITTED
Definition: pshalgo.h:40
PSH_GlyphRec_::do_vert_hints
FT_Bool do_vert_hints
Definition: pshalgo.h:221
PSH_GlyphRec_::do_horz_hints
FT_Bool do_horz_hints
Definition: pshalgo.h:220