Merge 25584, 25588.
[reactos.git] / reactos / dll / 3rdparty / freetype / include / freetype / ftimage.h
1 /***************************************************************************/
2 /* */
3 /* ftimage.h */
4 /* */
5 /* FreeType glyph image formats and default raster interface */
6 /* (specification). */
7 /* */
8 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* */
11 /* This file is part of the FreeType project, and may only be used, */
12 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */
16 /* */
17 /***************************************************************************/
18
19 /*************************************************************************/
20 /* */
21 /* Note: A `raster' is simply a scan-line converter, used to render */
22 /* FT_Outlines into FT_Bitmaps. */
23 /* */
24 /*************************************************************************/
25
26
27 #ifndef __FTIMAGE_H__
28 #define __FTIMAGE_H__
29
30
31 /* _STANDALONE_ is from ftgrays.c */
32 #ifndef _STANDALONE_
33 #include <ft2build.h>
34 #endif
35
36
37 FT_BEGIN_HEADER
38
39
40 /*************************************************************************/
41 /* */
42 /* <Section> */
43 /* basic_types */
44 /* */
45 /*************************************************************************/
46
47
48 /*************************************************************************/
49 /* */
50 /* <Type> */
51 /* FT_Pos */
52 /* */
53 /* <Description> */
54 /* The type FT_Pos is a 32-bit integer used to store vectorial */
55 /* coordinates. Depending on the context, these can represent */
56 /* distances in integer font units, or 16,16, or 26.6 fixed float */
57 /* pixel coordinates. */
58 /* */
59 typedef signed long FT_Pos;
60
61
62 /*************************************************************************/
63 /* */
64 /* <Struct> */
65 /* FT_Vector */
66 /* */
67 /* <Description> */
68 /* A simple structure used to store a 2D vector; coordinates are of */
69 /* the FT_Pos type. */
70 /* */
71 /* <Fields> */
72 /* x :: The horizontal coordinate. */
73 /* y :: The vertical coordinate. */
74 /* */
75 typedef struct FT_Vector_
76 {
77 FT_Pos x;
78 FT_Pos y;
79
80 } FT_Vector;
81
82
83 /*************************************************************************/
84 /* */
85 /* <Struct> */
86 /* FT_BBox */
87 /* */
88 /* <Description> */
89 /* A structure used to hold an outline's bounding box, i.e., the */
90 /* coordinates of its extrema in the horizontal and vertical */
91 /* directions. */
92 /* */
93 /* <Fields> */
94 /* xMin :: The horizontal minimum (left-most). */
95 /* */
96 /* yMin :: The vertical minimum (bottom-most). */
97 /* */
98 /* xMax :: The horizontal maximum (right-most). */
99 /* */
100 /* yMax :: The vertical maximum (top-most). */
101 /* */
102 typedef struct FT_BBox_
103 {
104 FT_Pos xMin, yMin;
105 FT_Pos xMax, yMax;
106
107 } FT_BBox;
108
109
110 /*************************************************************************/
111 /* */
112 /* <Enum> */
113 /* FT_Pixel_Mode */
114 /* */
115 /* <Description> */
116 /* An enumeration type used to describe the format of pixels in a */
117 /* given bitmap. Note that additional formats may be added in the */
118 /* future. */
119 /* */
120 /* <Values> */
121 /* FT_PIXEL_MODE_NONE :: */
122 /* Value 0 is reserved. */
123 /* */
124 /* FT_PIXEL_MODE_MONO :: */
125 /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */
126 /* are stored in most-significant order (MSB), which means that */
127 /* the left-most pixel in a byte has value 128. */
128 /* */
129 /* FT_PIXEL_MODE_GRAY :: */
130 /* An 8-bit bitmap, generally used to represent anti-aliased glyph */
131 /* images. Each pixel is stored in one byte. Note that the number */
132 /* of value `gray' levels is stored in the `num_bytes' field of */
133 /* the @FT_Bitmap structure (it generally is 256). */
134 /* */
135 /* FT_PIXEL_MODE_GRAY2 :: */
136 /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */
137 /* bitmaps in font files according to the OpenType specification. */
138 /* We haven't found a single font using this format, however. */
139 /* */
140 /* FT_PIXEL_MODE_GRAY4 :: */
141 /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */
142 /* bitmaps in font files according to the OpenType specification. */
143 /* We haven't found a single font using this format, however. */
144 /* */
145 /* FT_PIXEL_MODE_LCD :: */
146 /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
147 /* images used for display on LCD displays; the bitmap is three */
148 /* times wider than the original glyph image. See also */
149 /* @FT_RENDER_MODE_LCD. */
150 /* */
151 /* FT_PIXEL_MODE_LCD_V :: */
152 /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
153 /* images used for display on rotated LCD displays; the bitmap */
154 /* is three times taller than the original glyph image. See also */
155 /* @FT_RENDER_MODE_LCD_V. */
156 /* */
157 typedef enum FT_Pixel_Mode_
158 {
159 FT_PIXEL_MODE_NONE = 0,
160 FT_PIXEL_MODE_MONO,
161 FT_PIXEL_MODE_GRAY,
162 FT_PIXEL_MODE_GRAY2,
163 FT_PIXEL_MODE_GRAY4,
164 FT_PIXEL_MODE_LCD,
165 FT_PIXEL_MODE_LCD_V,
166
167 FT_PIXEL_MODE_MAX /* do not remove */
168
169 } FT_Pixel_Mode;
170
171
172 /*************************************************************************/
173 /* */
174 /* <Enum> */
175 /* ft_pixel_mode_xxx */
176 /* */
177 /* <Description> */
178 /* A list of deprecated constants. Use the corresponding */
179 /* @FT_Pixel_Mode values instead. */
180 /* */
181 /* <Values> */
182 /* ft_pixel_mode_none :: See @FT_PIXEL_MODE_NONE. */
183 /* ft_pixel_mode_mono :: See @FT_PIXEL_MODE_MONO. */
184 /* ft_pixel_mode_grays :: See @FT_PIXEL_MODE_GRAY. */
185 /* ft_pixel_mode_pal2 :: See @FT_PIXEL_MODE_GRAY2. */
186 /* ft_pixel_mode_pal4 :: See @FT_PIXEL_MODE_GRAY4. */
187 /* */
188 #define ft_pixel_mode_none FT_PIXEL_MODE_NONE
189 #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
190 #define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
191 #define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
192 #define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
193
194 /* */
195
196 #if 0
197
198 /*************************************************************************/
199 /* */
200 /* <Enum> */
201 /* FT_Palette_Mode */
202 /* */
203 /* <Description> */
204 /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
205 /* */
206 /* An enumeration type to describe the format of a bitmap palette, */
207 /* used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */
208 /* */
209 /* <Fields> */
210 /* ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */
211 /* records. */
212 /* */
213 /* ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */
214 /* records. */
215 /* */
216 /* <Note> */
217 /* As ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */
218 /* FreeType, these types are not handled by the library itself. */
219 /* */
220 typedef enum FT_Palette_Mode_
221 {
222 ft_palette_mode_rgb = 0,
223 ft_palette_mode_rgba,
224
225 ft_palettte_mode_max /* do not remove */
226
227 } FT_Palette_Mode;
228
229 /* */
230
231 #endif
232
233
234 /*************************************************************************/
235 /* */
236 /* <Struct> */
237 /* FT_Bitmap */
238 /* */
239 /* <Description> */
240 /* A structure used to describe a bitmap or pixmap to the raster. */
241 /* Note that we now manage pixmaps of various depths through the */
242 /* `pixel_mode' field. */
243 /* */
244 /* <Fields> */
245 /* rows :: The number of bitmap rows. */
246 /* */
247 /* width :: The number of pixels in bitmap row. */
248 /* */
249 /* pitch :: The pitch's absolute value is the number of bytes */
250 /* taken by one bitmap row, including padding. */
251 /* However, the pitch is positive when the bitmap has */
252 /* a `down' flow, and negative when it has an `up' */
253 /* flow. In all cases, the pitch is an offset to add */
254 /* to a bitmap pointer in order to go down one row. */
255 /* */
256 /* buffer :: A typeless pointer to the bitmap buffer. This */
257 /* value should be aligned on 32-bit boundaries in */
258 /* most cases. */
259 /* */
260 /* num_grays :: This field is only used with */
261 /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */
262 /* levels used in the bitmap. */
263 /* */
264 /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
265 /* See @FT_Pixel_Mode for possible values. */
266 /* */
267 /* palette_mode :: This field is intended for paletted pixel modes; */
268 /* it indicates how the palette is stored. Not */
269 /* used currently. */
270 /* */
271 /* palette :: A typeless pointer to the bitmap palette; this */
272 /* field is intended for paletted pixel modes. Not */
273 /* used currently. */
274 /* */
275 /* <Note> */
276 /* For now, the only pixel modes supported by FreeType are mono and */
277 /* grays. However, drivers might be added in the future to support */
278 /* more `colorful' options. */
279 /* */
280 typedef struct FT_Bitmap_
281 {
282 int rows;
283 int width;
284 int pitch;
285 unsigned char* buffer;
286 short num_grays;
287 char pixel_mode;
288 char palette_mode;
289 void* palette;
290
291 } FT_Bitmap;
292
293
294 /*************************************************************************/
295 /* */
296 /* <Section> */
297 /* outline_processing */
298 /* */
299 /*************************************************************************/
300
301
302 /*************************************************************************/
303 /* */
304 /* <Struct> */
305 /* FT_Outline */
306 /* */
307 /* <Description> */
308 /* This structure is used to describe an outline to the scan-line */
309 /* converter. */
310 /* */
311 /* <Fields> */
312 /* n_contours :: The number of contours in the outline. */
313 /* */
314 /* n_points :: The number of points in the outline. */
315 /* */
316 /* points :: A pointer to an array of `n_points' @FT_Vector */
317 /* elements, giving the outline's point coordinates. */
318 /* */
319 /* tags :: A pointer to an array of `n_points' chars, giving */
320 /* each outline point's type. If bit 0 is unset, the */
321 /* point is `off' the curve, i.e., a Bézier control */
322 /* point, while it is `on' when set. */
323 /* */
324 /* Bit 1 is meaningful for `off' points only. If set, */
325 /* it indicates a third-order Bézier arc control point; */
326 /* and a second-order control point if unset. */
327 /* */
328 /* contours :: An array of `n_contours' shorts, giving the end */
329 /* point of each contour within the outline. For */
330 /* example, the first contour is defined by the points */
331 /* `0' to `contours[0]', the second one is defined by */
332 /* the points `contours[0]+1' to `contours[1]', etc. */
333 /* */
334 /* flags :: A set of bit flags used to characterize the outline */
335 /* and give hints to the scan-converter and hinter on */
336 /* how to convert/grid-fit it. See @FT_OUTLINE_FLAGS. */
337 /* */
338 typedef struct FT_Outline_
339 {
340 short n_contours; /* number of contours in glyph */
341 short n_points; /* number of points in the glyph */
342
343 FT_Vector* points; /* the outline's points */
344 char* tags; /* the points flags */
345 short* contours; /* the contour end points */
346
347 int flags; /* outline masks */
348
349 } FT_Outline;
350
351
352 /*************************************************************************/
353 /* */
354 /* <Enum> */
355 /* FT_OUTLINE_FLAGS */
356 /* */
357 /* <Description> */
358 /* A list of bit-field constants use for the flags in an outline's */
359 /* `flags' field. */
360 /* */
361 /* <Values> */
362 /* FT_OUTLINE_NONE :: Value 0 is reserved. */
363 /* */
364 /* FT_OUTLINE_OWNER :: If set, this flag indicates that the */
365 /* outline's field arrays (i.e., */
366 /* `points', `flags' & `contours') are */
367 /* `owned' by the outline object, and */
368 /* should thus be freed when it is */
369 /* destroyed. */
370 /* */
371 /* FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */
372 /* the non-zero winding rule. If set to */
373 /* 1, the outline will be filled using */
374 /* the even-odd fill rule (only works */
375 /* with the smooth raster). */
376 /* */
377 /* FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */
378 /* outline are oriented in clock-wise */
379 /* direction, as defined in the TrueType */
380 /* specification. This flag is set if */
381 /* the outline uses the opposite */
382 /* direction (typically for Type 1 */
383 /* fonts). This flag is ignored by the */
384 /* scan-converter. However, it is very */
385 /* important for the auto-hinter. */
386 /* */
387 /* FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */
388 /* try to detect drop-outs in an outline */
389 /* and correct the glyph bitmap to */
390 /* ensure consistent shape continuity. */
391 /* If set, this flag hints the scan-line */
392 /* converter to ignore such cases. */
393 /* */
394 /* FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */
395 /* scan-line converter should try to */
396 /* convert this outline to bitmaps with */
397 /* the highest possible quality. It is */
398 /* typically set for small character */
399 /* sizes. Note that this is only a */
400 /* hint, that might be completely */
401 /* ignored by a given scan-converter. */
402 /* */
403 /* FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */
404 /* scan-converter to only use a single */
405 /* pass over the outline to render a */
406 /* bitmap glyph image. Normally, it is */
407 /* set for very large character sizes. */
408 /* It is only a hint, that might be */
409 /* completely ignored by a given */
410 /* scan-converter. */
411 /* */
412 #define FT_OUTLINE_NONE 0x0
413 #define FT_OUTLINE_OWNER 0x1
414 #define FT_OUTLINE_EVEN_ODD_FILL 0x2
415 #define FT_OUTLINE_REVERSE_FILL 0x4
416 #define FT_OUTLINE_IGNORE_DROPOUTS 0x8
417
418 #define FT_OUTLINE_HIGH_PRECISION 0x100
419 #define FT_OUTLINE_SINGLE_PASS 0x200
420
421
422 /*************************************************************************
423 *
424 * @enum:
425 * ft_outline_flags
426 *
427 * @description:
428 * These constants are deprecated. Please use the corresponding
429 * @FT_OUTLINE_FLAGS values.
430 *
431 * @values:
432 * ft_outline_none :: See @FT_OUTLINE_NONE.
433 * ft_outline_owner :: See @FT_OUTLINE_OWNER.
434 * ft_outline_even_odd_fill :: See @FT_OUTLINE_EVEN_ODD_FILL.
435 * ft_outline_reverse_fill :: See @FT_OUTLINE_REVERSE_FILL.
436 * ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS.
437 * ft_outline_high_precision :: See @FT_OUTLINE_HIGH_PRECISION.
438 * ft_outline_single_pass :: See @FT_OUTLINE_SINGLE_PASS.
439 */
440 #define ft_outline_none FT_OUTLINE_NONE
441 #define ft_outline_owner FT_OUTLINE_OWNER
442 #define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
443 #define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
444 #define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
445 #define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
446 #define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
447
448 /* */
449
450 #define FT_CURVE_TAG( flag ) ( flag & 3 )
451
452 #define FT_CURVE_TAG_ON 1
453 #define FT_CURVE_TAG_CONIC 0
454 #define FT_CURVE_TAG_CUBIC 2
455
456 #define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
457 #define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
458
459 #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
460 FT_CURVE_TAG_TOUCH_Y )
461
462 #define FT_Curve_Tag_On FT_CURVE_TAG_ON
463 #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
464 #define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
465 #define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
466 #define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
467
468 /*************************************************************************/
469 /* */
470 /* <FuncType> */
471 /* FT_Outline_MoveToFunc */
472 /* */
473 /* <Description> */
474 /* A function pointer type used to describe the signature of a `move */
475 /* to' function during outline walking/decomposition. */
476 /* */
477 /* A `move to' is emitted to start a new contour in an outline. */
478 /* */
479 /* <Input> */
480 /* to :: A pointer to the target point of the `move to'. */
481 /* */
482 /* user :: A typeless pointer which is passed from the caller of the */
483 /* decomposition function. */
484 /* */
485 /* <Return> */
486 /* Error code. 0 means success. */
487 /* */
488 typedef int
489 (*FT_Outline_MoveToFunc)( const FT_Vector* to,
490 void* user );
491
492 #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
493
494 /*************************************************************************/
495 /* */
496 /* <FuncType> */
497 /* FT_Outline_LineToFunc */
498 /* */
499 /* <Description> */
500 /* A function pointer type used to describe the signature of a `line */
501 /* to' function during outline walking/decomposition. */
502 /* */
503 /* A `line to' is emitted to indicate a segment in the outline. */
504 /* */
505 /* <Input> */
506 /* to :: A pointer to the target point of the `line to'. */
507 /* */
508 /* user :: A typeless pointer which is passed from the caller of the */
509 /* decomposition function. */
510 /* */
511 /* <Return> */
512 /* Error code. 0 means success. */
513 /* */
514 typedef int
515 (*FT_Outline_LineToFunc)( const FT_Vector* to,
516 void* user );
517
518 #define FT_Outline_LineTo_Func FT_Outline_LineToFunc
519
520 /*************************************************************************/
521 /* */
522 /* <FuncType> */
523 /* FT_Outline_ConicToFunc */
524 /* */
525 /* <Description> */
526 /* A function pointer type use to describe the signature of a `conic */
527 /* to' function during outline walking/decomposition. */
528 /* */
529 /* A `conic to' is emitted to indicate a second-order Bézier arc in */
530 /* the outline. */
531 /* */
532 /* <Input> */
533 /* control :: An intermediate control point between the last position */
534 /* and the new target in `to'. */
535 /* */
536 /* to :: A pointer to the target end point of the conic arc. */
537 /* */
538 /* user :: A typeless pointer which is passed from the caller of */
539 /* the decomposition function. */
540 /* */
541 /* <Return> */
542 /* Error code. 0 means success. */
543 /* */
544 typedef int
545 (*FT_Outline_ConicToFunc)( const FT_Vector* control,
546 const FT_Vector* to,
547 void* user );
548
549 #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
550
551 /*************************************************************************/
552 /* */
553 /* <FuncType> */
554 /* FT_Outline_CubicToFunc */
555 /* */
556 /* <Description> */
557 /* A function pointer type used to describe the signature of a `cubic */
558 /* to' function during outline walking/decomposition. */
559 /* */
560 /* A `cubic to' is emitted to indicate a third-order Bézier arc. */
561 /* */
562 /* <Input> */
563 /* control1 :: A pointer to the first Bézier control point. */
564 /* */
565 /* control2 :: A pointer to the second Bézier control point. */
566 /* */
567 /* to :: A pointer to the target end point. */
568 /* */
569 /* user :: A typeless pointer which is passed from the caller of */
570 /* the decomposition function. */
571 /* */
572 /* <Return> */
573 /* Error code. 0 means success. */
574 /* */
575 typedef int
576 (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
577 const FT_Vector* control2,
578 const FT_Vector* to,
579 void* user );
580
581 #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
582
583
584 /*************************************************************************/
585 /* */
586 /* <Struct> */
587 /* FT_Outline_Funcs */
588 /* */
589 /* <Description> */
590 /* A structure to hold various function pointers used during outline */
591 /* decomposition in order to emit segments, conic, and cubic Béziers, */
592 /* as well as `move to' and `close to' operations. */
593 /* */
594 /* <Fields> */
595 /* move_to :: The `move to' emitter. */
596 /* */
597 /* line_to :: The segment emitter. */
598 /* */
599 /* conic_to :: The second-order Bézier arc emitter. */
600 /* */
601 /* cubic_to :: The third-order Bézier arc emitter. */
602 /* */
603 /* shift :: The shift that is applied to coordinates before they */
604 /* are sent to the emitter. */
605 /* */
606 /* delta :: The delta that is applied to coordinates before they */
607 /* are sent to the emitter, but after the shift. */
608 /* */
609 /* <Note> */
610 /* The point coordinates sent to the emitters are the transformed */
611 /* version of the original coordinates (this is important for high */
612 /* accuracy during scan-conversion). The transformation is simple: */
613 /* */
614 /* { */
615 /* x' = (x << shift) - delta */
616 /* y' = (x << shift) - delta */
617 /* } */
618 /* */
619 /* Set the value of `shift' and `delta' to 0 to get the original */
620 /* point coordinates. */
621 /* */
622 typedef struct FT_Outline_Funcs_
623 {
624 FT_Outline_MoveToFunc move_to;
625 FT_Outline_LineToFunc line_to;
626 FT_Outline_ConicToFunc conic_to;
627 FT_Outline_CubicToFunc cubic_to;
628
629 int shift;
630 FT_Pos delta;
631
632 } FT_Outline_Funcs;
633
634
635 /*************************************************************************/
636 /* */
637 /* <Section> */
638 /* basic_types */
639 /* */
640 /*************************************************************************/
641
642
643 /*************************************************************************/
644 /* */
645 /* <Macro> */
646 /* FT_IMAGE_TAG */
647 /* */
648 /* <Description> */
649 /* This macro converts four-letter tags to an unsigned long type. */
650 /* */
651 /* <Note> */
652 /* Since many 16bit compilers don't like 32bit enumerations, you */
653 /* should redefine this macro in case of problems to something like */
654 /* this: */
655 /* */
656 /* { */
657 /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
658 /* } */
659 /* */
660 /* to get a simple enumeration without assigning special numbers. */
661 /* */
662 #ifndef FT_IMAGE_TAG
663 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
664 value = ( ( (unsigned long)_x1 << 24 ) | \
665 ( (unsigned long)_x2 << 16 ) | \
666 ( (unsigned long)_x3 << 8 ) | \
667 (unsigned long)_x4 )
668 #endif /* FT_IMAGE_TAG */
669
670
671 /*************************************************************************/
672 /* */
673 /* <Enum> */
674 /* FT_Glyph_Format */
675 /* */
676 /* <Description> */
677 /* An enumeration type used to describe the format of a given glyph */
678 /* image. Note that this version of FreeType only supports two image */
679 /* formats, even though future font drivers will be able to register */
680 /* their own format. */
681 /* */
682 /* <Values> */
683 /* FT_GLYPH_FORMAT_NONE :: */
684 /* The value 0 is reserved. */
685 /* */
686 /* FT_GLYPH_FORMAT_COMPOSITE :: */
687 /* The glyph image is a composite of several other images. This */
688 /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
689 /* report compound glyphs (like accented characters). */
690 /* */
691 /* FT_GLYPH_FORMAT_BITMAP :: */
692 /* The glyph image is a bitmap, and can be described as an */
693 /* @FT_Bitmap. You generally need to access the `bitmap' field of */
694 /* the @FT_GlyphSlotRec structure to read it. */
695 /* */
696 /* FT_GLYPH_FORMAT_OUTLINE :: */
697 /* The glyph image is a vectorial outline made of line segments */
698 /* and Bézier arcs; it can be described as an @FT_Outline; you */
699 /* generally want to access the `outline' field of the */
700 /* @FT_GlyphSlotRec structure to read it. */
701 /* */
702 /* FT_GLYPH_FORMAT_PLOTTER :: */
703 /* The glyph image is a vectorial path with no inside and outside */
704 /* contours. Some Type 1 fonts, like those in the Hershey family, */
705 /* contain glyphs in this format. These are described as */
706 /* @FT_Outline, but FreeType isn't currently capable of rendering */
707 /* them correctly. */
708 /* */
709 typedef enum FT_Glyph_Format_
710 {
711 FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
712
713 FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
714 FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
715 FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
716 FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
717
718 } FT_Glyph_Format;
719
720
721 /*************************************************************************/
722 /* */
723 /* <Enum> */
724 /* ft_glyph_format_xxx */
725 /* */
726 /* <Description> */
727 /* A list of decprecated constants. Use the corresponding */
728 /* @FT_Glyph_Format values instead. */
729 /* */
730 /* <Values> */
731 /* ft_glyph_format_none :: See @FT_GLYPH_FORMAT_NONE. */
732 /* ft_glyph_format_composite :: See @FT_GLYPH_FORMAT_COMPOSITE. */
733 /* ft_glyph_format_bitmap :: See @FT_GLYPH_FORMAT_BITMAP. */
734 /* ft_glyph_format_outline :: See @FT_GLYPH_FORMAT_OUTLINE. */
735 /* ft_glyph_format_plotter :: See @FT_GLYPH_FORMAT_PLOTTER. */
736 /* */
737 #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
738 #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
739 #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
740 #define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
741 #define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
742
743
744 /*************************************************************************/
745 /*************************************************************************/
746 /*************************************************************************/
747 /***** *****/
748 /***** R A S T E R D E F I N I T I O N S *****/
749 /***** *****/
750 /*************************************************************************/
751 /*************************************************************************/
752 /*************************************************************************/
753
754
755 /*************************************************************************/
756 /* */
757 /* A raster is a scan converter, in charge of rendering an outline into */
758 /* a a bitmap. This section contains the public API for rasters. */
759 /* */
760 /* Note that in FreeType 2, all rasters are now encapsulated within */
761 /* specific modules called `renderers'. See `freetype/ftrender.h' for */
762 /* more details on renderers. */
763 /* */
764 /*************************************************************************/
765
766
767 /*************************************************************************/
768 /* */
769 /* <Section> */
770 /* raster */
771 /* */
772 /* <Title> */
773 /* Scanline Converter */
774 /* */
775 /* <Abstract> */
776 /* How vectorial outlines are converted into bitmaps and pixmaps. */
777 /* */
778 /* <Description> */
779 /* This section contains technical definitions. */
780 /* */
781 /*************************************************************************/
782
783
784 /*************************************************************************/
785 /* */
786 /* <Type> */
787 /* FT_Raster */
788 /* */
789 /* <Description> */
790 /* A handle (pointer) to a raster object. Each object can be used */
791 /* independently to convert an outline into a bitmap or pixmap. */
792 /* */
793 typedef struct FT_RasterRec_* FT_Raster;
794
795
796 /*************************************************************************/
797 /* */
798 /* <Struct> */
799 /* FT_Span */
800 /* */
801 /* <Description> */
802 /* A structure used to model a single span of gray (or black) pixels */
803 /* when rendering a monochrome or anti-aliased bitmap. */
804 /* */
805 /* <Fields> */
806 /* x :: The span's horizontal start position. */
807 /* */
808 /* len :: The span's length in pixels. */
809 /* */
810 /* coverage :: The span color/coverage, ranging from 0 (background) */
811 /* to 255 (foreground). Only used for anti-aliased */
812 /* rendering. */
813 /* */
814 /* <Note> */
815 /* This structure is used by the span drawing callback type named */
816 /* @FT_SpanFunc which takes the y-coordinate of the span as a */
817 /* a parameter. */
818 /* */
819 /* The coverage value is always between 0 and 255. */
820 /* */
821 typedef struct FT_Span_
822 {
823 short x;
824 unsigned short len;
825 unsigned char coverage;
826
827 } FT_Span;
828
829
830 /*************************************************************************/
831 /* */
832 /* <FuncType> */
833 /* FT_SpanFunc */
834 /* */
835 /* <Description> */
836 /* A function used as a call-back by the anti-aliased renderer in */
837 /* order to let client applications draw themselves the gray pixel */
838 /* spans on each scan line. */
839 /* */
840 /* <Input> */
841 /* y :: The scanline's y-coordinate. */
842 /* */
843 /* count :: The number of spans to draw on this scanline. */
844 /* */
845 /* spans :: A table of `count' spans to draw on the scanline. */
846 /* */
847 /* user :: User-supplied data that is passed to the callback. */
848 /* */
849 /* <Note> */
850 /* This callback allows client applications to directly render the */
851 /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
852 /* */
853 /* This can be used to write anti-aliased outlines directly to a */
854 /* given background bitmap, and even perform translucency. */
855 /* */
856 /* Note that the `count' field cannot be greater than a fixed value */
857 /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */
858 /* `ftoption.h'. By default, this value is set to 32, which means */
859 /* that if there are more than 32 spans on a given scanline, the */
860 /* callback is called several times with the same `y' parameter in */
861 /* order to draw all callbacks. */
862 /* */
863 /* Otherwise, the callback is only called once per scan-line, and */
864 /* only for those scanlines that do have `gray' pixels on them. */
865 /* */
866 typedef void
867 (*FT_SpanFunc)( int y,
868 int count,
869 const FT_Span* spans,
870 void* user );
871
872 #define FT_Raster_Span_Func FT_SpanFunc
873
874
875 /*************************************************************************/
876 /* */
877 /* <FuncType> */
878 /* FT_Raster_BitTest_Func */
879 /* */
880 /* <Description> */
881 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
882 /* */
883 /* A function used as a call-back by the monochrome scan-converter */
884 /* to test whether a given target pixel is already set to the drawing */
885 /* `color'. These tests are crucial to implement drop-out control */
886 /* per-se the TrueType spec. */
887 /* */
888 /* <Input> */
889 /* y :: The pixel's y-coordinate. */
890 /* */
891 /* x :: The pixel's x-coordinate. */
892 /* */
893 /* user :: User-supplied data that is passed to the callback. */
894 /* */
895 /* <Return> */
896 /* 1 if the pixel is `set', 0 otherwise. */
897 /* */
898 typedef int
899 (*FT_Raster_BitTest_Func)( int y,
900 int x,
901 void* user );
902
903
904 /*************************************************************************/
905 /* */
906 /* <FuncType> */
907 /* FT_Raster_BitSet_Func */
908 /* */
909 /* <Description> */
910 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
911 /* */
912 /* A function used as a call-back by the monochrome scan-converter */
913 /* to set an individual target pixel. This is crucial to implement */
914 /* drop-out control according to the TrueType specification. */
915 /* */
916 /* <Input> */
917 /* y :: The pixel's y-coordinate. */
918 /* */
919 /* x :: The pixel's x-coordinate. */
920 /* */
921 /* user :: User-supplied data that is passed to the callback. */
922 /* */
923 /* <Return> */
924 /* 1 if the pixel is `set', 0 otherwise. */
925 /* */
926 typedef void
927 (*FT_Raster_BitSet_Func)( int y,
928 int x,
929 void* user );
930
931
932 /*************************************************************************/
933 /* */
934 /* <Enum> */
935 /* FT_RASTER_FLAG_XXX */
936 /* */
937 /* <Description> */
938 /* A list of bit flag constants as used in the `flags' field of a */
939 /* @FT_Raster_Params structure. */
940 /* */
941 /* <Values> */
942 /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
943 /* */
944 /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
945 /* anti-aliased glyph image should be */
946 /* generated. Otherwise, it will be */
947 /* monochrome (1-bit). */
948 /* */
949 /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
950 /* rendering. In this mode, client */
951 /* applications must provide their own span */
952 /* callback. This lets them directly */
953 /* draw or compose over an existing bitmap. */
954 /* If this bit is not set, the target */
955 /* pixmap's buffer _must_ be zeroed before */
956 /* rendering. */
957 /* */
958 /* Note that for now, direct rendering is */
959 /* only possible with anti-aliased glyphs. */
960 /* */
961 /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
962 /* rendering mode. If set, the output will */
963 /* be clipped to a box specified in the */
964 /* `clip_box' field of the */
965 /* @FT_Raster_Params structure. */
966 /* */
967 /* Note that by default, the glyph bitmap */
968 /* is clipped to the target pixmap, except */
969 /* in direct rendering mode where all spans */
970 /* are generated if no clipping box is set. */
971 /* */
972 #define FT_RASTER_FLAG_DEFAULT 0x0
973 #define FT_RASTER_FLAG_AA 0x1
974 #define FT_RASTER_FLAG_DIRECT 0x2
975 #define FT_RASTER_FLAG_CLIP 0x4
976
977 /* deprecated */
978 #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
979 #define ft_raster_flag_aa FT_RASTER_FLAG_AA
980 #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
981 #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
982
983
984 /*************************************************************************/
985 /* */
986 /* <Struct> */
987 /* FT_Raster_Params */
988 /* */
989 /* <Description> */
990 /* A structure to hold the arguments used by a raster's render */
991 /* function. */
992 /* */
993 /* <Fields> */
994 /* target :: The target bitmap. */
995 /* */
996 /* source :: A pointer to the source glyph image (e.g., an */
997 /* @FT_Outline). */
998 /* */
999 /* flags :: The rendering flags. */
1000 /* */
1001 /* gray_spans :: The gray span drawing callback. */
1002 /* */
1003 /* black_spans :: The black span drawing callback. */
1004 /* */
1005 /* bit_test :: The bit test callback. UNIMPLEMENTED! */
1006 /* */
1007 /* bit_set :: The bit set callback. UNIMPLEMENTED! */
1008 /* */
1009 /* user :: User-supplied data that is passed to each drawing */
1010 /* callback. */
1011 /* */
1012 /* clip_box :: An optional clipping box. It is only used in */
1013 /* direct rendering mode. Note that coordinates here */
1014 /* should be expressed in _integer_ pixels (and not in */
1015 /* 26.6 fixed-point units). */
1016 /* */
1017 /* <Note> */
1018 /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */
1019 /* bit flag is set in the `flags' field, otherwise a monochrome */
1020 /* bitmap is generated. */
1021 /* */
1022 /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
1023 /* raster will call the `gray_spans' callback to draw gray pixel */
1024 /* spans, in the case of an aa glyph bitmap, it will call */
1025 /* `black_spans', and `bit_test' and `bit_set' in the case of a */
1026 /* monochrome bitmap. This allows direct composition over a */
1027 /* pre-existing bitmap through user-provided callbacks to perform the */
1028 /* span drawing/composition. */
1029 /* */
1030 /* Note that the `bit_test' and `bit_set' callbacks are required when */
1031 /* rendering a monochrome bitmap, as they are crucial to implement */
1032 /* correct drop-out control as defined in the TrueType specification. */
1033 /* */
1034 typedef struct FT_Raster_Params_
1035 {
1036 const FT_Bitmap* target;
1037 const void* source;
1038 int flags;
1039 FT_SpanFunc gray_spans;
1040 FT_SpanFunc black_spans;
1041 FT_Raster_BitTest_Func bit_test; /* doesn't work! */
1042 FT_Raster_BitSet_Func bit_set; /* doesn't work! */
1043 void* user;
1044 FT_BBox clip_box;
1045
1046 } FT_Raster_Params;
1047
1048
1049 /*************************************************************************/
1050 /* */
1051 /* <FuncType> */
1052 /* FT_Raster_NewFunc */
1053 /* */
1054 /* <Description> */
1055 /* A function used to create a new raster object. */
1056 /* */
1057 /* <Input> */
1058 /* memory :: A handle to the memory allocator. */
1059 /* */
1060 /* <Output> */
1061 /* raster :: A handle to the new raster object. */
1062 /* */
1063 /* <Return> */
1064 /* Error code. 0 means success. */
1065 /* */
1066 /* <Note> */
1067 /* The `memory' parameter is a typeless pointer in order to avoid */
1068 /* un-wanted dependencies on the rest of the FreeType code. In */
1069 /* practice, it is an @FT_Memory object, i.e., a handle to the */
1070 /* standard FreeType memory allocator. However, this field can be */
1071 /* completely ignored by a given raster implementation. */
1072 /* */
1073 typedef int
1074 (*FT_Raster_NewFunc)( void* memory,
1075 FT_Raster* raster );
1076
1077 #define FT_Raster_New_Func FT_Raster_NewFunc
1078
1079 /*************************************************************************/
1080 /* */
1081 /* <FuncType> */
1082 /* FT_Raster_DoneFunc */
1083 /* */
1084 /* <Description> */
1085 /* A function used to destroy a given raster object. */
1086 /* */
1087 /* <Input> */
1088 /* raster :: A handle to the raster object. */
1089 /* */
1090 typedef void
1091 (*FT_Raster_DoneFunc)( FT_Raster raster );
1092
1093 #define FT_Raster_Done_Func FT_Raster_DoneFunc
1094
1095 /*************************************************************************/
1096 /* */
1097 /* <FuncType> */
1098 /* FT_Raster_ResetFunc */
1099 /* */
1100 /* <Description> */
1101 /* FreeType provides an area of memory called the `render pool', */
1102 /* available to all registered rasters. This pool can be freely used */
1103 /* during a given scan-conversion but is shared by all rasters. Its */
1104 /* content is thus transient. */
1105 /* */
1106 /* This function is called each time the render pool changes, or just */
1107 /* after a new raster object is created. */
1108 /* */
1109 /* <Input> */
1110 /* raster :: A handle to the new raster object. */
1111 /* */
1112 /* pool_base :: The address in memory of the render pool. */
1113 /* */
1114 /* pool_size :: The size in bytes of the render pool. */
1115 /* */
1116 /* <Note> */
1117 /* Rasters can ignore the render pool and rely on dynamic memory */
1118 /* allocation if they want to (a handle to the memory allocator is */
1119 /* passed to the raster constructor). However, this is not */
1120 /* recommended for efficiency purposes. */
1121 /* */
1122 typedef void
1123 (*FT_Raster_ResetFunc)( FT_Raster raster,
1124 unsigned char* pool_base,
1125 unsigned long pool_size );
1126
1127 #define FT_Raster_Reset_Func FT_Raster_ResetFunc
1128
1129 /*************************************************************************/
1130 /* */
1131 /* <FuncType> */
1132 /* FT_Raster_SetModeFunc */
1133 /* */
1134 /* <Description> */
1135 /* This function is a generic facility to change modes or attributes */
1136 /* in a given raster. This can be used for debugging purposes, or */
1137 /* simply to allow implementation-specific `features' in a given */
1138 /* raster module. */
1139 /* */
1140 /* <Input> */
1141 /* raster :: A handle to the new raster object. */
1142 /* */
1143 /* mode :: A 4-byte tag used to name the mode or property. */
1144 /* */
1145 /* args :: A pointer to the new mode/property to use. */
1146 /* */
1147 typedef int
1148 (*FT_Raster_SetModeFunc)( FT_Raster raster,
1149 unsigned long mode,
1150 void* args );
1151
1152 #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1153
1154 /*************************************************************************/
1155 /* */
1156 /* <FuncType> */
1157 /* FT_Raster_RenderFunc */
1158 /* */
1159 /* <Description> */
1160 /* Invokes a given raster to scan-convert a given glyph image into a */
1161 /* target bitmap. */
1162 /* */
1163 /* <Input> */
1164 /* raster :: A handle to the raster object. */
1165 /* */
1166 /* params :: A pointer to an @FT_Raster_Params structure used to */
1167 /* store the rendering parameters. */
1168 /* */
1169 /* <Return> */
1170 /* Error code. 0 means success. */
1171 /* */
1172 /* <Note> */
1173 /* The exact format of the source image depends on the raster's glyph */
1174 /* format defined in its @FT_Raster_Funcs structure. It can be an */
1175 /* @FT_Outline or anything else in order to support a large array of */
1176 /* glyph formats. */
1177 /* */
1178 /* Note also that the render function can fail and return a */
1179 /* `FT_Err_Unimplemented_Feature' error code if the raster used does */
1180 /* not support direct composition. */
1181 /* */
1182 /* XXX: For now, the standard raster doesn't support direct */
1183 /* composition but this should change for the final release (see */
1184 /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */
1185 /* for examples of distinct implementations which support direct */
1186 /* composition). */
1187 /* */
1188 typedef int
1189 (*FT_Raster_RenderFunc)( FT_Raster raster,
1190 const FT_Raster_Params* params );
1191
1192 #define FT_Raster_Render_Func FT_Raster_RenderFunc
1193
1194 /*************************************************************************/
1195 /* */
1196 /* <Struct> */
1197 /* FT_Raster_Funcs */
1198 /* */
1199 /* <Description> */
1200 /* A structure used to describe a given raster class to the library. */
1201 /* */
1202 /* <Fields> */
1203 /* glyph_format :: The supported glyph format for this raster. */
1204 /* */
1205 /* raster_new :: The raster constructor. */
1206 /* */
1207 /* raster_reset :: Used to reset the render pool within the raster. */
1208 /* */
1209 /* raster_render :: A function to render a glyph into a given bitmap. */
1210 /* */
1211 /* raster_done :: The raster destructor. */
1212 /* */
1213 typedef struct FT_Raster_Funcs_
1214 {
1215 FT_Glyph_Format glyph_format;
1216 FT_Raster_NewFunc raster_new;
1217 FT_Raster_ResetFunc raster_reset;
1218 FT_Raster_SetModeFunc raster_set_mode;
1219 FT_Raster_RenderFunc raster_render;
1220 FT_Raster_DoneFunc raster_done;
1221
1222 } FT_Raster_Funcs;
1223
1224
1225 /* */
1226
1227
1228 FT_END_HEADER
1229
1230 #endif /* __FTIMAGE_H__ */
1231
1232
1233 /* END */
1234
1235
1236 /* Local Variables: */
1237 /* coding: utf-8 */
1238 /* End: */