1 /***************************************************************************/
5 /* FreeType glyph image formats and default raster interface */
8 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 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 is three */
148 /* 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 */
154 /* is three times taller than the original glyph image. See also */
155 /* @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 to describe the format of a bitmap palette, */
207 /* 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 Bézier 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 Bézier 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
)( const 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
)( const 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 Bézier 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
)( const 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 Bézier arc. */
563 /* control1 :: A pointer to the first Bézier control point. */
565 /* control2 :: A pointer to the second Bézier 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
)( const FT_Vector
* control1
,
577 const FT_Vector
* control2
,
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 Béziers, */
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 Bézier arc emitter. */
601 /* cubic_to :: The third-order Bézier 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: */
615 /* x' = (x << shift) - delta */
616 /* y' = (x << shift) - delta */
619 /* Set the value of `shift' and `delta' to 0 to get the original */
620 /* point coordinates. */
622 typedef struct FT_Outline_Funcs_
624 FT_Outline_MoveToFunc move_to
;
625 FT_Outline_LineToFunc line_to
;
626 FT_Outline_ConicToFunc conic_to
;
627 FT_Outline_CubicToFunc cubic_to
;
635 /*************************************************************************/
640 /*************************************************************************/
643 /*************************************************************************/
649 /* This macro converts four-letter tags to an unsigned long type. */
652 /* Since many 16bit compilers don't like 32bit enumerations, you */
653 /* should redefine this macro in case of problems to something like */
657 /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
660 /* to get a simple enumeration without assigning special numbers. */
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 ) | \
668 #endif /* FT_IMAGE_TAG */
671 /*************************************************************************/
674 /* FT_Glyph_Format */
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. */
683 /* FT_GLYPH_FORMAT_NONE :: */
684 /* The value 0 is reserved. */
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). */
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. */
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. */
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. */
709 typedef enum FT_Glyph_Format_
711 FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE
, 0, 0, 0, 0 ),
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' )
721 /*************************************************************************/
724 /* ft_glyph_format_xxx */
727 /* A list of decprecated constants. Use the corresponding */
728 /* @FT_Glyph_Format values instead. */
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. */
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
744 /*************************************************************************/
745 /*************************************************************************/
746 /*************************************************************************/
748 /***** R A S T E R D E F I N I T I O N S *****/
750 /*************************************************************************/
751 /*************************************************************************/
752 /*************************************************************************/
755 /*************************************************************************/
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. */
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. */
764 /*************************************************************************/
767 /*************************************************************************/
773 /* Scanline Converter */
776 /* How vectorial outlines are converted into bitmaps and pixmaps. */
779 /* This section contains technical definitions. */
781 /*************************************************************************/
784 /*************************************************************************/
790 /* A handle (pointer) to a raster object. Each object can be used */
791 /* independently to convert an outline into a bitmap or pixmap. */
793 typedef struct FT_RasterRec_
* FT_Raster
;
796 /*************************************************************************/
802 /* A structure used to model a single span of gray (or black) pixels */
803 /* when rendering a monochrome or anti-aliased bitmap. */
806 /* x :: The span's horizontal start position. */
808 /* len :: The span's length in pixels. */
810 /* coverage :: The span color/coverage, ranging from 0 (background) */
811 /* to 255 (foreground). Only used for anti-aliased */
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 */
819 /* The coverage value is always between 0 and 255. */
821 typedef struct FT_Span_
825 unsigned char coverage
;
830 /*************************************************************************/
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. */
841 /* y :: The scanline's y-coordinate. */
843 /* count :: The number of spans to draw on this scanline. */
845 /* spans :: A table of `count' spans to draw on the scanline. */
847 /* user :: User-supplied data that is passed to the callback. */
850 /* This callback allows client applications to directly render the */
851 /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
853 /* This can be used to write anti-aliased outlines directly to a */
854 /* given background bitmap, and even perform translucency. */
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. */
863 /* Otherwise, the callback is only called once per scan-line, and */
864 /* only for those scanlines that do have `gray' pixels on them. */
867 (*FT_SpanFunc
)( int y
,
869 const FT_Span
* spans
,
872 #define FT_Raster_Span_Func FT_SpanFunc
875 /*************************************************************************/
878 /* FT_Raster_BitTest_Func */
881 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
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. */
889 /* y :: The pixel's y-coordinate. */
891 /* x :: The pixel's x-coordinate. */
893 /* user :: User-supplied data that is passed to the callback. */
896 /* 1 if the pixel is `set', 0 otherwise. */
899 (*FT_Raster_BitTest_Func
)( int y
,
904 /*************************************************************************/
907 /* FT_Raster_BitSet_Func */
910 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
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. */
917 /* y :: The pixel's y-coordinate. */
919 /* x :: The pixel's x-coordinate. */
921 /* user :: User-supplied data that is passed to the callback. */
924 /* 1 if the pixel is `set', 0 otherwise. */
927 (*FT_Raster_BitSet_Func
)( int y
,
932 /*************************************************************************/
935 /* FT_RASTER_FLAG_XXX */
938 /* A list of bit flag constants as used in the `flags' field of a */
939 /* @FT_Raster_Params structure. */
942 /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
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). */
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 */
958 /* Note that for now, direct rendering is */
959 /* only possible with anti-aliased glyphs. */
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. */
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. */
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
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
984 /*************************************************************************/
987 /* FT_Raster_Params */
990 /* A structure to hold the arguments used by a raster's render */
994 /* target :: The target bitmap. */
996 /* source :: A pointer to the source glyph image (e.g., an */
999 /* flags :: The rendering flags. */
1001 /* gray_spans :: The gray span drawing callback. */
1003 /* black_spans :: The black span drawing callback. */
1005 /* bit_test :: The bit test callback. UNIMPLEMENTED! */
1007 /* bit_set :: The bit set callback. UNIMPLEMENTED! */
1009 /* user :: User-supplied data that is passed to each drawing */
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). */
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. */
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. */
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. */
1034 typedef struct FT_Raster_Params_
1036 const FT_Bitmap
* target
;
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! */
1049 /*************************************************************************/
1052 /* FT_Raster_NewFunc */
1055 /* A function used to create a new raster object. */
1058 /* memory :: A handle to the memory allocator. */
1061 /* raster :: A handle to the new raster object. */
1064 /* Error code. 0 means success. */
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. */
1074 (*FT_Raster_NewFunc
)( void* memory
,
1075 FT_Raster
* raster
);
1077 #define FT_Raster_New_Func FT_Raster_NewFunc
1079 /*************************************************************************/
1082 /* FT_Raster_DoneFunc */
1085 /* A function used to destroy a given raster object. */
1088 /* raster :: A handle to the raster object. */
1091 (*FT_Raster_DoneFunc
)( FT_Raster raster
);
1093 #define FT_Raster_Done_Func FT_Raster_DoneFunc
1095 /*************************************************************************/
1098 /* FT_Raster_ResetFunc */
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. */
1106 /* This function is called each time the render pool changes, or just */
1107 /* after a new raster object is created. */
1110 /* raster :: A handle to the new raster object. */
1112 /* pool_base :: The address in memory of the render pool. */
1114 /* pool_size :: The size in bytes of the render pool. */
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. */
1123 (*FT_Raster_ResetFunc
)( FT_Raster raster
,
1124 unsigned char* pool_base
,
1125 unsigned long pool_size
);
1127 #define FT_Raster_Reset_Func FT_Raster_ResetFunc
1129 /*************************************************************************/
1132 /* FT_Raster_SetModeFunc */
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. */
1141 /* raster :: A handle to the new raster object. */
1143 /* mode :: A 4-byte tag used to name the mode or property. */
1145 /* args :: A pointer to the new mode/property to use. */
1148 (*FT_Raster_SetModeFunc
)( FT_Raster raster
,
1152 #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1154 /*************************************************************************/
1157 /* FT_Raster_RenderFunc */
1160 /* Invokes a given raster to scan-convert a given glyph image into a */
1161 /* target bitmap. */
1164 /* raster :: A handle to the raster object. */
1166 /* params :: A pointer to an @FT_Raster_Params structure used to */
1167 /* store the rendering parameters. */
1170 /* Error code. 0 means success. */
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. */
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. */
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 */
1189 (*FT_Raster_RenderFunc
)( FT_Raster raster
,
1190 const FT_Raster_Params
* params
);
1192 #define FT_Raster_Render_Func FT_Raster_RenderFunc
1194 /*************************************************************************/
1197 /* FT_Raster_Funcs */
1200 /* A structure used to describe a given raster class to the library. */
1203 /* glyph_format :: The supported glyph format for this raster. */
1205 /* raster_new :: The raster constructor. */
1207 /* raster_reset :: Used to reset the render pool within the raster. */
1209 /* raster_render :: A function to render a glyph into a given bitmap. */
1211 /* raster_done :: The raster destructor. */
1213 typedef struct FT_Raster_Funcs_
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
;
1230 #endif /* __FTIMAGE_H__ */
1236 /* Local Variables: */