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, 2007 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
37FT_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. */
385 /* */
386 /* FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */
387 /* try to detect drop-outs in an outline */
388 /* and correct the glyph bitmap to */
389 /* ensure consistent shape continuity. */
390 /* If set, this flag hints the scan-line */
391 /* converter to ignore such cases. */
392 /* */
393 /* FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */
394 /* scan-line converter should try to */
395 /* convert this outline to bitmaps with */
396 /* the highest possible quality. It is */
397 /* typically set for small character */
398 /* sizes. Note that this is only a */
399 /* hint, that might be completely */
400 /* ignored by a given scan-converter. */
401 /* */
402 /* FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */
403 /* scan-converter to only use a single */
404 /* pass over the outline to render a */
405 /* bitmap glyph image. Normally, it is */
406 /* set for very large character sizes. */
407 /* It is only a hint, that might be */
408 /* completely ignored by a given */
409 /* scan-converter. */
410 /* */
411#define FT_OUTLINE_NONE 0x0
412#define FT_OUTLINE_OWNER 0x1
413#define FT_OUTLINE_EVEN_ODD_FILL 0x2
414#define FT_OUTLINE_REVERSE_FILL 0x4
415#define FT_OUTLINE_IGNORE_DROPOUTS 0x8
416
417#define FT_OUTLINE_HIGH_PRECISION 0x100
418#define FT_OUTLINE_SINGLE_PASS 0x200
419
420
421 /*************************************************************************
422 *
423 * @enum:
424 * ft_outline_flags
425 *
426 * @description:
427 * These constants are deprecated. Please use the corresponding
428 * @FT_OUTLINE_FLAGS values.
429 *
430 * @values:
431 * ft_outline_none :: See @FT_OUTLINE_NONE.
432 * ft_outline_owner :: See @FT_OUTLINE_OWNER.
433 * ft_outline_even_odd_fill :: See @FT_OUTLINE_EVEN_ODD_FILL.
434 * ft_outline_reverse_fill :: See @FT_OUTLINE_REVERSE_FILL.
435 * ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS.
436 * ft_outline_high_precision :: See @FT_OUTLINE_HIGH_PRECISION.
437 * ft_outline_single_pass :: See @FT_OUTLINE_SINGLE_PASS.
438 */
439#define ft_outline_none FT_OUTLINE_NONE
440#define ft_outline_owner FT_OUTLINE_OWNER
441#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
442#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
443#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
444#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
445#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
446
447 /* */
448
449#define FT_CURVE_TAG( flag ) ( flag & 3 )
450
451#define FT_CURVE_TAG_ON 1
452#define FT_CURVE_TAG_CONIC 0
453#define FT_CURVE_TAG_CUBIC 2
454
455#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
456#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
457
458#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
459 FT_CURVE_TAG_TOUCH_Y )
460
461#define FT_Curve_Tag_On FT_CURVE_TAG_ON
462#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
463#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
464#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
465#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
466
467 /*************************************************************************/
468 /* */
469 /* <FuncType> */
470 /* FT_Outline_MoveToFunc */
471 /* */
472 /* <Description> */
473 /* A function pointer type used to describe the signature of a `move */
474 /* to' function during outline walking/decomposition. */
475 /* */
476 /* A `move to' is emitted to start a new contour in an outline. */
477 /* */
478 /* <Input> */
479 /* to :: A pointer to the target point of the `move to'. */
480 /* */
481 /* user :: A typeless pointer which is passed from the caller of the */
482 /* decomposition function. */
483 /* */
484 /* <Return> */
485 /* Error code. 0 means success. */
486 /* */
487 typedef int
488 (*FT_Outline_MoveToFunc)( const FT_Vector* to,
489 void* user );
490
491#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
492
493 /*************************************************************************/
494 /* */
495 /* <FuncType> */
496 /* FT_Outline_LineToFunc */
497 /* */
498 /* <Description> */
499 /* A function pointer type used to describe the signature of a `line */
500 /* to' function during outline walking/decomposition. */
501 /* */
502 /* A `line to' is emitted to indicate a segment in the outline. */
503 /* */
504 /* <Input> */
505 /* to :: A pointer to the target point of the `line to'. */
506 /* */
507 /* user :: A typeless pointer which is passed from the caller of the */
508 /* decomposition function. */
509 /* */
510 /* <Return> */
511 /* Error code. 0 means success. */
512 /* */
513 typedef int
514 (*FT_Outline_LineToFunc)( const FT_Vector* to,
515 void* user );
516
517#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
518
519 /*************************************************************************/
520 /* */
521 /* <FuncType> */
522 /* FT_Outline_ConicToFunc */
523 /* */
524 /* <Description> */
525 /* A function pointer type use to describe the signature of a `conic */
526 /* to' function during outline walking/decomposition. */
527 /* */
528 /* A `conic to' is emitted to indicate a second-order Bézier arc in */
529 /* the outline. */
530 /* */
531 /* <Input> */
532 /* control :: An intermediate control point between the last position */
533 /* and the new target in `to'. */
534 /* */
535 /* to :: A pointer to the target end point of the conic arc. */
536 /* */
537 /* user :: A typeless pointer which is passed from the caller of */
538 /* the decomposition function. */
539 /* */
540 /* <Return> */
541 /* Error code. 0 means success. */
542 /* */
543 typedef int
544 (*FT_Outline_ConicToFunc)( const FT_Vector* control,
545 const FT_Vector* to,
546 void* user );
547
548#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
549
550 /*************************************************************************/
551 /* */
552 /* <FuncType> */
553 /* FT_Outline_CubicToFunc */
554 /* */
555 /* <Description> */
556 /* A function pointer type used to describe the signature of a `cubic */
557 /* to' function during outline walking/decomposition. */
558 /* */
559 /* A `cubic to' is emitted to indicate a third-order Bézier arc. */
560 /* */
561 /* <Input> */
562 /* control1 :: A pointer to the first Bézier control point. */
563 /* */
564 /* control2 :: A pointer to the second Bézier control point. */
565 /* */
566 /* to :: A pointer to the target end point. */
567 /* */
568 /* user :: A typeless pointer which is passed from the caller of */
569 /* the decomposition function. */
570 /* */
571 /* <Return> */
572 /* Error code. 0 means success. */
573 /* */
574 typedef int
575 (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
576 const FT_Vector* control2,
577 const FT_Vector* to,
578 void* user );
579
580#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
581
582
583 /*************************************************************************/
584 /* */
585 /* <Struct> */
586 /* FT_Outline_Funcs */
587 /* */
588 /* <Description> */
589 /* A structure to hold various function pointers used during outline */
590 /* decomposition in order to emit segments, conic, and cubic Béziers, */
591 /* as well as `move to' and `close to' operations. */
592 /* */
593 /* <Fields> */
594 /* move_to :: The `move to' emitter. */
595 /* */
596 /* line_to :: The segment emitter. */
597 /* */
598 /* conic_to :: The second-order Bézier arc emitter. */
599 /* */
600 /* cubic_to :: The third-order Bézier arc emitter. */
601 /* */
602 /* shift :: The shift that is applied to coordinates before they */
603 /* are sent to the emitter. */
604 /* */
605 /* delta :: The delta that is applied to coordinates before they */
606 /* are sent to the emitter, but after the shift. */
607 /* */
608 /* <Note> */
609 /* The point coordinates sent to the emitters are the transformed */
610 /* version of the original coordinates (this is important for high */
611 /* accuracy during scan-conversion). The transformation is simple: */
612 /* */
613 /* { */
614 /* x' = (x << shift) - delta */
615 /* y' = (x << shift) - delta */
616 /* } */
617 /* */
618 /* Set the value of `shift' and `delta' to 0 to get the original */
619 /* point coordinates. */
620 /* */
621 typedef struct FT_Outline_Funcs_
622 {
623 FT_Outline_MoveToFunc move_to;
624 FT_Outline_LineToFunc line_to;
625 FT_Outline_ConicToFunc conic_to;
626 FT_Outline_CubicToFunc cubic_to;
627
628 int shift;
629 FT_Pos delta;
630
631 } FT_Outline_Funcs;
632
633
634 /*************************************************************************/
635 /* */
636 /* <Section> */
637 /* basic_types */
638 /* */
639 /*************************************************************************/
640
641
642 /*************************************************************************/
643 /* */
644 /* <Macro> */
645 /* FT_IMAGE_TAG */
646 /* */
647 /* <Description> */
648 /* This macro converts four-letter tags to an unsigned long type. */
649 /* */
650 /* <Note> */
651 /* Since many 16bit compilers don't like 32bit enumerations, you */
652 /* should redefine this macro in case of problems to something like */
653 /* this: */
654 /* */
655 /* { */
656 /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
657 /* } */
658 /* */
659 /* to get a simple enumeration without assigning special numbers. */
660 /* */
661#ifndef FT_IMAGE_TAG
662#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
663 value = ( ( (unsigned long)_x1 << 24 ) | \
664 ( (unsigned long)_x2 << 16 ) | \
665 ( (unsigned long)_x3 << 8 ) | \
666 (unsigned long)_x4 )
667#endif /* FT_IMAGE_TAG */
668
669
670 /*************************************************************************/
671 /* */
672 /* <Enum> */
673 /* FT_Glyph_Format */
674 /* */
675 /* <Description> */
676 /* An enumeration type used to describe the format of a given glyph */
677 /* image. Note that this version of FreeType only supports two image */
678 /* formats, even though future font drivers will be able to register */
679 /* their own format. */
680 /* */
681 /* <Values> */
682 /* FT_GLYPH_FORMAT_NONE :: */
683 /* The value 0 is reserved. */
684 /* */
685 /* FT_GLYPH_FORMAT_COMPOSITE :: */
686 /* The glyph image is a composite of several other images. This */
687 /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
688 /* report compound glyphs (like accented characters). */
689 /* */
690 /* FT_GLYPH_FORMAT_BITMAP :: */
691 /* The glyph image is a bitmap, and can be described as an */
692 /* @FT_Bitmap. You generally need to access the `bitmap' field of */
693 /* the @FT_GlyphSlotRec structure to read it. */
694 /* */
695 /* FT_GLYPH_FORMAT_OUTLINE :: */
696 /* The glyph image is a vectorial outline made of line segments */
697 /* and Bézier arcs; it can be described as an @FT_Outline; you */
698 /* generally want to access the `outline' field of the */
699 /* @FT_GlyphSlotRec structure to read it. */
700 /* */
701 /* FT_GLYPH_FORMAT_PLOTTER :: */
702 /* The glyph image is a vectorial path with no inside and outside */
703 /* contours. Some Type 1 fonts, like those in the Hershey family, */
704 /* contain glyphs in this format. These are described as */
705 /* @FT_Outline, but FreeType isn't currently capable of rendering */
706 /* them correctly. */
707 /* */
708 typedef enum FT_Glyph_Format_
709 {
710 FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
711
712 FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
713 FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
714 FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
715 FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
716
717 } FT_Glyph_Format;
718
719
720 /*************************************************************************/
721 /* */
722 /* <Enum> */
723 /* ft_glyph_format_xxx */
724 /* */
725 /* <Description> */
726 /* A list of deprecated constants. Use the corresponding */
727 /* @FT_Glyph_Format values instead. */
728 /* */
729 /* <Values> */
730 /* ft_glyph_format_none :: See @FT_GLYPH_FORMAT_NONE. */
731 /* ft_glyph_format_composite :: See @FT_GLYPH_FORMAT_COMPOSITE. */
732 /* ft_glyph_format_bitmap :: See @FT_GLYPH_FORMAT_BITMAP. */
733 /* ft_glyph_format_outline :: See @FT_GLYPH_FORMAT_OUTLINE. */
734 /* ft_glyph_format_plotter :: See @FT_GLYPH_FORMAT_PLOTTER. */
735 /* */
736#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
737#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
738#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
739#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
740#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
741
742
743 /*************************************************************************/
744 /*************************************************************************/
745 /*************************************************************************/
746 /***** *****/
747 /***** R A S T E R D E F I N I T I O N S *****/
748 /***** *****/
749 /*************************************************************************/
750 /*************************************************************************/
751 /*************************************************************************/
752
753
754 /*************************************************************************/
755 /* */
756 /* A raster is a scan converter, in charge of rendering an outline into */
757 /* a a bitmap. This section contains the public API for rasters. */
758 /* */
759 /* Note that in FreeType 2, all rasters are now encapsulated within */
760 /* specific modules called `renderers'. See `freetype/ftrender.h' for */
761 /* more details on renderers. */
762 /* */
763 /*************************************************************************/
764
765
766 /*************************************************************************/
767 /* */
768 /* <Section> */
769 /* raster */
770 /* */
771 /* <Title> */
772 /* Scanline Converter */
773 /* */
774 /* <Abstract> */
775 /* How vectorial outlines are converted into bitmaps and pixmaps. */
776 /* */
777 /* <Description> */
778 /* This section contains technical definitions. */
779 /* */
780 /*************************************************************************/
781
782
783 /*************************************************************************/
784 /* */
785 /* <Type> */
786 /* FT_Raster */
787 /* */
788 /* <Description> */
789 /* A handle (pointer) to a raster object. Each object can be used */
790 /* independently to convert an outline into a bitmap or pixmap. */
791 /* */
792 typedef struct FT_RasterRec_* FT_Raster;
793
794
795 /*************************************************************************/
796 /* */
797 /* <Struct> */
798 /* FT_Span */
799 /* */
800 /* <Description> */
801 /* A structure used to model a single span of gray (or black) pixels */
802 /* when rendering a monochrome or anti-aliased bitmap. */
803 /* */
804 /* <Fields> */
805 /* x :: The span's horizontal start position. */
806 /* */
807 /* len :: The span's length in pixels. */
808 /* */
809 /* coverage :: The span color/coverage, ranging from 0 (background) */
810 /* to 255 (foreground). Only used for anti-aliased */
811 /* rendering. */
812 /* */
813 /* <Note> */
814 /* This structure is used by the span drawing callback type named */
815 /* @FT_SpanFunc which takes the y-coordinate of the span as a */
816 /* a parameter. */
817 /* */
818 /* The coverage value is always between 0 and 255. */
819 /* */
820 typedef struct FT_Span_
821 {
822 short x;
823 unsigned short len;
824 unsigned char coverage;
825
826 } FT_Span;
827
828
829 /*************************************************************************/
830 /* */
831 /* <FuncType> */
832 /* FT_SpanFunc */
833 /* */
834 /* <Description> */
835 /* A function used as a call-back by the anti-aliased renderer in */
836 /* order to let client applications draw themselves the gray pixel */
837 /* spans on each scan line. */
838 /* */
839 /* <Input> */
840 /* y :: The scanline's y-coordinate. */
841 /* */
842 /* count :: The number of spans to draw on this scanline. */
843 /* */
844 /* spans :: A table of `count' spans to draw on the scanline. */
845 /* */
846 /* user :: User-supplied data that is passed to the callback. */
847 /* */
848 /* <Note> */
849 /* This callback allows client applications to directly render the */
850 /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
851 /* */
852 /* This can be used to write anti-aliased outlines directly to a */
853 /* given background bitmap, and even perform translucency. */
854 /* */
855 /* Note that the `count' field cannot be greater than a fixed value */
856 /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */
857 /* `ftoption.h'. By default, this value is set to 32, which means */
858 /* that if there are more than 32 spans on a given scanline, the */
859 /* callback is called several times with the same `y' parameter in */
860 /* order to draw all callbacks. */
861 /* */
862 /* Otherwise, the callback is only called once per scan-line, and */
863 /* only for those scanlines that do have `gray' pixels on them. */
864 /* */
865 typedef void
866 (*FT_SpanFunc)( int y,
867 int count,
868 const FT_Span* spans,
869 void* user );
870
871#define FT_Raster_Span_Func FT_SpanFunc
872
873
874 /*************************************************************************/
875 /* */
876 /* <FuncType> */
877 /* FT_Raster_BitTest_Func */
878 /* */
879 /* <Description> */
880 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
881 /* */
882 /* A function used as a call-back by the monochrome scan-converter */
883 /* to test whether a given target pixel is already set to the drawing */
884 /* `color'. These tests are crucial to implement drop-out control */
885 /* per-se the TrueType spec. */
886 /* */
887 /* <Input> */
888 /* y :: The pixel's y-coordinate. */
889 /* */
890 /* x :: The pixel's x-coordinate. */
891 /* */
892 /* user :: User-supplied data that is passed to the callback. */
893 /* */
894 /* <Return> */
895 /* 1 if the pixel is `set', 0 otherwise. */
896 /* */
897 typedef int
898 (*FT_Raster_BitTest_Func)( int y,
899 int x,
900 void* user );
901
902
903 /*************************************************************************/
904 /* */
905 /* <FuncType> */
906 /* FT_Raster_BitSet_Func */
907 /* */
908 /* <Description> */
909 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
910 /* */
911 /* A function used as a call-back by the monochrome scan-converter */
912 /* to set an individual target pixel. This is crucial to implement */
913 /* drop-out control according to the TrueType specification. */
914 /* */
915 /* <Input> */
916 /* y :: The pixel's y-coordinate. */
917 /* */
918 /* x :: The pixel's x-coordinate. */
919 /* */
920 /* user :: User-supplied data that is passed to the callback. */
921 /* */
922 /* <Return> */
923 /* 1 if the pixel is `set', 0 otherwise. */
924 /* */
925 typedef void
926 (*FT_Raster_BitSet_Func)( int y,
927 int x,
928 void* user );
929
930
931 /*************************************************************************/
932 /* */
933 /* <Enum> */
934 /* FT_RASTER_FLAG_XXX */
935 /* */
936 /* <Description> */
937 /* A list of bit flag constants as used in the `flags' field of a */
938 /* @FT_Raster_Params structure. */
939 /* */
940 /* <Values> */
941 /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
942 /* */
943 /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
944 /* anti-aliased glyph image should be */
945 /* generated. Otherwise, it will be */
946 /* monochrome (1-bit). */
947 /* */
948 /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
949 /* rendering. In this mode, client */
950 /* applications must provide their own span */
951 /* callback. This lets them directly */
952 /* draw or compose over an existing bitmap. */
953 /* If this bit is not set, the target */
954 /* pixmap's buffer _must_ be zeroed before */
955 /* rendering. */
956 /* */
957 /* Note that for now, direct rendering is */
958 /* only possible with anti-aliased glyphs. */
959 /* */
960 /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
961 /* rendering mode. If set, the output will */
962 /* be clipped to a box specified in the */
963 /* `clip_box' field of the */
964 /* @FT_Raster_Params structure. */
965 /* */
966 /* Note that by default, the glyph bitmap */
967 /* is clipped to the target pixmap, except */
968 /* in direct rendering mode where all spans */
969 /* are generated if no clipping box is set. */
970 /* */
971#define FT_RASTER_FLAG_DEFAULT 0x0
972#define FT_RASTER_FLAG_AA 0x1
973#define FT_RASTER_FLAG_DIRECT 0x2
974#define FT_RASTER_FLAG_CLIP 0x4
975
976 /* deprecated */
977#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
978#define ft_raster_flag_aa FT_RASTER_FLAG_AA
979#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
980#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
981
982
983 /*************************************************************************/
984 /* */
985 /* <Struct> */
986 /* FT_Raster_Params */
987 /* */
988 /* <Description> */
989 /* A structure to hold the arguments used by a raster's render */
990 /* function. */
991 /* */
992 /* <Fields> */
993 /* target :: The target bitmap. */
994 /* */
995 /* source :: A pointer to the source glyph image (e.g., an */
996 /* @FT_Outline). */
997 /* */
998 /* flags :: The rendering flags. */
999 /* */
1000 /* gray_spans :: The gray span drawing callback. */
1001 /* */
1002 /* black_spans :: The black span drawing callback. */
1003 /* */
1004 /* bit_test :: The bit test callback. UNIMPLEMENTED! */
1005 /* */
1006 /* bit_set :: The bit set callback. UNIMPLEMENTED! */
1007 /* */
1008 /* user :: User-supplied data that is passed to each drawing */
1009 /* callback. */
1010 /* */
1011 /* clip_box :: An optional clipping box. It is only used in */
1012 /* direct rendering mode. Note that coordinates here */
1013 /* should be expressed in _integer_ pixels (and not in */
1014 /* 26.6 fixed-point units). */
1015 /* */
1016 /* <Note> */
1017 /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */
1018 /* bit flag is set in the `flags' field, otherwise a monochrome */
1019 /* bitmap is generated. */
1020 /* */
1021 /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
1022 /* raster will call the `gray_spans' callback to draw gray pixel */
1023 /* spans, in the case of an aa glyph bitmap, it will call */
1024 /* `black_spans', and `bit_test' and `bit_set' in the case of a */
1025 /* monochrome bitmap. This allows direct composition over a */
1026 /* pre-existing bitmap through user-provided callbacks to perform the */
1027 /* span drawing/composition. */
1028 /* */
1029 /* Note that the `bit_test' and `bit_set' callbacks are required when */
1030 /* rendering a monochrome bitmap, as they are crucial to implement */
1031 /* correct drop-out control as defined in the TrueType specification. */
1032 /* */
1033 typedef struct FT_Raster_Params_
1034 {
1035 const FT_Bitmap* target;
1036 const void* source;
1037 int flags;
1038 FT_SpanFunc gray_spans;
1039 FT_SpanFunc black_spans;
1040 FT_Raster_BitTest_Func bit_test; /* doesn't work! */
1041 FT_Raster_BitSet_Func bit_set; /* doesn't work! */
1042 void* user;
1043 FT_BBox clip_box;
1044
1045 } FT_Raster_Params;
1046
1047
1048 /*************************************************************************/
1049 /* */
1050 /* <FuncType> */
1051 /* FT_Raster_NewFunc */
1052 /* */
1053 /* <Description> */
1054 /* A function used to create a new raster object. */
1055 /* */
1056 /* <Input> */
1057 /* memory :: A handle to the memory allocator. */
1058 /* */
1059 /* <Output> */
1060 /* raster :: A handle to the new raster object. */
1061 /* */
1062 /* <Return> */
1063 /* Error code. 0 means success. */
1064 /* */
1065 /* <Note> */
1066 /* The `memory' parameter is a typeless pointer in order to avoid */
1067 /* un-wanted dependencies on the rest of the FreeType code. In */
1068 /* practice, it is an @FT_Memory object, i.e., a handle to the */
1069 /* standard FreeType memory allocator. However, this field can be */
1070 /* completely ignored by a given raster implementation. */
1071 /* */
1072 typedef int
1073 (*FT_Raster_NewFunc)( void* memory,
1074 FT_Raster* raster );
1075
1076#define FT_Raster_New_Func FT_Raster_NewFunc
1077
1078 /*************************************************************************/
1079 /* */
1080 /* <FuncType> */
1081 /* FT_Raster_DoneFunc */
1082 /* */
1083 /* <Description> */
1084 /* A function used to destroy a given raster object. */
1085 /* */
1086 /* <Input> */
1087 /* raster :: A handle to the raster object. */
1088 /* */
1089 typedef void
1090 (*FT_Raster_DoneFunc)( FT_Raster raster );
1091
1092#define FT_Raster_Done_Func FT_Raster_DoneFunc
1093
1094 /*************************************************************************/
1095 /* */
1096 /* <FuncType> */
1097 /* FT_Raster_ResetFunc */
1098 /* */
1099 /* <Description> */
1100 /* FreeType provides an area of memory called the `render pool', */
1101 /* available to all registered rasters. This pool can be freely used */
1102 /* during a given scan-conversion but is shared by all rasters. Its */
1103 /* content is thus transient. */
1104 /* */
1105 /* This function is called each time the render pool changes, or just */
1106 /* after a new raster object is created. */
1107 /* */
1108 /* <Input> */
1109 /* raster :: A handle to the new raster object. */
1110 /* */
1111 /* pool_base :: The address in memory of the render pool. */
1112 /* */
1113 /* pool_size :: The size in bytes of the render pool. */
1114 /* */
1115 /* <Note> */
1116 /* Rasters can ignore the render pool and rely on dynamic memory */
1117 /* allocation if they want to (a handle to the memory allocator is */
1118 /* passed to the raster constructor). However, this is not */
1119 /* recommended for efficiency purposes. */
1120 /* */
1121 typedef void
1122 (*FT_Raster_ResetFunc)( FT_Raster raster,
1123 unsigned char* pool_base,
1124 unsigned long pool_size );
1125
1126#define FT_Raster_Reset_Func FT_Raster_ResetFunc
1127
1128 /*************************************************************************/
1129 /* */
1130 /* <FuncType> */
1131 /* FT_Raster_SetModeFunc */
1132 /* */
1133 /* <Description> */
1134 /* This function is a generic facility to change modes or attributes */
1135 /* in a given raster. This can be used for debugging purposes, or */
1136 /* simply to allow implementation-specific `features' in a given */
1137 /* raster module. */
1138 /* */
1139 /* <Input> */
1140 /* raster :: A handle to the new raster object. */
1141 /* */
1142 /* mode :: A 4-byte tag used to name the mode or property. */
1143 /* */
1144 /* args :: A pointer to the new mode/property to use. */
1145 /* */
1146 typedef int
1147 (*FT_Raster_SetModeFunc)( FT_Raster raster,
1148 unsigned long mode,
1149 void* args );
1150
1151#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1152
1153 /*************************************************************************/
1154 /* */
1155 /* <FuncType> */
1156 /* FT_Raster_RenderFunc */
1157 /* */
1158 /* <Description> */
1159 /* Invokes a given raster to scan-convert a given glyph image into a */
1160 /* target bitmap. */
1161 /* */
1162 /* <Input> */
1163 /* raster :: A handle to the raster object. */
1164 /* */
1165 /* params :: A pointer to an @FT_Raster_Params structure used to */
1166 /* store the rendering parameters. */
1167 /* */
1168 /* <Return> */
1169 /* Error code. 0 means success. */
1170 /* */
1171 /* <Note> */
1172 /* The exact format of the source image depends on the raster's glyph */
1173 /* format defined in its @FT_Raster_Funcs structure. It can be an */
1174 /* @FT_Outline or anything else in order to support a large array of */
1175 /* glyph formats. */
1176 /* */
1177 /* Note also that the render function can fail and return a */
1178 /* `FT_Err_Unimplemented_Feature' error code if the raster used does */
1179 /* not support direct composition. */
1180 /* */
1181 /* XXX: For now, the standard raster doesn't support direct */
1182 /* composition but this should change for the final release (see */
1183 /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */
1184 /* for examples of distinct implementations which support direct */
1185 /* composition). */
1186 /* */
1187 typedef int
1188 (*FT_Raster_RenderFunc)( FT_Raster raster,
1189 const FT_Raster_Params* params );
1190
1191#define FT_Raster_Render_Func FT_Raster_RenderFunc
1192
1193 /*************************************************************************/
1194 /* */
1195 /* <Struct> */
1196 /* FT_Raster_Funcs */
1197 /* */
1198 /* <Description> */
1199 /* A structure used to describe a given raster class to the library. */
1200 /* */
1201 /* <Fields> */
1202 /* glyph_format :: The supported glyph format for this raster. */
1203 /* */
1204 /* raster_new :: The raster constructor. */
1205 /* */
1206 /* raster_reset :: Used to reset the render pool within the raster. */
1207 /* */
1208 /* raster_render :: A function to render a glyph into a given bitmap. */
1209 /* */
1210 /* raster_done :: The raster destructor. */
1211 /* */
1212 typedef struct FT_Raster_Funcs_
1213 {
1214 FT_Glyph_Format glyph_format;
1215 FT_Raster_NewFunc raster_new;
1216 FT_Raster_ResetFunc raster_reset;
1217 FT_Raster_SetModeFunc raster_set_mode;
1218 FT_Raster_RenderFunc raster_render;
1219 FT_Raster_DoneFunc raster_done;
1220
1221 } FT_Raster_Funcs;
1222
1223
1224 /* */
1225
1226
1227FT_END_HEADER
1228
1229#endif /* __FTIMAGE_H__ */
1230
1231
1232/* END */
1233
1234
1235/* Local Variables: */
1236/* coding: utf-8 */
1237/* End: */
1238