1
/***************************************************************************/
5
/* FreeType glyph image formats and default raster interface */
8
/* Copyright 1996-2001, 2002, 2003, 2004 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
/* QT_FT_Outlines into QT_FT_Bitmaps. */
24
/*************************************************************************/
27
#ifndef __QT_FTIMAGE_H__
28
#define __QT_FTIMAGE_H__
33
/*************************************************************************/
38
/*************************************************************************/
41
/*************************************************************************/
47
/* The type QT_FT_Pos is a 32-bit integer used to store vectorial */
48
/* coordinates. Depending on the context, these can represent */
49
/* distances in integer font units, or 16,16, or 26.6 fixed float */
50
/* pixel coordinates. */
52
typedef signed long QT_FT_Pos;
55
/*************************************************************************/
61
/* A simple structure used to store a 2D vector; coordinates are of */
62
/* the QT_FT_Pos type. */
65
/* x :: The horizontal coordinate. */
66
/* y :: The vertical coordinate. */
68
typedef struct QT_FT_Vector_
76
/*************************************************************************/
82
/* A structure used to hold an outline's bounding box, i.e., the */
83
/* coordinates of its extrema in the horizontal and vertical */
87
/* xMin :: The horizontal minimum (left-most). */
89
/* yMin :: The vertical minimum (bottom-most). */
91
/* xMax :: The horizontal maximum (right-most). */
93
/* yMax :: The vertical maximum (top-most). */
95
typedef struct QT_FT_BBox_
103
/*************************************************************************/
106
/* QT_FT_Pixel_Mode */
109
/* An enumeration type used to describe the format of pixels in a */
110
/* given bitmap. Note that additional formats may be added in the */
114
/* QT_FT_PIXEL_MODE_NONE :: */
115
/* Value 0 is reserved. */
117
/* QT_FT_PIXEL_MODE_MONO :: */
118
/* A monochrome bitmap, using 1 bit per pixel. Note that pixels */
119
/* are stored in most-significant order (MSB), which means that */
120
/* the left-most pixel in a byte has value 128. */
122
/* QT_FT_PIXEL_MODE_GRAY :: */
123
/* An 8-bit bitmap, generally used to represent anti-aliased glyph */
124
/* images. Each pixel is stored in one byte. Note that the number */
125
/* of value "gray" levels is stored in the `num_bytes' field of */
126
/* the @QT_FT_Bitmap structure (it generally is 256). */
128
/* QT_FT_PIXEL_MODE_GRAY2 :: */
129
/* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */
130
/* bitmaps in font files according to the OpenType specification. */
131
/* We haven't found a single font using this format, however. */
133
/* QT_FT_PIXEL_MODE_GRAY4 :: */
134
/* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */
135
/* bitmaps in font files according to the OpenType specification. */
136
/* We haven't found a single font using this format, however. */
138
/* QT_FT_PIXEL_MODE_LCD :: */
139
/* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
140
/* images used for display on LCD displays; the bitmap's width is */
141
/* three times wider than the original glyph image. See also */
142
/* @QT_FT_RENDER_MODE_LCD. */
144
/* QT_FT_PIXEL_MODE_LCD_V :: */
145
/* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
146
/* images used for display on rotated LCD displays; the bitmap's */
147
/* height is three times taller than the original glyph image. */
148
/* See also @QT_FT_RENDER_MODE_LCD_V. */
150
typedef enum QT_FT_Pixel_Mode_
152
QT_FT_PIXEL_MODE_NONE = 0,
153
QT_FT_PIXEL_MODE_MONO,
154
QT_FT_PIXEL_MODE_GRAY,
155
QT_FT_PIXEL_MODE_GRAY2,
156
QT_FT_PIXEL_MODE_GRAY4,
157
QT_FT_PIXEL_MODE_LCD,
158
QT_FT_PIXEL_MODE_LCD_V,
160
QT_FT_PIXEL_MODE_MAX /* do not remove */
165
/*************************************************************************/
168
/* qt_ft_pixel_mode_xxx */
171
/* A list of deprecated constants. Use the corresponding */
172
/* @QT_FT_Pixel_Mode values instead. */
175
/* qt_ft_pixel_mode_none :: see @QT_FT_PIXEL_MODE_NONE */
176
/* qt_ft_pixel_mode_mono :: see @QT_FT_PIXEL_MODE_MONO */
177
/* qt_ft_pixel_mode_grays :: see @QT_FT_PIXEL_MODE_GRAY */
178
/* qt_ft_pixel_mode_pal2 :: see @QT_FT_PIXEL_MODE_GRAY2 */
179
/* qt_ft_pixel_mode_pal4 :: see @QT_FT_PIXEL_MODE_GRAY4 */
181
#define qt_ft_pixel_mode_none QT_FT_PIXEL_MODE_NONE
182
#define qt_ft_pixel_mode_mono QT_FT_PIXEL_MODE_MONO
183
#define qt_ft_pixel_mode_grays QT_FT_PIXEL_MODE_GRAY
184
#define qt_ft_pixel_mode_pal2 QT_FT_PIXEL_MODE_GRAY2
185
#define qt_ft_pixel_mode_pal4 QT_FT_PIXEL_MODE_GRAY4
191
/*************************************************************************/
194
/* QT_FT_Palette_Mode */
197
/* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
199
/* An enumeration type used to describe the format of a bitmap */
200
/* palette, used with qt_ft_pixel_mode_pal4 and qt_ft_pixel_mode_pal8. */
203
/* qt_ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */
206
/* qt_ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */
210
/* As qt_ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */
211
/* FreeType, these types are not handled by the library itself. */
213
typedef enum QT_FT_Palette_Mode_
215
qt_ft_palette_mode_rgb = 0,
216
qt_ft_palette_mode_rgba,
218
qt_ft_palettte_mode_max /* do not remove */
220
} QT_FT_Palette_Mode;
227
/*************************************************************************/
233
/* A structure used to describe a bitmap or pixmap to the raster. */
234
/* Note that we now manage pixmaps of various depths through the */
235
/* `pixel_mode' field. */
238
/* rows :: The number of bitmap rows. */
240
/* width :: The number of pixels in bitmap row. */
242
/* pitch :: The pitch's absolute value is the number of bytes */
243
/* taken by one bitmap row, including padding. */
244
/* However, the pitch is positive when the bitmap has */
245
/* a `down' flow, and negative when it has an `up' */
246
/* flow. In all cases, the pitch is an offset to add */
247
/* to a bitmap pointer in order to go down one row. */
249
/* buffer :: A typeless pointer to the bitmap buffer. This */
250
/* value should be aligned on 32-bit boundaries in */
253
/* num_grays :: This field is only used with */
254
/* `QT_FT_PIXEL_MODE_GRAY'; it gives the number of gray */
255
/* levels used in the bitmap. */
257
/* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
258
/* See @QT_FT_Pixel_Mode for possible values. */
260
/* palette_mode :: This field is only used with paletted pixel modes; */
261
/* it indicates how the palette is stored. */
263
/* palette :: A typeless pointer to the bitmap palette; only */
264
/* used for paletted pixel modes. */
267
/* For now, the only pixel mode supported by FreeType are mono and */
268
/* grays. However, drivers might be added in the future to support */
269
/* more `colorful' options. */
271
/* When using pixel modes pal2, pal4 and pal8 with a void `palette' */
272
/* field, a gray pixmap with respectively 4, 16, and 256 levels of */
273
/* gray is assumed. This, in order to be compatible with some */
274
/* embedded bitmap formats defined in the TrueType specification. */
276
/* Note that no font was found presenting such embedded bitmaps, so */
277
/* this is currently completely unhandled by the library. */
279
typedef struct QT_FT_Bitmap_
284
unsigned char* buffer;
293
/*************************************************************************/
296
/* outline_processing */
298
/*************************************************************************/
301
/*************************************************************************/
307
/* This structure is used to describe an outline to the scan-line */
311
/* n_contours :: The number of contours in the outline. */
313
/* n_points :: The number of points in the outline. */
315
/* points :: A pointer to an array of `n_points' QT_FT_Vector */
316
/* elements, giving the outline's point coordinates. */
318
/* tags :: A pointer to an array of `n_points' chars, giving */
319
/* each outline point's type. If bit 0 is unset, the */
320
/* point is `off' the curve, i.e. a Bezier control */
321
/* point, while it is `on' when set. */
323
/* Bit 1 is meaningful for `off' points only. If set, */
324
/* it indicates a third-order Bezier arc control point; */
325
/* and a second-order control point if unset. */
327
/* contours :: An array of `n_contours' shorts, giving the end */
328
/* point of each contour within the outline. For */
329
/* example, the first contour is defined by the points */
330
/* `0' to `contours[0]', the second one is defined by */
331
/* the points `contours[0]+1' to `contours[1]', etc. */
333
/* flags :: A set of bit flags used to characterize the outline */
334
/* and give hints to the scan-converter and hinter on */
335
/* how to convert/grid-fit it. See QT_FT_Outline_Flags. */
337
typedef struct QT_FT_Outline_
339
short n_contours; /* number of contours in glyph */
340
short n_points; /* number of points in the glyph */
342
QT_FT_Vector* points; /* the outline's points */
343
char* tags; /* the points flags */
344
short* contours; /* the contour end points */
346
int flags; /* outline masks */
351
/*************************************************************************/
354
/* QT_FT_OUTLINE_FLAGS */
357
/* A list of bit-field constants use for the flags in an outline's */
361
/* QT_FT_OUTLINE_NONE :: Value 0 is reserved. */
363
/* QT_FT_OUTLINE_OWNER :: If set, this flag indicates that the */
364
/* outline's field arrays (i.e. */
365
/* `points', `flags' & `contours') are */
366
/* `owned' by the outline object, and */
367
/* should thus be freed when it is */
370
/* QT_FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */
371
/* the non-zero winding rule. If set to */
372
/* 1, the outline will be filled using */
373
/* the even-odd fill rule (only works */
374
/* with the smooth raster). */
376
/* QT_FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */
377
/* outline are oriented in clock-wise */
378
/* direction, as defined in the TrueType */
379
/* specification. This flag is set if */
380
/* the outline uses the opposite */
381
/* direction (typically for Type 1 */
382
/* fonts). This flag is ignored by the */
383
/* scan-converter. However, it is very */
384
/* important for the auto-hinter. */
386
/* QT_FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */
387
/* try to detect drop-outs in an outline */
388
/* and correct the glyph bitmap to */
389
/* ensure consistent shape continuity. */
390
/* If set, this flag hints the scan-line */
391
/* converter to ignore such cases. */
393
/* QT_FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */
394
/* scan-line converter should try to */
395
/* convert this outline to bitmaps with */
396
/* the highest possible quality. It is */
397
/* typically set for small character */
398
/* sizes. Note that this is only a */
399
/* hint, that might be completely */
400
/* ignored by a given scan-converter. */
402
/* QT_FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */
403
/* scan-converter to only use a single */
404
/* pass over the outline to render a */
405
/* bitmap glyph image. Normally, it is */
406
/* set for very large character sizes. */
407
/* It is only a hint, that might be */
408
/* completely ignored by a given */
409
/* scan-converter. */
411
#define QT_FT_OUTLINE_NONE 0x0
412
#define QT_FT_OUTLINE_OWNER 0x1
413
#define QT_FT_OUTLINE_EVEN_ODD_FILL 0x2
414
#define QT_FT_OUTLINE_REVERSE_FILL 0x4
415
#define QT_FT_OUTLINE_IGNORE_DROPOUTS 0x8
417
#define QT_FT_OUTLINE_HIGH_PRECISION 0x100
418
#define QT_FT_OUTLINE_SINGLE_PASS 0x200
421
/*************************************************************************
424
* qt_ft_outline_flags
427
* These constants are deprecated. Please use the corresponding
428
* @QT_FT_OUTLINE_FLAGS values.
431
* qt_ft_outline_none :: See @QT_FT_OUTLINE_NONE.
432
* qt_ft_outline_owner :: See @QT_FT_OUTLINE_OWNER.
433
* qt_ft_outline_even_odd_fill :: See @QT_FT_OUTLINE_EVEN_ODD_FILL.
434
* qt_ft_outline_reverse_fill :: See @QT_FT_OUTLINE_REVERSE_FILL.
435
* qt_ft_outline_ignore_dropouts :: See @QT_FT_OUTLINE_IGNORE_DROPOUTS.
436
* qt_ft_outline_high_precision :: See @QT_FT_OUTLINE_HIGH_PRECISION.
437
* qt_ft_outline_single_pass :: See @QT_FT_OUTLINE_SINGLE_PASS.
439
#define qt_ft_outline_none QT_FT_OUTLINE_NONE
440
#define qt_ft_outline_owner QT_FT_OUTLINE_OWNER
441
#define qt_ft_outline_even_odd_fill QT_FT_OUTLINE_EVEN_ODD_FILL
442
#define qt_ft_outline_reverse_fill QT_FT_OUTLINE_REVERSE_FILL
443
#define qt_ft_outline_ignore_dropouts QT_FT_OUTLINE_IGNORE_DROPOUTS
444
#define qt_ft_outline_high_precision QT_FT_OUTLINE_HIGH_PRECISION
445
#define qt_ft_outline_single_pass QT_FT_OUTLINE_SINGLE_PASS
449
#define QT_FT_CURVE_TAG( flag ) ( flag & 3 )
451
#define QT_FT_CURVE_TAG_ON 1
452
#define QT_FT_CURVE_TAG_CONIC 0
453
#define QT_FT_CURVE_TAG_CUBIC 2
455
#define QT_FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
456
#define QT_FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
458
#define QT_FT_CURVE_TAG_TOUCH_BOTH ( QT_FT_CURVE_TAG_TOUCH_X | \
459
QT_FT_CURVE_TAG_TOUCH_Y )
461
#define QT_FT_Curve_Tag_On QT_FT_CURVE_TAG_ON
462
#define QT_FT_Curve_Tag_Conic QT_FT_CURVE_TAG_CONIC
463
#define QT_FT_Curve_Tag_Cubic QT_FT_CURVE_TAG_CUBIC
464
#define QT_FT_Curve_Tag_Touch_X QT_FT_CURVE_TAG_TOUCH_X
465
#define QT_FT_Curve_Tag_Touch_Y QT_FT_CURVE_TAG_TOUCH_Y
467
/*************************************************************************/
470
/* QT_FT_Outline_MoveToFunc */
473
/* A function pointer type used to describe the signature of a `move */
474
/* to' function during outline walking/decomposition. */
476
/* A `move to' is emitted to start a new contour in an outline. */
479
/* to :: A pointer to the target point of the `move to'. */
481
/* user :: A typeless pointer which is passed from the caller of the */
482
/* decomposition function. */
485
/* Error code. 0 means success. */
488
(*QT_FT_Outline_MoveToFunc)( QT_FT_Vector* to,
491
#define QT_FT_Outline_MoveTo_Func QT_FT_Outline_MoveToFunc
493
/*************************************************************************/
496
/* QT_FT_Outline_LineToFunc */
499
/* A function pointer type used to describe the signature of a `line */
500
/* to' function during outline walking/decomposition. */
502
/* A `line to' is emitted to indicate a segment in the outline. */
505
/* to :: A pointer to the target point of the `line to'. */
507
/* user :: A typeless pointer which is passed from the caller of the */
508
/* decomposition function. */
511
/* Error code. 0 means success. */
514
(*QT_FT_Outline_LineToFunc)( QT_FT_Vector* to,
517
#define QT_FT_Outline_LineTo_Func QT_FT_Outline_LineToFunc
519
/*************************************************************************/
522
/* QT_FT_Outline_ConicToFunc */
525
/* A function pointer type use to describe the signature of a `conic */
526
/* to' function during outline walking/decomposition. */
528
/* A `conic to' is emitted to indicate a second-order Bezier arc in */
532
/* control :: An intermediate control point between the last position */
533
/* and the new target in `to'. */
535
/* to :: A pointer to the target end point of the conic arc. */
537
/* user :: A typeless pointer which is passed from the caller of */
538
/* the decomposition function. */
541
/* Error code. 0 means success. */
544
(*QT_FT_Outline_ConicToFunc)( QT_FT_Vector* control,
548
#define QT_FT_Outline_ConicTo_Func QT_FT_Outline_ConicToFunc
550
/*************************************************************************/
553
/* QT_FT_Outline_CubicToFunc */
556
/* A function pointer type used to describe the signature of a `cubic */
557
/* to' function during outline walking/decomposition. */
559
/* A `cubic to' is emitted to indicate a third-order Bezier arc. */
562
/* control1 :: A pointer to the first Bezier control point. */
564
/* control2 :: A pointer to the second Bezier control point. */
566
/* to :: A pointer to the target end point. */
568
/* user :: A typeless pointer which is passed from the caller of */
569
/* the decomposition function. */
572
/* Error code. 0 means success. */
575
(*QT_FT_Outline_CubicToFunc)( QT_FT_Vector* control1,
576
QT_FT_Vector* control2,
580
#define QT_FT_Outline_CubicTo_Func QT_FT_Outline_CubicToFunc
583
/*************************************************************************/
586
/* QT_FT_Outline_Funcs */
589
/* A structure to hold various function pointers used during outline */
590
/* decomposition in order to emit segments, conic, and cubic Beziers, */
591
/* as well as `move to' and `close to' operations. */
594
/* move_to :: The `move to' emitter. */
596
/* line_to :: The segment emitter. */
598
/* conic_to :: The second-order Bezier arc emitter. */
600
/* cubic_to :: The third-order Bezier arc emitter. */
602
/* shift :: The shift that is applied to coordinates before they */
603
/* are sent to the emitter. */
605
/* delta :: The delta that is applied to coordinates before they */
606
/* are sent to the emitter, but after the shift. */
609
/* The point coordinates sent to the emitters are the transformed */
610
/* version of the original coordinates (this is important for high */
611
/* accuracy during scan-conversion). The transformation is simple: */
613
/* x' = (x << shift) - delta */
614
/* y' = (x << shift) - delta */
616
/* Set the value of `shift' and `delta' to 0 to get the original */
617
/* point coordinates. */
619
typedef struct QT_FT_Outline_Funcs_
621
QT_FT_Outline_MoveToFunc move_to;
622
QT_FT_Outline_LineToFunc line_to;
623
QT_FT_Outline_ConicToFunc conic_to;
624
QT_FT_Outline_CubicToFunc cubic_to;
629
} QT_FT_Outline_Funcs;
632
/*************************************************************************/
637
/*************************************************************************/
640
/*************************************************************************/
643
/* QT_FT_IMAGE_TAG */
646
/* This macro converts four letter tags into an unsigned long. */
649
/* Since many 16bit compilers don't like 32bit enumerations, you */
650
/* should redefine this macro in case of problems to something like */
653
/* #define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
655
/* to get a simple enumeration without assigning special numbers. */
657
#ifndef QT_FT_IMAGE_TAG
658
#define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
659
value = ( ( (unsigned long)_x1 << 24 ) | \
660
( (unsigned long)_x2 << 16 ) | \
661
( (unsigned long)_x3 << 8 ) | \
663
#endif /* QT_FT_IMAGE_TAG */
666
/*************************************************************************/
669
/* QT_FT_Glyph_Format */
672
/* An enumeration type used to describe the format of a given glyph */
673
/* image. Note that this version of FreeType only supports two image */
674
/* formats, even though future font drivers will be able to register */
675
/* their own format. */
678
/* QT_FT_GLYPH_FORMAT_NONE :: */
679
/* The value 0 is reserved and does describe a glyph format. */
681
/* QT_FT_GLYPH_FORMAT_COMPOSITE :: */
682
/* The glyph image is a composite of several other images. This */
683
/* format is _only_ used with @QT_FT_LOAD_NO_RECURSE, and is used to */
684
/* report compound glyphs (like accented characters). */
686
/* QT_FT_GLYPH_FORMAT_BITMAP :: */
687
/* The glyph image is a bitmap, and can be described as an */
688
/* @QT_FT_Bitmap. You generally need to access the `bitmap' field of */
689
/* the @QT_FT_GlyphSlotRec structure to read it. */
691
/* QT_FT_GLYPH_FORMAT_OUTLINE :: */
692
/* The glyph image is a vertorial outline made of line segments */
693
/* and Bezier arcs; it can be described as an @QT_FT_Outline; you */
694
/* generally want to access the `outline' field of the */
695
/* @QT_FT_GlyphSlotRec structure to read it. */
697
/* QT_FT_GLYPH_FORMAT_PLOTTER :: */
698
/* The glyph image is a vectorial path with no inside/outside */
699
/* contours. Some Type 1 fonts, like those in the Hershey family, */
700
/* contain glyphs in this format. These are described as */
701
/* @QT_FT_Outline, but FreeType isn't currently capable of rendering */
702
/* them correctly. */
704
typedef enum QT_FT_Glyph_Format_
706
QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
708
QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
709
QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
710
QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
711
QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
713
} QT_FT_Glyph_Format;
716
/*************************************************************************/
719
/* qt_ft_glyph_format_xxx */
722
/* A list of decprecated constants. Use the corresponding */
723
/* @QT_FT_Glyph_Format values instead. */
726
/* qt_ft_glyph_format_none :: see @QT_FT_GLYPH_FORMAT_NONE */
727
/* qt_ft_glyph_format_composite :: see @QT_FT_GLYPH_FORMAT_COMPOSITE */
728
/* qt_ft_glyph_format_bitmap :: see @QT_FT_GLYPH_FORMAT_BITMAP */
729
/* qt_ft_glyph_format_outline :: see @QT_FT_GLYPH_FORMAT_OUTLINE */
730
/* qt_ft_glyph_format_plotter :: see @QT_FT_GLYPH_FORMAT_PLOTTER */
732
#define qt_ft_glyph_format_none QT_FT_GLYPH_FORMAT_NONE
733
#define qt_ft_glyph_format_composite QT_FT_GLYPH_FORMAT_COMPOSITE
734
#define qt_ft_glyph_format_bitmap QT_FT_GLYPH_FORMAT_BITMAP
735
#define qt_ft_glyph_format_outline QT_FT_GLYPH_FORMAT_OUTLINE
736
#define qt_ft_glyph_format_plotter QT_FT_GLYPH_FORMAT_PLOTTER
739
/*************************************************************************/
740
/*************************************************************************/
741
/*************************************************************************/
743
/***** R A S T E R D E F I N I T I O N S *****/
745
/*************************************************************************/
746
/*************************************************************************/
747
/*************************************************************************/
750
/*************************************************************************/
752
/* A raster is a scan converter, in charge of rendering an outline into */
753
/* a a bitmap. This section contains the public API for rasters. */
755
/* Note that in FreeType 2, all rasters are now encapsulated within */
756
/* specific modules called `renderers'. See `freetype/ftrender.h' for */
757
/* more details on renderers. */
759
/*************************************************************************/
762
/*************************************************************************/
768
/* Scanline converter */
771
/* How vectorial outlines are converted into bitmaps and pixmaps. */
774
/* This section contains technical definitions. */
776
/*************************************************************************/
779
/*************************************************************************/
785
/* A handle (pointer) to a raster object. Each object can be used */
786
/* independently to convert an outline into a bitmap or pixmap. */
788
typedef struct QT_FT_RasterRec_* QT_FT_Raster;
791
/*************************************************************************/
797
/* A structure used to model a single span of gray (or black) pixels */
798
/* when rendering a monochrome or anti-aliased bitmap. */
801
/* x :: The span's horizontal start position. */
803
/* len :: The span's length in pixels. */
805
/* coverage :: The span color/coverage, ranging from 0 (background) */
806
/* to 255 (foreground). Only used for anti-aliased */
810
/* This structure is used by the span drawing callback type named */
811
/* QT_FT_SpanFunc which takes the y-coordinate of the span as a */
814
/* The coverage value is always between 0 and 255, even if the number */
815
/* of gray levels have been set through QT_FT_Set_Gray_Levels(). */
817
typedef struct QT_FT_Span_
821
unsigned char coverage;
826
/*************************************************************************/
832
/* A function used as a call-back by the anti-aliased renderer in */
833
/* order to let client applications draw themselves the gray pixel */
834
/* spans on each scan line. */
837
/* y :: The scanline's y-coordinate. */
839
/* count :: The number of spans to draw on this scanline. */
841
/* spans :: A table of `count' spans to draw on the scanline. */
843
/* user :: User-supplied data that is passed to the callback. */
846
/* This callback allows client applications to directly render the */
847
/* gray spans of the anti-aliased bitmap to any kind of surfaces. */
849
/* This can be used to write anti-aliased outlines directly to a */
850
/* given background bitmap, and even perform translucency. */
852
/* Note that the `count' field cannot be greater than a fixed value */
853
/* defined by the QT_FT_MAX_GRAY_SPANS configuration macro in */
854
/* ftoption.h. By default, this value is set to 32, which means that */
855
/* if there are more than 32 spans on a given scanline, the callback */
856
/* will be called several times with the same `y' parameter in order */
857
/* to draw all callbacks. */
859
/* Otherwise, the callback is only called once per scan-line, and */
860
/* only for those scanlines that do have `gray' pixels on them. */
863
(*QT_FT_SpanFunc)( int y,
868
#define QT_FT_Raster_Span_Func QT_FT_SpanFunc
871
/*************************************************************************/
874
/* QT_FT_Raster_BitTest_Func */
877
/* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
879
/* A function used as a call-back by the monochrome scan-converter */
880
/* to test whether a given target pixel is already set to the drawing */
881
/* `color'. These tests are crucial to implement drop-out control */
882
/* per-se the TrueType spec. */
885
/* y :: The pixel's y-coordinate. */
887
/* x :: The pixel's x-coordinate. */
889
/* user :: User-supplied data that is passed to the callback. */
892
/* 1 if the pixel is `set', 0 otherwise. */
895
(*QT_FT_Raster_BitTest_Func)( int y,
900
/*************************************************************************/
903
/* QT_FT_Raster_BitSet_Func */
906
/* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
908
/* A function used as a call-back by the monochrome scan-converter */
909
/* to set an individual target pixel. This is crucial to implement */
910
/* drop-out control according to the TrueType specification. */
913
/* y :: The pixel's y-coordinate. */
915
/* x :: The pixel's x-coordinate. */
917
/* user :: User-supplied data that is passed to the callback. */
920
/* 1 if the pixel is `set', 0 otherwise. */
923
(*QT_FT_Raster_BitSet_Func)( int y,
928
/*************************************************************************/
931
/* QT_FT_RASTER_FLAG_XXX */
934
/* A list of bit flag constants as used in the `flags' field of a */
935
/* @QT_FT_Raster_Params structure. */
938
/* QT_FT_RASTER_FLAG_DEFAULT :: This value is 0. */
940
/* QT_FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
941
/* anti-aliased glyph image should be */
942
/* generated. Otherwise, it will be */
943
/* monochrome (1-bit). */
945
/* QT_FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
946
/* rendering. In this mode, client */
947
/* applications must provide their own span */
948
/* callback. This lets them directly */
949
/* draw or compose over an existing bitmap. */
950
/* If this bit is not set, the target */
951
/* pixmap's buffer _must_ be zeroed before */
954
/* Note that for now, direct rendering is */
955
/* only possible with anti-aliased glyphs. */
957
/* QT_FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
958
/* rendering mode. If set, the output will */
959
/* be clipped to a box specified in the */
960
/* "clip_box" field of the QT_FT_Raster_Params */
963
/* Note that by default, the glyph bitmap */
964
/* is clipped to the target pixmap, except */
965
/* in direct rendering mode where all spans */
966
/* are generated if no clipping box is set. */
968
#define QT_FT_RASTER_FLAG_DEFAULT 0x0
969
#define QT_FT_RASTER_FLAG_AA 0x1
970
#define QT_FT_RASTER_FLAG_DIRECT 0x2
971
#define QT_FT_RASTER_FLAG_CLIP 0x4
974
#define qt_ft_raster_flag_default QT_FT_RASTER_FLAG_DEFAULT
975
#define qt_ft_raster_flag_aa QT_FT_RASTER_FLAG_AA
976
#define qt_ft_raster_flag_direct QT_FT_RASTER_FLAG_DIRECT
977
#define qt_ft_raster_flag_clip QT_FT_RASTER_FLAG_CLIP
980
/*************************************************************************/
983
/* QT_FT_Raster_Params */
986
/* A structure to hold the arguments used by a raster's render */
990
/* target :: The target bitmap. */
992
/* source :: A pointer to the source glyph image (e.g. an */
993
/* QT_FT_Outline). */
995
/* flags :: The rendering flags. */
997
/* gray_spans :: The gray span drawing callback. */
999
/* black_spans :: The black span drawing callback. */
1001
/* bit_test :: The bit test callback. UNIMPLEMENTED! */
1003
/* bit_set :: The bit set callback. UNIMPLEMENTED! */
1005
/* user :: User-supplied data that is passed to each drawing */
1008
/* clip_box :: An optional clipping box. It is only used in */
1009
/* direct rendering mode. Note that coordinates here */
1010
/* should be expressed in _integer_ pixels (and not in */
1011
/* 26.6 fixed-point units). */
1014
/* An anti-aliased glyph bitmap is drawn if the QT_FT_RASTER_FLAG_AA bit */
1015
/* flag is set in the `flags' field, otherwise a monochrome bitmap */
1016
/* will be generated. */
1018
/* If the QT_FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
1019
/* raster will call the `gray_spans' callback to draw gray pixel */
1020
/* spans, in the case of an aa glyph bitmap, it will call */
1021
/* `black_spans', and `bit_test' and `bit_set' in the case of a */
1022
/* monochrome bitmap. This allows direct composition over a */
1023
/* pre-existing bitmap through user-provided callbacks to perform the */
1024
/* span drawing/composition. */
1026
/* Note that the `bit_test' and `bit_set' callbacks are required when */
1027
/* rendering a monochrome bitmap, as they are crucial to implement */
1028
/* correct drop-out control as defined in the TrueType specification. */
1030
typedef struct QT_FT_Raster_Params_
1032
QT_FT_Bitmap* target;
1035
QT_FT_SpanFunc gray_spans;
1036
QT_FT_SpanFunc black_spans;
1037
QT_FT_Raster_BitTest_Func bit_test; /* doesn't work! */
1038
QT_FT_Raster_BitSet_Func bit_set; /* doesn't work! */
1040
QT_FT_BBox clip_box;
1042
} QT_FT_Raster_Params;
1045
/*************************************************************************/
1048
/* QT_FT_Raster_NewFunc */
1051
/* A function used to create a new raster object. */
1054
/* memory :: A handle to the memory allocator. */
1057
/* raster :: A handle to the new raster object. */
1060
/* Error code. 0 means success. */
1063
/* The `memory' parameter is a typeless pointer in order to avoid */
1064
/* un-wanted dependencies on the rest of the FreeType code. In */
1065
/* practice, it is a QT_FT_Memory, i.e., a handle to the standard */
1066
/* FreeType memory allocator. However, this field can be completely */
1067
/* ignored by a given raster implementation. */
1070
(*QT_FT_Raster_NewFunc)( void* memory,
1071
QT_FT_Raster* raster );
1073
#define QT_FT_Raster_New_Func QT_FT_Raster_NewFunc
1075
/*************************************************************************/
1078
/* QT_FT_Raster_DoneFunc */
1081
/* A function used to destroy a given raster object. */
1084
/* raster :: A handle to the raster object. */
1087
(*QT_FT_Raster_DoneFunc)( QT_FT_Raster raster );
1089
#define QT_FT_Raster_Done_Func QT_FT_Raster_DoneFunc
1091
/*************************************************************************/
1094
/* QT_FT_Raster_ResetFunc */
1097
/* FreeType provides an area of memory called the `render pool', */
1098
/* available to all registered rasters. This pool can be freely used */
1099
/* during a given scan-conversion but is shared by all rasters. Its */
1100
/* content is thus transient. */
1102
/* This function is called each time the render pool changes, or just */
1103
/* after a new raster object is created. */
1106
/* raster :: A handle to the new raster object. */
1108
/* pool_base :: The address in memory of the render pool. */
1110
/* pool_size :: The size in bytes of the render pool. */
1113
/* Rasters can ignore the render pool and rely on dynamic memory */
1114
/* allocation if they want to (a handle to the memory allocator is */
1115
/* passed to the raster constructor). However, this is not */
1116
/* recommended for efficiency purposes. */
1119
(*QT_FT_Raster_ResetFunc)( QT_FT_Raster raster,
1120
unsigned char* pool_base,
1121
unsigned long pool_size );
1123
#define QT_FT_Raster_Reset_Func QT_FT_Raster_ResetFunc
1125
/*************************************************************************/
1128
/* QT_FT_Raster_SetModeFunc */
1131
/* This function is a generic facility to change modes or attributes */
1132
/* in a given raster. This can be used for debugging purposes, or */
1133
/* simply to allow implementation-specific `features' in a given */
1134
/* raster module. */
1137
/* raster :: A handle to the new raster object. */
1139
/* mode :: A 4-byte tag used to name the mode or property. */
1141
/* args :: A pointer to the new mode/property to use. */
1144
(*QT_FT_Raster_SetModeFunc)( QT_FT_Raster raster,
1148
#define QT_FT_Raster_Set_Mode_Func QT_FT_Raster_SetModeFunc
1150
/*************************************************************************/
1153
/* QT_FT_Raster_RenderFunc */
1156
/* Invokes a given raster to scan-convert a given glyph image into a */
1157
/* target bitmap. */
1160
/* raster :: A handle to the raster object. */
1162
/* params :: A pointer to a QT_FT_Raster_Params structure used to store */
1163
/* the rendering parameters. */
1166
/* Error code. 0 means success. */
1169
/* The exact format of the source image depends on the raster's glyph */
1170
/* format defined in its QT_FT_Raster_Funcs structure. It can be an */
1171
/* QT_FT_Outline or anything else in order to support a large array of */
1172
/* glyph formats. */
1174
/* Note also that the render function can fail and return a */
1175
/* QT_FT_Err_Unimplemented_Feature error code if the raster used does */
1176
/* not support direct composition. */
1178
/* XXX: For now, the standard raster doesn't support direct */
1179
/* composition but this should change for the final release (see */
1180
/* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */
1181
/* examples of distinct implementations which support direct */
1185
(*QT_FT_Raster_RenderFunc)( QT_FT_Raster raster,
1186
QT_FT_Raster_Params* params );
1188
#define QT_FT_Raster_Render_Func QT_FT_Raster_RenderFunc
1190
/*************************************************************************/
1193
/* QT_FT_Raster_Funcs */
1196
/* A structure used to describe a given raster class to the library. */
1199
/* glyph_format :: The supported glyph format for this raster. */
1201
/* raster_new :: The raster constructor. */
1203
/* raster_reset :: Used to reset the render pool within the raster. */
1205
/* raster_render :: A function to render a glyph into a given bitmap. */
1207
/* raster_done :: The raster destructor. */
1209
typedef struct QT_FT_Raster_Funcs_
1211
QT_FT_Glyph_Format glyph_format;
1212
QT_FT_Raster_NewFunc raster_new;
1213
QT_FT_Raster_ResetFunc raster_reset;
1214
QT_FT_Raster_SetModeFunc raster_set_mode;
1215
QT_FT_Raster_RenderFunc raster_render;
1216
QT_FT_Raster_DoneFunc raster_done;
1218
} QT_FT_Raster_Funcs;
1226
#endif /* __FTIMAGE_H__ */