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