]> git.saurik.com Git - wxWidgets.git/blame - src/freetype/autohint/ahtypes.h
made GetColourFromGTKWidget() more general, it is now used for all colours
[wxWidgets.git] / src / freetype / autohint / ahtypes.h
CommitLineData
cabec872
RR
1/***************************************************************************/
2/* */
3/* ahtypes.h */
4/* */
5/* General types and definitions for the auto-hint module */
6/* (specification only). */
7/* */
8/* Copyright 2000 Catharon Productions Inc. */
9/* Author: David Turner */
10/* */
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. */
17/* */
18/* Note that this license is compatible with the FreeType license. */
19/* */
20/***************************************************************************/
21
22
23#ifndef AHTYPES_H
24#define AHTYPES_H
25
26
27#include <freetype/internal/ftobjs.h> /* for freetype.h + LOCAL_DEF etc. */
28
29
30#ifdef FT_FLAT_COMPILE
31
32#include "ahloader.h"
33
34#else
35
36#include <autohint/ahloader.h>
37
38#endif
39
40
41#define xxAH_DEBUG
42
43
44#ifdef AH_DEBUG
45
46#include <stdio.h>
47
48#define AH_LOG( x ) printf##x
49
50#else
51
52#define AH_LOG( x ) do ; while ( 0 ) /* nothing */
53
54#endif
55
56
57 /*************************************************************************/
58 /*************************************************************************/
59 /*************************************************************************/
60 /**** ****/
61 /**** COMPILE-TIME BUILD OPTIONS ****/
62 /**** ****/
63 /**** Toggle these configuration macros to experiment with `features' ****/
64 /**** of the auto-hinter. ****/
65 /**** ****/
66 /*************************************************************************/
67 /*************************************************************************/
68 /*************************************************************************/
69
70
71 /*************************************************************************/
72 /* */
73 /* If this option is defined, only strong interpolation will be used to */
74 /* place the points between edges. Otherwise, `smooth' points are */
75 /* detected and later hinted through weak interpolation to correct some */
76 /* unpleasant artefacts. */
77 /* */
78#undef AH_OPTION_NO_WEAK_INTERPOLATION
79
80
81 /*************************************************************************/
82 /* */
83 /* If this option is defined, only weak interpolation will be used to */
84 /* place the points between edges. Otherwise, `strong' points are */
85 /* detected and later hinted through strong interpolation to correct */
86 /* some unpleasant artefacts. */
87 /* */
88#undef AH_OPTION_NO_STRONG_INTERPOLATION
89
90
91 /*************************************************************************/
92 /* */
93 /* Undefine this macro if you don't want to hint the metrics. There is */
94 /* no reason to do this (at least for non-CJK scripts), except for */
95 /* experimentation. */
96 /* */
97#define AH_HINT_METRICS
98
99
100 /*************************************************************************/
101 /* */
102 /* Define this macro if you do not want to insert extra edges at a */
103 /* glyph's x and y extremum (if there isn't one already available). */
104 /* This helps to reduce a number of artefacts and allows hinting of */
105 /* metrics. */
106 /* */
107#undef AH_OPTION_NO_EXTREMUM_EDGES
108
109
110 /* don't touch for now */
111#define AH_MAX_WIDTHS 12
112#define AH_MAX_HEIGHTS 12
113
114
115 /*************************************************************************/
116 /*************************************************************************/
117 /*************************************************************************/
118 /**** ****/
119 /**** TYPE DEFINITIONS ****/
120 /**** ****/
121 /*************************************************************************/
122 /*************************************************************************/
123 /*************************************************************************/
124
125
126 /* see agangles.h */
127 typedef FT_Int AH_Angle;
128
129
130 /* hint flags */
131#define ah_flah_none 0
132
133 /* bezier control points flags */
134#define ah_flah_conic 1
135#define ah_flah_cubic 2
136#define ah_flah_control ( ah_flah_conic | ah_flah_cubic )
137
138 /* extrema flags */
139#define ah_flah_extrema_x 4
140#define ah_flah_extrema_y 8
141
142 /* roundness */
143#define ah_flah_round_x 16
144#define ah_flah_round_y 32
145
146 /* touched */
147#define ah_flah_touch_x 64
148#define ah_flah_touch_y 128
149
150 /* weak interpolation */
151#define ah_flah_weak_interpolation 256
152
153 typedef FT_Int AH_Flags;
154
155
156 /* edge hint flags */
157#define ah_edge_normal 0
158#define ah_edge_round 1
159#define ah_edge_serif 2
160#define ah_edge_done 4
161
162 typedef FT_Int AH_Edge_Flags;
163
164
165 /* hint directions -- the values are computed so that two vectors are */
166 /* in opposite directions iff `dir1+dir2 == 0' */
167#define ah_dir_none 4
168#define ah_dir_right 1
169#define ah_dir_left -1
170#define ah_dir_up 2
171#define ah_dir_down -2
172
173 typedef FT_Int AH_Direction;
174
175
176 typedef struct AH_Point AH_Point;
177 typedef struct AH_Segment AH_Segment;
178 typedef struct AH_Edge AH_Edge;
179
180
181 /*************************************************************************/
182 /* */
183 /* <Struct> */
184 /* AH_Point */
185 /* */
186 /* <Description> */
187 /* A structure used to model an outline point to the AH_Outline type. */
188 /* */
189 /* <Fields> */
190 /* flags :: The current point hint flags. */
191 /* */
192 /* ox, oy :: The current original scaled coordinates. */
193 /* */
194 /* fx, fy :: The current coordinates in font units. */
195 /* */
196 /* x, y :: The current hinter coordinates. */
197 /* */
198 /* u, v :: Point coordinates -- meaning varies with context. */
199 /* */
200 /* in_dir :: The direction of the inwards vector (prev->point). */
201 /* */
202 /* out_dir :: The direction of the outwards vector (point->next). */
203 /* */
204 /* in_angle :: The angle of the inwards vector. */
205 /* */
206 /* out_angle :: The angle of the outwards vector. */
207 /* */
208 /* next :: The next point in same contour. */
209 /* */
210 /* prev :: The previous point in same contour. */
211 /* */
212 struct AH_Point
213 {
214 AH_Flags flags; /* point flags used by hinter */
215 FT_Pos ox, oy;
216 FT_Pos fx, fy;
217 FT_Pos x, y;
218 FT_Pos u, v;
219
220 AH_Direction in_dir; /* direction of inwards vector */
221 AH_Direction out_dir; /* direction of outwards vector */
222
223 AH_Angle in_angle;
224 AH_Angle out_angle;
225
226 AH_Point* next; /* next point in contour */
227 AH_Point* prev; /* previous point in contour */
228 };
229
230
231 /*************************************************************************/
232 /* */
233 /* <Struct> */
234 /* AH_Segment */
235 /* */
236 /* <Description> */
237 /* A structure used to describe an edge segment to the auto-hinter. */
238 /* A segment is simply a sequence of successive points located on the */
239 /* same horizontal or vertical `position', in a given direction. */
240 /* */
241 /* <Fields> */
242 /* flags :: The segment edge flags (straight, rounded, etc.). */
243 /* */
244 /* dir :: The segment direction. */
245 /* */
246 /* first :: The first point in the segment. */
247 /* */
248 /* last :: The last point in the segment. */
249 /* */
250 /* contour :: A pointer to the first point of the segment's */
251 /* contour. */
252 /* */
253 /* pos :: The segment position in font units. */
254 /* */
255 /* size :: The segment size. */
256 /* */
257 /* edge :: The edge of the current segment. */
258 /* */
259 /* edge_next :: The next segment on the same edge. */
260 /* */
261 /* link :: The pairing segment for this edge. */
262 /* */
263 /* serif :: The primary segment for serifs. */
264 /* */
265 /* num_linked :: The number of other segments that link to this one. */
266 /* */
267 /* score :: Used to score the segment when selecting them. */
268 /* */
269 struct AH_Segment
270 {
271 AH_Edge_Flags flags;
272 AH_Direction dir;
273
274 AH_Point* first; /* first point in edge segment */
275 AH_Point* last; /* last point in edge segment */
276 AH_Point** contour; /* ptr to first point of segment's contour */
277
278 FT_Pos pos; /* position of segment */
279 FT_Pos min_coord; /* minimum coordinate of segment */
280 FT_Pos max_coord; /* maximum coordinate of segment */
281
282 AH_Edge* edge;
283 AH_Segment* edge_next;
284
285 AH_Segment* link; /* link segment */
286 AH_Segment* serif; /* primary segment for serifs */
287 FT_Pos num_linked; /* number of linked segments */
288 FT_Int score;
289 };
290
291
292 /*************************************************************************/
293 /* */
294 /* <Struct> */
295 /* AH_Edge */
296 /* */
297 /* <Description> */
298 /* A structure used to describe an edge, which really is a horizontal */
299 /* or vertical coordinate to be hinted depending on the segments */
300 /* located on it. */
301 /* */
302 /* <Fields> */
303 /* flags :: The segment edge flags (straight, rounded, etc.). */
304 /* */
305 /* dir :: The main segment direction on this edge. */
306 /* */
307 /* first :: The first edge segment. */
308 /* */
309 /* last :: The last edge segment. */
310 /* */
311 /* fpos :: The original edge position in font units. */
312 /* */
313 /* opos :: The original scaled edge position. */
314 /* */
315 /* pos :: The hinted edge position. */
316 /* */
317 /* link :: The linked edge. */
318 /* */
319 /* serif :: The serif edge. */
320 /* */
321 /* num_paired :: The number of other edges that pair to this one. */
322 /* */
323 /* score :: Used to score the edge when selecting them. */
324 /* */
325 /* blue_edge :: Indicate the blue zone edge this edge is related to. */
326 /* Only set for some of the horizontal edges in a Latin */
327 /* font. */
328 /* */
329 struct AH_Edge
330 {
331 AH_Edge_Flags flags;
332 AH_Direction dir;
333
334 AH_Segment* first;
335 AH_Segment* last;
336
337 FT_Pos fpos;
338 FT_Pos opos;
339 FT_Pos pos;
340
341 AH_Edge* link;
342 AH_Edge* serif;
343 FT_Int num_linked;
344
345 FT_Int score;
346 FT_Pos* blue_edge;
347 };
348
349
350 /* an outline as seen by the hinter */
351 typedef struct AH_Outline_
352 {
353 FT_Memory memory;
354
355 AH_Direction vert_major_dir; /* vertical major direction */
356 AH_Direction horz_major_dir; /* horizontal major direction */
357
358 FT_Fixed x_scale;
359 FT_Fixed y_scale;
360 FT_Pos edge_distance_threshold;
361
362 FT_Int max_points;
363 FT_Int num_points;
364 AH_Point* points;
365
366 FT_Int max_contours;
367 FT_Int num_contours;
368 AH_Point** contours;
369
370 FT_Int num_hedges;
371 AH_Edge* horz_edges;
372
373 FT_Int num_vedges;
374 AH_Edge* vert_edges;
375
376 FT_Int num_hsegments;
377 AH_Segment* horz_segments;
378
379 FT_Int num_vsegments;
380 AH_Segment* vert_segments;
381
382 } AH_Outline;
383
384
385#define ah_blue_capital_top 0 /* THEZOCQS */
386#define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */
387#define ah_blue_small_top ( ah_blue_capital_bottom + 1 ) /* xzroesc */
388#define ah_blue_small_bottom ( ah_blue_small_top + 1 ) /* xzroesc */
389#define ah_blue_small_minor ( ah_blue_small_bottom + 1 ) /* pqgjy */
390#define ah_blue_max ( ah_blue_small_minor + 1 )
391
392 typedef FT_Int AH_Blue;
393
394
395#define ah_hinter_monochrome 1
396#define ah_hinter_optimize 2
397
398 typedef FT_Int AH_Hinter_Flags;
399
400
401 /*************************************************************************/
402 /* */
403 /* <Struct> */
404 /* AH_Globals */
405 /* */
406 /* <Description> */
407 /* Holds the global metrics for a given font face (be it in design */
408 /* units or scaled pixel values). */
409 /* */
410 /* <Fields> */
411 /* num_widths :: The number of widths. */
412 /* */
413 /* num_heights :: The number of heights. */
414 /* */
415 /* widths :: Snap widths, including standard one. */
416 /* */
417 /* heights :: Snap height, including standard one. */
418 /* */
419 /* blue_refs :: The reference positions of blue zones. */
420 /* */
421 /* blue_shoots :: The overshoot positions of blue zones. */
422 /* */
423 typedef struct AH_Globals_
424 {
425 FT_Int num_widths;
426 FT_Int num_heights;
427
428 FT_Pos widths [AH_MAX_WIDTHS];
429 FT_Pos heights[AH_MAX_HEIGHTS];
430
431 FT_Pos blue_refs [ah_blue_max];
432 FT_Pos blue_shoots[ah_blue_max];
433
434 } AH_Globals;
435
436
437 /*************************************************************************/
438 /* */
439 /* <Struct> */
440 /* AH_Face_Globals */
441 /* */
442 /* <Description> */
443 /* Holds the complete global metrics for a given font face (i.e., the */
444 /* design units version + a scaled version + the current scales */
445 /* used). */
446 /* */
447 /* <Fields> */
448 /* face :: A handle to the source face object */
449 /* */
450 /* design :: The globals in font design units. */
451 /* */
452 /* scaled :: Scaled globals in sub-pixel values. */
453 /* */
454 /* x_scale :: The current horizontal scale. */
455 /* */
456 /* y_scale :: The current vertical scale. */
457 /* */
458 typedef struct AH_Face_Globals_
459 {
460 FT_Face face;
461 AH_Globals design;
462 AH_Globals scaled;
463 FT_Fixed x_scale;
464 FT_Fixed y_scale;
465 FT_Bool control_overshoot;
466
467 } AH_Face_Globals;
468
469
470 typedef struct AH_Hinter
471 {
472 FT_Memory memory;
473 AH_Hinter_Flags flags;
474
475 FT_Int algorithm;
476 FT_Face face;
477
478 AH_Face_Globals* globals;
479
480 AH_Outline* glyph;
481
482 AH_Loader* loader;
483 FT_Vector pp1;
484 FT_Vector pp2;
485
486 } AH_Hinter;
487
488
489#endif /* AHTYPES_H */
490
491
492/* END */