1 /***************************************************************************/
5 /* FreeType glyph image formats and default raster interface */
8 /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
17 /***************************************************************************/
19 /*************************************************************************/
21 /* Note: A `raster' is simply a scan-line converter, used to render */
22 /* FT_Outlines into FT_Bitmaps. */
24 /*************************************************************************/
31 /* _STANDALONE_ is from ftgrays.c */
40 /*************************************************************************/
45 /*************************************************************************/
48 /*************************************************************************/
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. */
59 typedef signed long FT_Pos;
62 /*************************************************************************/
68 /* A simple structure used to store a 2D vector; coordinates are of */
69 /* the FT_Pos type. */
72 /* x :: The horizontal coordinate. */
73 /* y :: The vertical coordinate. */
75 typedef struct FT_Vector_
83 /*************************************************************************/
89 /* A structure used to hold an outline's bounding box, i.e., the */
90 /* coordinates of its extrema in the horizontal and vertical */
94 /* xMin :: The horizontal minimum (left-most). */
96 /* yMin :: The vertical minimum (bottom-most). */
98 /* xMax :: The horizontal maximum (right-most). */
100 /* yMax :: The vertical maximum (top-most). */
102 typedef struct FT_BBox_
110 /*************************************************************************/
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 */
121 /* FT_PIXEL_MODE_NONE :: */
122 /* Value 0 is reserved. */
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. */
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). */
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. */
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. */
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's width is */
148 /* three times wider than the original glyph image. See also */
149 /* @FT_RENDER_MODE_LCD. */
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's */
154 /* height is three times taller than the original glyph image. */
155 /* See also @FT_RENDER_MODE_LCD_V. */
157 typedef enum FT_Pixel_Mode_
159 FT_PIXEL_MODE_NONE = 0,
167 FT_PIXEL_MODE_MAX /* do not remove */
172 /*************************************************************************/
175 /* ft_pixel_mode_xxx */
178 /* A list of deprecated constants. Use the corresponding */
179 /* @FT_Pixel_Mode values instead. */
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 */
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
198 /*************************************************************************/
201 /* FT_Palette_Mode */
204 /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
206 /* An enumeration type used to describe the format of a bitmap */
207 /* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */
210 /* ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */
213 /* ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */
217 /* As ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */
218 /* FreeType, these types are not handled by the library itself. */
220 typedef enum FT_Palette_Mode_
222 ft_palette_mode_rgb = 0,
223 ft_palette_mode_rgba,
225 ft_palettte_mode_max /* do not remove */
234 /*************************************************************************/
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. */
245 /* rows :: The number of bitmap rows. */
247 /* width :: The number of pixels in bitmap row. */
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. */
256 /* buffer :: A typeless pointer to the bitmap buffer. This */
257 /* value should be aligned on 32-bit boundaries in */
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. */
264 /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
265 /* See @FT_Pixel_Mode for possible values. */
267 /* palette_mode :: This field is intended for paletted pixel modes; */
268 /* it indicates how the palette is stored. Not */
269 /* used currently. */
271 /* palette :: A typeless pointer to the bitmap palette; this */
272 /* field is intended for paletted pixel modes. Not */
273 /* used currently. */
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. */
280 typedef struct FT_Bitmap_
285 unsigned char* buffer;
294 /*************************************************************************/
297 /* outline_processing */
299 /*************************************************************************/
302 /*************************************************************************/
308 /* This structure is used to describe an outline to the scan-line */
312 /* n_contours :: The number of contours in the outline. */
314 /* n_points :: The number of points in the outline. */
316 /* points :: A pointer to an array of `n_points' FT_Vector */
317 /* elements, giving the outline's point coordinates. */
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 Bezier control */
322 /* point, while it is `on' when set. */
324 /* Bit 1 is meaningful for `off' points only. If set, */
325 /* it indicates a third-order Bezier arc control point; */
326 /* and a second-order control point if unset. */
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. */
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. */
338 typedef struct FT_Outline_
340 short n_contours; /* number of contours in glyph */
341 short n_points; /* number of points in the glyph */
343 FT_Vector* points; /* the outline's points */
344 char* tags; /* the points flags */
345 short* contours; /* the contour end points */
347 int flags; /* outline masks */
352 /*************************************************************************/
355 /* FT_OUTLINE_FLAGS */
358 /* A list of bit-field constants use for the flags in an outline's */
362 /* FT_OUTLINE_NONE :: Value 0 is reserved. */
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 */
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). */
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. */
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. */
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. */
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. */
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
418 #define FT_OUTLINE_HIGH_PRECISION 0x100
419 #define FT_OUTLINE_SINGLE_PASS 0x200
422 /*************************************************************************
428 * These constants are deprecated. Please use the corresponding
429 * @FT_OUTLINE_FLAGS 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.
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
450 #define FT_CURVE_TAG( flag ) ( flag & 3 )
452 #define FT_CURVE_TAG_ON 1
453 #define FT_CURVE_TAG_CONIC 0
454 #define FT_CURVE_TAG_CUBIC 2
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 */
459 #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
460 FT_CURVE_TAG_TOUCH_Y )
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
468 /*************************************************************************/
471 /* FT_Outline_MoveToFunc */
474 /* A function pointer type used to describe the signature of a `move */
475 /* to' function during outline walking/decomposition. */
477 /* A `move to' is emitted to start a new contour in an outline. */
480 /* to :: A pointer to the target point of the `move to'. */
482 /* user :: A typeless pointer which is passed from the caller of the */
483 /* decomposition function. */
486 /* Error code. 0 means success. */
489 (*FT_Outline_MoveToFunc)( FT_Vector* to,
492 #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
494 /*************************************************************************/
497 /* FT_Outline_LineToFunc */
500 /* A function pointer type used to describe the signature of a `line */
501 /* to' function during outline walking/decomposition. */
503 /* A `line to' is emitted to indicate a segment in the outline. */
506 /* to :: A pointer to the target point of the `line to'. */
508 /* user :: A typeless pointer which is passed from the caller of the */
509 /* decomposition function. */
512 /* Error code. 0 means success. */
515 (*FT_Outline_LineToFunc)( FT_Vector* to,
518 #define FT_Outline_LineTo_Func FT_Outline_LineToFunc
520 /*************************************************************************/
523 /* FT_Outline_ConicToFunc */
526 /* A function pointer type use to describe the signature of a `conic */
527 /* to' function during outline walking/decomposition. */
529 /* A `conic to' is emitted to indicate a second-order Bezier arc in */
533 /* control :: An intermediate control point between the last position */
534 /* and the new target in `to'. */
536 /* to :: A pointer to the target end point of the conic arc. */
538 /* user :: A typeless pointer which is passed from the caller of */
539 /* the decomposition function. */
542 /* Error code. 0 means success. */
545 (*FT_Outline_ConicToFunc)( FT_Vector* control,
549 #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
551 /*************************************************************************/
554 /* FT_Outline_CubicToFunc */
557 /* A function pointer type used to describe the signature of a `cubic */
558 /* to' function during outline walking/decomposition. */
560 /* A `cubic to' is emitted to indicate a third-order Bezier arc. */
563 /* control1 :: A pointer to the first Bezier control point. */
565 /* control2 :: A pointer to the second Bezier control point. */
567 /* to :: A pointer to the target end point. */
569 /* user :: A typeless pointer which is passed from the caller of */
570 /* the decomposition function. */
573 /* Error code. 0 means success. */
576 (*FT_Outline_CubicToFunc)( FT_Vector* control1,
581 #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
584 /*************************************************************************/
587 /* FT_Outline_Funcs */
590 /* A structure to hold various function pointers used during outline */
591 /* decomposition in order to emit segments, conic, and cubic Beziers, */
592 /* as well as `move to' and `close to' operations. */
595 /* move_to :: The `move to' emitter. */
597 /* line_to :: The segment emitter. */
599 /* conic_to :: The second-order Bezier arc emitter. */
601 /* cubic_to :: The third-order Bezier arc emitter. */
603 /* shift :: The shift that is applied to coordinates before they */
604 /* are sent to the emitter. */
606 /* delta :: The delta that is applied to coordinates before they */
607 /* are sent to the emitter, but after the shift. */
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: */
614 /* x' = (x << shift) - delta */
615 /* y' = (x << shift) - delta */
617 /* Set the value of `shift' and `delta' to 0 to get the original */
618 /* point coordinates. */
620 typedef struct FT_Outline_Funcs_
622 FT_Outline_MoveToFunc move_to;
623 FT_Outline_LineToFunc line_to;
624 FT_Outline_ConicToFunc conic_to;
625 FT_Outline_CubicToFunc cubic_to;
633 /*************************************************************************/
638 /*************************************************************************/
641 /*************************************************************************/
647 /* This macro converts four letter tags into an unsigned long. */
650 /* Since many 16bit compilers don't like 32bit enumerations, you */
651 /* should redefine this macro in case of problems to something like */
654 /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
656 /* to get a simple enumeration without assigning special numbers. */
659 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
660 value = ( ( (unsigned long)_x1 << 24 ) | \
661 ( (unsigned long)_x2 << 16 ) | \
662 ( (unsigned long)_x3 << 8 ) | \
664 #endif /* FT_IMAGE_TAG */
667 /*************************************************************************/
670 /* FT_Glyph_Format */
673 /* An enumeration type used to describe the format of a given glyph */
674 /* image. Note that this version of FreeType only supports two image */
675 /* formats, even though future font drivers will be able to register */
676 /* their own format. */
679 /* FT_GLYPH_FORMAT_NONE :: */
680 /* The value 0 is reserved and does describe a glyph format. */
682 /* FT_GLYPH_FORMAT_COMPOSITE :: */
683 /* The glyph image is a composite of several other images. This */
684 /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
685 /* report compound glyphs (like accented characters). */
687 /* FT_GLYPH_FORMAT_BITMAP :: */
688 /* The glyph image is a bitmap, and can be described as an */
689 /* @FT_Bitmap. You generally need to access the `bitmap' field of */
690 /* the @FT_GlyphSlotRec structure to read it. */
692 /* FT_GLYPH_FORMAT_OUTLINE :: */
693 /* The glyph image is a vertorial outline made of line segments */
694 /* and Bezier arcs; it can be described as an @FT_Outline; you */
695 /* generally want to access the `outline' field of the */
696 /* @FT_GlyphSlotRec structure to read it. */
698 /* FT_GLYPH_FORMAT_PLOTTER :: */
699 /* The glyph image is a vectorial path with no inside/outside */
700 /* contours. Some Type 1 fonts, like those in the Hershey family, */
701 /* contain glyphs in this format. These are described as */
702 /* @FT_Outline, but FreeType isn't currently capable of rendering */
703 /* them correctly. */
705 typedef enum FT_Glyph_Format_
707 FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
709 FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
710 FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
711 FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
712 FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
717 /*************************************************************************/
720 /* ft_glyph_format_xxx */
723 /* A list of decprecated constants. Use the corresponding */
724 /* @FT_Glyph_Format values instead. */
727 /* ft_glyph_format_none :: see @FT_GLYPH_FORMAT_NONE */
728 /* ft_glyph_format_composite :: see @FT_GLYPH_FORMAT_COMPOSITE */
729 /* ft_glyph_format_bitmap :: see @FT_GLYPH_FORMAT_BITMAP */
730 /* ft_glyph_format_outline :: see @FT_GLYPH_FORMAT_OUTLINE */
731 /* ft_glyph_format_plotter :: see @FT_GLYPH_FORMAT_PLOTTER */
733 #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
734 #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
735 #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
736 #define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
737 #define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
740 /*************************************************************************/
741 /*************************************************************************/
742 /*************************************************************************/
744 /***** R A S T E R D E F I N I T I O N S *****/
746 /*************************************************************************/
747 /*************************************************************************/
748 /*************************************************************************/
751 /*************************************************************************/
753 /* A raster is a scan converter, in charge of rendering an outline into */
754 /* a a bitmap. This section contains the public API for rasters. */
756 /* Note that in FreeType 2, all rasters are now encapsulated within */
757 /* specific modules called `renderers'. See `freetype/ftrender.h' for */
758 /* more details on renderers. */
760 /*************************************************************************/
763 /*************************************************************************/
769 /* Scanline Converter */
772 /* How vectorial outlines are converted into bitmaps and pixmaps. */
775 /* This section contains technical definitions. */
777 /*************************************************************************/
780 /*************************************************************************/
786 /* A handle (pointer) to a raster object. Each object can be used */
787 /* independently to convert an outline into a bitmap or pixmap. */
789 typedef struct FT_RasterRec_* FT_Raster;
792 /*************************************************************************/
798 /* A structure used to model a single span of gray (or black) pixels */
799 /* when rendering a monochrome or anti-aliased bitmap. */
802 /* x :: The span's horizontal start position. */
804 /* len :: The span's length in pixels. */
806 /* coverage :: The span color/coverage, ranging from 0 (background) */
807 /* to 255 (foreground). Only used for anti-aliased */
811 /* This structure is used by the span drawing callback type named */
812 /* FT_SpanFunc which takes the y-coordinate of the span as a */
815 /* The coverage value is always between 0 and 255, even if the number */
816 /* of gray levels have been set through FT_Set_Gray_Levels(). */
818 typedef struct FT_Span_
822 unsigned char coverage;
827 /*************************************************************************/
833 /* A function used as a call-back by the anti-aliased renderer in */
834 /* order to let client applications draw themselves the gray pixel */
835 /* spans on each scan line. */
838 /* y :: The scanline's y-coordinate. */
840 /* count :: The number of spans to draw on this scanline. */
842 /* spans :: A table of `count' spans to draw on the scanline. */
844 /* user :: User-supplied data that is passed to the callback. */
847 /* This callback allows client applications to directly render the */
848 /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
850 /* This can be used to write anti-aliased outlines directly to a */
851 /* given background bitmap, and even perform translucency. */
853 /* Note that the `count' field cannot be greater than a fixed value */
854 /* defined by the FT_MAX_GRAY_SPANS configuration macro in */
855 /* ftoption.h. By default, this value is set to 32, which means that */
856 /* if there are more than 32 spans on a given scanline, the callback */
857 /* will be called several times with the same `y' parameter in order */
858 /* to draw all callbacks. */
860 /* Otherwise, the callback is only called once per scan-line, and */
861 /* only for those scanlines that do have `gray' pixels on them. */
864 (*FT_SpanFunc)( int y,
869 #define FT_Raster_Span_Func FT_SpanFunc
872 /*************************************************************************/
875 /* FT_Raster_BitTest_Func */
878 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
880 /* A function used as a call-back by the monochrome scan-converter */
881 /* to test whether a given target pixel is already set to the drawing */
882 /* `color'. These tests are crucial to implement drop-out control */
883 /* per-se the TrueType spec. */
886 /* y :: The pixel's y-coordinate. */
888 /* x :: The pixel's x-coordinate. */
890 /* user :: User-supplied data that is passed to the callback. */
893 /* 1 if the pixel is `set', 0 otherwise. */
896 (*FT_Raster_BitTest_Func)( int y,
901 /*************************************************************************/
904 /* FT_Raster_BitSet_Func */
907 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
909 /* A function used as a call-back by the monochrome scan-converter */
910 /* to set an individual target pixel. This is crucial to implement */
911 /* drop-out control according to the TrueType specification. */
914 /* y :: The pixel's y-coordinate. */
916 /* x :: The pixel's x-coordinate. */
918 /* user :: User-supplied data that is passed to the callback. */
921 /* 1 if the pixel is `set', 0 otherwise. */
924 (*FT_Raster_BitSet_Func)( int y,
929 /*************************************************************************/
932 /* FT_RASTER_FLAG_XXX */
935 /* A list of bit flag constants as used in the `flags' field of a */
936 /* @FT_Raster_Params structure. */
939 /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
941 /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
942 /* anti-aliased glyph image should be */
943 /* generated. Otherwise, it will be */
944 /* monochrome (1-bit). */
946 /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
947 /* rendering. In this mode, client */
948 /* applications must provide their own span */
949 /* callback. This lets them directly */
950 /* draw or compose over an existing bitmap. */
951 /* If this bit is not set, the target */
952 /* pixmap's buffer _must_ be zeroed before */
955 /* Note that for now, direct rendering is */
956 /* only possible with anti-aliased glyphs. */
958 /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
959 /* rendering mode. If set, the output will */
960 /* be clipped to a box specified in the */
961 /* "clip_box" field of the FT_Raster_Params */
964 /* Note that by default, the glyph bitmap */
965 /* is clipped to the target pixmap, except */
966 /* in direct rendering mode where all spans */
967 /* are generated if no clipping box is set. */
969 #define FT_RASTER_FLAG_DEFAULT 0x0
970 #define FT_RASTER_FLAG_AA 0x1
971 #define FT_RASTER_FLAG_DIRECT 0x2
972 #define FT_RASTER_FLAG_CLIP 0x4
975 #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
976 #define ft_raster_flag_aa FT_RASTER_FLAG_AA
977 #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
978 #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
981 /*************************************************************************/
984 /* FT_Raster_Params */
987 /* A structure to hold the arguments used by a raster's render */
991 /* target :: The target bitmap. */
993 /* source :: A pointer to the source glyph image (e.g. an */
996 /* flags :: The rendering flags. */
998 /* gray_spans :: The gray span drawing callback. */
1000 /* black_spans :: The black span drawing callback. */
1002 /* bit_test :: The bit test callback. UNIMPLEMENTED! */
1004 /* bit_set :: The bit set callback. UNIMPLEMENTED! */
1006 /* user :: User-supplied data that is passed to each drawing */
1009 /* clip_box :: An optional clipping box. It is only used in */
1010 /* direct rendering mode. Note that coordinates here */
1011 /* should be expressed in _integer_ pixels (and not in */
1012 /* 26.6 fixed-point units). */
1015 /* An anti-aliased glyph bitmap is drawn if the FT_RASTER_FLAG_AA bit */
1016 /* flag is set in the `flags' field, otherwise a monochrome bitmap */
1017 /* will be generated. */
1019 /* If the FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
1020 /* raster will call the `gray_spans' callback to draw gray pixel */
1021 /* spans, in the case of an aa glyph bitmap, it will call */
1022 /* `black_spans', and `bit_test' and `bit_set' in the case of a */
1023 /* monochrome bitmap. This allows direct composition over a */
1024 /* pre-existing bitmap through user-provided callbacks to perform the */
1025 /* span drawing/composition. */
1027 /* Note that the `bit_test' and `bit_set' callbacks are required when */
1028 /* rendering a monochrome bitmap, as they are crucial to implement */
1029 /* correct drop-out control as defined in the TrueType specification. */
1031 typedef struct FT_Raster_Params_
1033 const FT_Bitmap* target;
1036 FT_SpanFunc gray_spans;
1037 FT_SpanFunc black_spans;
1038 FT_Raster_BitTest_Func bit_test; /* doesn't work! */
1039 FT_Raster_BitSet_Func bit_set; /* doesn't work! */
1046 /*************************************************************************/
1049 /* FT_Raster_NewFunc */
1052 /* A function used to create a new raster object. */
1055 /* memory :: A handle to the memory allocator. */
1058 /* raster :: A handle to the new raster object. */
1061 /* Error code. 0 means success. */
1064 /* The `memory' parameter is a typeless pointer in order to avoid */
1065 /* un-wanted dependencies on the rest of the FreeType code. In */
1066 /* practice, it is a FT_Memory, i.e., a handle to the standard */
1067 /* FreeType memory allocator. However, this field can be completely */
1068 /* ignored by a given raster implementation. */
1071 (*FT_Raster_NewFunc)( void* memory,
1072 FT_Raster* raster );
1074 #define FT_Raster_New_Func FT_Raster_NewFunc
1076 /*************************************************************************/
1079 /* FT_Raster_DoneFunc */
1082 /* A function used to destroy a given raster object. */
1085 /* raster :: A handle to the raster object. */
1088 (*FT_Raster_DoneFunc)( FT_Raster raster );
1090 #define FT_Raster_Done_Func FT_Raster_DoneFunc
1092 /*************************************************************************/
1095 /* FT_Raster_ResetFunc */
1098 /* FreeType provides an area of memory called the `render pool', */
1099 /* available to all registered rasters. This pool can be freely used */
1100 /* during a given scan-conversion but is shared by all rasters. Its */
1101 /* content is thus transient. */
1103 /* This function is called each time the render pool changes, or just */
1104 /* after a new raster object is created. */
1107 /* raster :: A handle to the new raster object. */
1109 /* pool_base :: The address in memory of the render pool. */
1111 /* pool_size :: The size in bytes of the render pool. */
1114 /* Rasters can ignore the render pool and rely on dynamic memory */
1115 /* allocation if they want to (a handle to the memory allocator is */
1116 /* passed to the raster constructor). However, this is not */
1117 /* recommended for efficiency purposes. */
1120 (*FT_Raster_ResetFunc)( FT_Raster raster,
1121 unsigned char* pool_base,
1122 unsigned long pool_size );
1124 #define FT_Raster_Reset_Func FT_Raster_ResetFunc
1126 /*************************************************************************/
1129 /* FT_Raster_SetModeFunc */
1132 /* This function is a generic facility to change modes or attributes */
1133 /* in a given raster. This can be used for debugging purposes, or */
1134 /* simply to allow implementation-specific `features' in a given */
1135 /* raster module. */
1138 /* raster :: A handle to the new raster object. */
1140 /* mode :: A 4-byte tag used to name the mode or property. */
1142 /* args :: A pointer to the new mode/property to use. */
1145 (*FT_Raster_SetModeFunc)( FT_Raster raster,
1149 #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1151 /*************************************************************************/
1154 /* FT_Raster_RenderFunc */
1157 /* Invokes a given raster to scan-convert a given glyph image into a */
1158 /* target bitmap. */
1161 /* raster :: A handle to the raster object. */
1163 /* params :: A pointer to a FT_Raster_Params structure used to store */
1164 /* the rendering parameters. */
1167 /* Error code. 0 means success. */
1170 /* The exact format of the source image depends on the raster's glyph */
1171 /* format defined in its FT_Raster_Funcs structure. It can be an */
1172 /* FT_Outline or anything else in order to support a large array of */
1173 /* glyph formats. */
1175 /* Note also that the render function can fail and return a */
1176 /* FT_Err_Unimplemented_Feature error code if the raster used does */
1177 /* not support direct composition. */
1179 /* XXX: For now, the standard raster doesn't support direct */
1180 /* composition but this should change for the final release (see */
1181 /* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */
1182 /* examples of distinct implementations which support direct */
1186 (*FT_Raster_RenderFunc)( FT_Raster raster,
1187 FT_Raster_Params* params );
1189 #define FT_Raster_Render_Func FT_Raster_RenderFunc
1191 /*************************************************************************/
1194 /* FT_Raster_Funcs */
1197 /* A structure used to describe a given raster class to the library. */
1200 /* glyph_format :: The supported glyph format for this raster. */
1202 /* raster_new :: The raster constructor. */
1204 /* raster_reset :: Used to reset the render pool within the raster. */
1206 /* raster_render :: A function to render a glyph into a given bitmap. */
1208 /* raster_done :: The raster destructor. */
1210 typedef struct FT_Raster_Funcs_
1212 FT_Glyph_Format glyph_format;
1213 FT_Raster_NewFunc raster_new;
1214 FT_Raster_ResetFunc raster_reset;
1215 FT_Raster_SetModeFunc raster_set_mode;
1216 FT_Raster_RenderFunc raster_render;
1217 FT_Raster_DoneFunc raster_done;
1227 #endif /* __FTIMAGE_H__ */