1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 /***************************************************************************/
46 /* FreeType glyph image formats and default raster interface */
47 /* (specification). */
49 /* Copyright 1996-2001, 2002, 2003, 2004 by */
50 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
52 /* This file is part of the FreeType project, and may only be used, */
53 /* modified, and distributed under the terms of the FreeType project */
54 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
55 /* this file you indicate that you have read the license and */
56 /* understand and accept it fully. */
58 /***************************************************************************/
60 /*************************************************************************/
62 /* Note: A `raster' is simply a scan-line converter, used to render */
63 /* QT_FT_Outlines into QT_FT_Bitmaps. */
65 /*************************************************************************/
68 #ifndef __QT_FTIMAGE_H__
69 #define __QT_FTIMAGE_H__
75 // This file is not part of the Qt API. It exists purely as an
76 // implementation detail. This header file may change from version to
77 // version without notice, or even be removed.
84 /*************************************************************************/
89 /*************************************************************************/
92 /*************************************************************************/
98 /* The type QT_FT_Pos is a 32-bit integer used to store vectorial */
99 /* coordinates. Depending on the context, these can represent */
100 /* distances in integer font units, or 16,16, or 26.6 fixed float */
101 /* pixel coordinates. */
103 typedef signed int QT_FT_Pos;
106 /*************************************************************************/
112 /* A simple structure used to store a 2D vector; coordinates are of */
113 /* the QT_FT_Pos type. */
116 /* x :: The horizontal coordinate. */
117 /* y :: The vertical coordinate. */
119 typedef struct QT_FT_Vector_
127 /*************************************************************************/
133 /* A structure used to hold an outline's bounding box, i.e., the */
134 /* coordinates of its extrema in the horizontal and vertical */
138 /* xMin :: The horizontal minimum (left-most). */
140 /* yMin :: The vertical minimum (bottom-most). */
142 /* xMax :: The horizontal maximum (right-most). */
144 /* yMax :: The vertical maximum (top-most). */
146 typedef struct QT_FT_BBox_
148 QT_FT_Pos xMin, yMin;
149 QT_FT_Pos xMax, yMax;
154 /*************************************************************************/
157 /* QT_FT_Pixel_Mode */
160 /* An enumeration type used to describe the format of pixels in a */
161 /* given bitmap. Note that additional formats may be added in the */
165 /* QT_FT_PIXEL_MODE_NONE :: */
166 /* Value 0 is reserved. */
168 /* QT_FT_PIXEL_MODE_MONO :: */
169 /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */
170 /* are stored in most-significant order (MSB), which means that */
171 /* the left-most pixel in a byte has value 128. */
173 /* QT_FT_PIXEL_MODE_GRAY :: */
174 /* An 8-bit bitmap, generally used to represent anti-aliased glyph */
175 /* images. Each pixel is stored in one byte. Note that the number */
176 /* of value "gray" levels is stored in the `num_bytes' field of */
177 /* the @QT_FT_Bitmap structure (it generally is 256). */
179 /* QT_FT_PIXEL_MODE_GRAY2 :: */
180 /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */
181 /* bitmaps in font files according to the OpenType specification. */
182 /* We haven't found a single font using this format, however. */
184 /* QT_FT_PIXEL_MODE_GRAY4 :: */
185 /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */
186 /* bitmaps in font files according to the OpenType specification. */
187 /* We haven't found a single font using this format, however. */
189 /* QT_FT_PIXEL_MODE_LCD :: */
190 /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
191 /* images used for display on LCD displays; the bitmap's width is */
192 /* three times wider than the original glyph image. See also */
193 /* @QT_FT_RENDER_MODE_LCD. */
195 /* QT_FT_PIXEL_MODE_LCD_V :: */
196 /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
197 /* images used for display on rotated LCD displays; the bitmap's */
198 /* height is three times taller than the original glyph image. */
199 /* See also @QT_FT_RENDER_MODE_LCD_V. */
201 typedef enum QT_FT_Pixel_Mode_
203 QT_FT_PIXEL_MODE_NONE = 0,
204 QT_FT_PIXEL_MODE_MONO,
205 QT_FT_PIXEL_MODE_GRAY,
206 QT_FT_PIXEL_MODE_GRAY2,
207 QT_FT_PIXEL_MODE_GRAY4,
208 QT_FT_PIXEL_MODE_LCD,
209 QT_FT_PIXEL_MODE_LCD_V,
211 QT_FT_PIXEL_MODE_MAX /* do not remove */
216 /*************************************************************************/
219 /* qt_ft_pixel_mode_xxx */
222 /* A list of deprecated constants. Use the corresponding */
223 /* @QT_FT_Pixel_Mode values instead. */
226 /* qt_ft_pixel_mode_none :: see @QT_FT_PIXEL_MODE_NONE */
227 /* qt_ft_pixel_mode_mono :: see @QT_FT_PIXEL_MODE_MONO */
228 /* qt_ft_pixel_mode_grays :: see @QT_FT_PIXEL_MODE_GRAY */
229 /* qt_ft_pixel_mode_pal2 :: see @QT_FT_PIXEL_MODE_GRAY2 */
230 /* qt_ft_pixel_mode_pal4 :: see @QT_FT_PIXEL_MODE_GRAY4 */
232 #define qt_ft_pixel_mode_none QT_FT_PIXEL_MODE_NONE
233 #define qt_ft_pixel_mode_mono QT_FT_PIXEL_MODE_MONO
234 #define qt_ft_pixel_mode_grays QT_FT_PIXEL_MODE_GRAY
235 #define qt_ft_pixel_mode_pal2 QT_FT_PIXEL_MODE_GRAY2
236 #define qt_ft_pixel_mode_pal4 QT_FT_PIXEL_MODE_GRAY4
242 /*************************************************************************/
245 /* QT_FT_Palette_Mode */
248 /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
250 /* An enumeration type used to describe the format of a bitmap */
251 /* palette, used with qt_ft_pixel_mode_pal4 and qt_ft_pixel_mode_pal8. */
254 /* qt_ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */
257 /* qt_ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */
261 /* As qt_ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */
262 /* FreeType, these types are not handled by the library itself. */
264 typedef enum QT_FT_Palette_Mode_
266 qt_ft_palette_mode_rgb = 0,
267 qt_ft_palette_mode_rgba,
269 qt_ft_palettte_mode_max /* do not remove */
271 } QT_FT_Palette_Mode;
278 /*************************************************************************/
284 /* A structure used to describe a bitmap or pixmap to the raster. */
285 /* Note that we now manage pixmaps of various depths through the */
286 /* `pixel_mode' field. */
289 /* rows :: The number of bitmap rows. */
291 /* width :: The number of pixels in bitmap row. */
293 /* pitch :: The pitch's absolute value is the number of bytes */
294 /* taken by one bitmap row, including padding. */
295 /* However, the pitch is positive when the bitmap has */
296 /* a `down' flow, and negative when it has an `up' */
297 /* flow. In all cases, the pitch is an offset to add */
298 /* to a bitmap pointer in order to go down one row. */
300 /* buffer :: A typeless pointer to the bitmap buffer. This */
301 /* value should be aligned on 32-bit boundaries in */
304 /* num_grays :: This field is only used with */
305 /* `QT_FT_PIXEL_MODE_GRAY'; it gives the number of gray */
306 /* levels used in the bitmap. */
308 /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
309 /* See @QT_FT_Pixel_Mode for possible values. */
311 /* palette_mode :: This field is only used with paletted pixel modes; */
312 /* it indicates how the palette is stored. */
314 /* palette :: A typeless pointer to the bitmap palette; only */
315 /* used for paletted pixel modes. */
318 /* For now, the only pixel mode supported by FreeType are mono and */
319 /* grays. However, drivers might be added in the future to support */
320 /* more `colorful' options. */
322 /* When using pixel modes pal2, pal4 and pal8 with a void `palette' */
323 /* field, a gray pixmap with respectively 4, 16, and 256 levels of */
324 /* gray is assumed. This, in order to be compatible with some */
325 /* embedded bitmap formats defined in the TrueType specification. */
327 /* Note that no font was found presenting such embedded bitmaps, so */
328 /* this is currently completely unhandled by the library. */
330 typedef struct QT_FT_Bitmap_
335 unsigned char* buffer;
344 /*************************************************************************/
347 /* outline_processing */
349 /*************************************************************************/
352 /*************************************************************************/
358 /* This structure is used to describe an outline to the scan-line */
362 /* n_contours :: The number of contours in the outline. */
364 /* n_points :: The number of points in the outline. */
366 /* points :: A pointer to an array of `n_points' QT_FT_Vector */
367 /* elements, giving the outline's point coordinates. */
369 /* tags :: A pointer to an array of `n_points' chars, giving */
370 /* each outline point's type. If bit 0 is unset, the */
371 /* point is `off' the curve, i.e. a Bezier control */
372 /* point, while it is `on' when set. */
374 /* Bit 1 is meaningful for `off' points only. If set, */
375 /* it indicates a third-order Bezier arc control point; */
376 /* and a second-order control point if unset. */
378 /* contours :: An array of `n_contours' shorts, giving the end */
379 /* point of each contour within the outline. For */
380 /* example, the first contour is defined by the points */
381 /* `0' to `contours[0]', the second one is defined by */
382 /* the points `contours[0]+1' to `contours[1]', etc. */
384 /* flags :: A set of bit flags used to characterize the outline */
385 /* and give hints to the scan-converter and hinter on */
386 /* how to convert/grid-fit it. See QT_FT_Outline_Flags. */
388 typedef struct QT_FT_Outline_
390 int n_contours; /* number of contours in glyph */
391 int n_points; /* number of points in the glyph */
393 QT_FT_Vector* points; /* the outline's points */
394 char* tags; /* the points flags */
395 int* contours; /* the contour end points */
397 int flags; /* outline masks */
402 /*************************************************************************/
405 /* QT_FT_OUTLINE_FLAGS */
408 /* A list of bit-field constants use for the flags in an outline's */
412 /* QT_FT_OUTLINE_NONE :: Value 0 is reserved. */
414 /* QT_FT_OUTLINE_OWNER :: If set, this flag indicates that the */
415 /* outline's field arrays (i.e. */
416 /* `points', `flags' & `contours') are */
417 /* `owned' by the outline object, and */
418 /* should thus be freed when it is */
421 /* QT_FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */
422 /* the non-zero winding rule. If set to */
423 /* 1, the outline will be filled using */
424 /* the even-odd fill rule (only works */
425 /* with the smooth raster). */
427 /* QT_FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */
428 /* outline are oriented in clock-wise */
429 /* direction, as defined in the TrueType */
430 /* specification. This flag is set if */
431 /* the outline uses the opposite */
432 /* direction (typically for Type 1 */
433 /* fonts). This flag is ignored by the */
434 /* scan-converter. However, it is very */
435 /* important for the auto-hinter. */
437 /* QT_FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */
438 /* try to detect drop-outs in an outline */
439 /* and correct the glyph bitmap to */
440 /* ensure consistent shape continuity. */
441 /* If set, this flag hints the scan-line */
442 /* converter to ignore such cases. */
444 /* QT_FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */
445 /* scan-line converter should try to */
446 /* convert this outline to bitmaps with */
447 /* the highest possible quality. It is */
448 /* typically set for small character */
449 /* sizes. Note that this is only a */
450 /* hint, that might be completely */
451 /* ignored by a given scan-converter. */
453 /* QT_FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */
454 /* scan-converter to only use a single */
455 /* pass over the outline to render a */
456 /* bitmap glyph image. Normally, it is */
457 /* set for very large character sizes. */
458 /* It is only a hint, that might be */
459 /* completely ignored by a given */
460 /* scan-converter. */
462 #define QT_FT_OUTLINE_NONE 0x0
463 #define QT_FT_OUTLINE_OWNER 0x1
464 #define QT_FT_OUTLINE_EVEN_ODD_FILL 0x2
465 #define QT_FT_OUTLINE_REVERSE_FILL 0x4
466 #define QT_FT_OUTLINE_IGNORE_DROPOUTS 0x8
468 #define QT_FT_OUTLINE_HIGH_PRECISION 0x100
469 #define QT_FT_OUTLINE_SINGLE_PASS 0x200
472 /*************************************************************************
475 * qt_ft_outline_flags
478 * These constants are deprecated. Please use the corresponding
479 * @QT_FT_OUTLINE_FLAGS values.
482 * qt_ft_outline_none :: See @QT_FT_OUTLINE_NONE.
483 * qt_ft_outline_owner :: See @QT_FT_OUTLINE_OWNER.
484 * qt_ft_outline_even_odd_fill :: See @QT_FT_OUTLINE_EVEN_ODD_FILL.
485 * qt_ft_outline_reverse_fill :: See @QT_FT_OUTLINE_REVERSE_FILL.
486 * qt_ft_outline_ignore_dropouts :: See @QT_FT_OUTLINE_IGNORE_DROPOUTS.
487 * qt_ft_outline_high_precision :: See @QT_FT_OUTLINE_HIGH_PRECISION.
488 * qt_ft_outline_single_pass :: See @QT_FT_OUTLINE_SINGLE_PASS.
490 #define qt_ft_outline_none QT_FT_OUTLINE_NONE
491 #define qt_ft_outline_owner QT_FT_OUTLINE_OWNER
492 #define qt_ft_outline_even_odd_fill QT_FT_OUTLINE_EVEN_ODD_FILL
493 #define qt_ft_outline_reverse_fill QT_FT_OUTLINE_REVERSE_FILL
494 #define qt_ft_outline_ignore_dropouts QT_FT_OUTLINE_IGNORE_DROPOUTS
495 #define qt_ft_outline_high_precision QT_FT_OUTLINE_HIGH_PRECISION
496 #define qt_ft_outline_single_pass QT_FT_OUTLINE_SINGLE_PASS
500 #define QT_FT_CURVE_TAG( flag ) ( flag & 3 )
502 #define QT_FT_CURVE_TAG_ON 1
503 #define QT_FT_CURVE_TAG_CONIC 0
504 #define QT_FT_CURVE_TAG_CUBIC 2
506 #define QT_FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
507 #define QT_FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
509 #define QT_FT_CURVE_TAG_TOUCH_BOTH ( QT_FT_CURVE_TAG_TOUCH_X | \
510 QT_FT_CURVE_TAG_TOUCH_Y )
512 #define QT_FT_Curve_Tag_On QT_FT_CURVE_TAG_ON
513 #define QT_FT_Curve_Tag_Conic QT_FT_CURVE_TAG_CONIC
514 #define QT_FT_Curve_Tag_Cubic QT_FT_CURVE_TAG_CUBIC
515 #define QT_FT_Curve_Tag_Touch_X QT_FT_CURVE_TAG_TOUCH_X
516 #define QT_FT_Curve_Tag_Touch_Y QT_FT_CURVE_TAG_TOUCH_Y
518 /*************************************************************************/
521 /* QT_FT_Outline_MoveToFunc */
524 /* A function pointer type used to describe the signature of a `move */
525 /* to' function during outline walking/decomposition. */
527 /* A `move to' is emitted to start a new contour in an outline. */
530 /* to :: A pointer to the target point of the `move to'. */
532 /* user :: A typeless pointer which is passed from the caller of the */
533 /* decomposition function. */
536 /* Error code. 0 means success. */
539 (*QT_FT_Outline_MoveToFunc)( QT_FT_Vector* to,
542 #define QT_FT_Outline_MoveTo_Func QT_FT_Outline_MoveToFunc
544 /*************************************************************************/
547 /* QT_FT_Outline_LineToFunc */
550 /* A function pointer type used to describe the signature of a `line */
551 /* to' function during outline walking/decomposition. */
553 /* A `line to' is emitted to indicate a segment in the outline. */
556 /* to :: A pointer to the target point of the `line to'. */
558 /* user :: A typeless pointer which is passed from the caller of the */
559 /* decomposition function. */
562 /* Error code. 0 means success. */
565 (*QT_FT_Outline_LineToFunc)( QT_FT_Vector* to,
568 #define QT_FT_Outline_LineTo_Func QT_FT_Outline_LineToFunc
570 /*************************************************************************/
573 /* QT_FT_Outline_ConicToFunc */
576 /* A function pointer type use to describe the signature of a `conic */
577 /* to' function during outline walking/decomposition. */
579 /* A `conic to' is emitted to indicate a second-order Bezier arc in */
583 /* control :: An intermediate control point between the last position */
584 /* and the new target in `to'. */
586 /* to :: A pointer to the target end point of the conic arc. */
588 /* user :: A typeless pointer which is passed from the caller of */
589 /* the decomposition function. */
592 /* Error code. 0 means success. */
595 (*QT_FT_Outline_ConicToFunc)( QT_FT_Vector* control,
599 #define QT_FT_Outline_ConicTo_Func QT_FT_Outline_ConicToFunc
601 /*************************************************************************/
604 /* QT_FT_Outline_CubicToFunc */
607 /* A function pointer type used to describe the signature of a `cubic */
608 /* to' function during outline walking/decomposition. */
610 /* A `cubic to' is emitted to indicate a third-order Bezier arc. */
613 /* control1 :: A pointer to the first Bezier control point. */
615 /* control2 :: A pointer to the second Bezier control point. */
617 /* to :: A pointer to the target end point. */
619 /* user :: A typeless pointer which is passed from the caller of */
620 /* the decomposition function. */
623 /* Error code. 0 means success. */
626 (*QT_FT_Outline_CubicToFunc)( QT_FT_Vector* control1,
627 QT_FT_Vector* control2,
631 #define QT_FT_Outline_CubicTo_Func QT_FT_Outline_CubicToFunc
634 /*************************************************************************/
637 /* QT_FT_Outline_Funcs */
640 /* A structure to hold various function pointers used during outline */
641 /* decomposition in order to emit segments, conic, and cubic Beziers, */
642 /* as well as `move to' and `close to' operations. */
645 /* move_to :: The `move to' emitter. */
647 /* line_to :: The segment emitter. */
649 /* conic_to :: The second-order Bezier arc emitter. */
651 /* cubic_to :: The third-order Bezier arc emitter. */
653 /* shift :: The shift that is applied to coordinates before they */
654 /* are sent to the emitter. */
656 /* delta :: The delta that is applied to coordinates before they */
657 /* are sent to the emitter, but after the shift. */
660 /* The point coordinates sent to the emitters are the transformed */
661 /* version of the original coordinates (this is important for high */
662 /* accuracy during scan-conversion). The transformation is simple: */
664 /* x' = (x << shift) - delta */
665 /* y' = (x << shift) - delta */
667 /* Set the value of `shift' and `delta' to 0 to get the original */
668 /* point coordinates. */
670 typedef struct QT_FT_Outline_Funcs_
672 QT_FT_Outline_MoveToFunc move_to;
673 QT_FT_Outline_LineToFunc line_to;
674 QT_FT_Outline_ConicToFunc conic_to;
675 QT_FT_Outline_CubicToFunc cubic_to;
680 } QT_FT_Outline_Funcs;
683 /*************************************************************************/
688 /*************************************************************************/
691 /*************************************************************************/
694 /* QT_FT_IMAGE_TAG */
697 /* This macro converts four letter tags into an unsigned long. */
700 /* Since many 16bit compilers don't like 32bit enumerations, you */
701 /* should redefine this macro in case of problems to something like */
704 /* #define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
706 /* to get a simple enumeration without assigning special numbers. */
708 #ifndef QT_FT_IMAGE_TAG
709 #define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
710 value = ( ( (unsigned long)_x1 << 24 ) | \
711 ( (unsigned long)_x2 << 16 ) | \
712 ( (unsigned long)_x3 << 8 ) | \
714 #endif /* QT_FT_IMAGE_TAG */
717 /*************************************************************************/
720 /* QT_FT_Glyph_Format */
723 /* An enumeration type used to describe the format of a given glyph */
724 /* image. Note that this version of FreeType only supports two image */
725 /* formats, even though future font drivers will be able to register */
726 /* their own format. */
729 /* QT_FT_GLYPH_FORMAT_NONE :: */
730 /* The value 0 is reserved and does describe a glyph format. */
732 /* QT_FT_GLYPH_FORMAT_COMPOSITE :: */
733 /* The glyph image is a composite of several other images. This */
734 /* format is _only_ used with @QT_FT_LOAD_NO_RECURSE, and is used to */
735 /* report compound glyphs (like accented characters). */
737 /* QT_FT_GLYPH_FORMAT_BITMAP :: */
738 /* The glyph image is a bitmap, and can be described as an */
739 /* @QT_FT_Bitmap. You generally need to access the `bitmap' field of */
740 /* the @QT_FT_GlyphSlotRec structure to read it. */
742 /* QT_FT_GLYPH_FORMAT_OUTLINE :: */
743 /* The glyph image is a vertorial outline made of line segments */
744 /* and Bezier arcs; it can be described as an @QT_FT_Outline; you */
745 /* generally want to access the `outline' field of the */
746 /* @QT_FT_GlyphSlotRec structure to read it. */
748 /* QT_FT_GLYPH_FORMAT_PLOTTER :: */
749 /* The glyph image is a vectorial path with no inside/outside */
750 /* contours. Some Type 1 fonts, like those in the Hershey family, */
751 /* contain glyphs in this format. These are described as */
752 /* @QT_FT_Outline, but FreeType isn't currently capable of rendering */
753 /* them correctly. */
755 typedef enum QT_FT_Glyph_Format_
757 QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
759 QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
760 QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
761 QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
762 QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
764 } QT_FT_Glyph_Format;
767 /*************************************************************************/
770 /* qt_ft_glyph_format_xxx */
773 /* A list of decprecated constants. Use the corresponding */
774 /* @QT_FT_Glyph_Format values instead. */
777 /* qt_ft_glyph_format_none :: see @QT_FT_GLYPH_FORMAT_NONE */
778 /* qt_ft_glyph_format_composite :: see @QT_FT_GLYPH_FORMAT_COMPOSITE */
779 /* qt_ft_glyph_format_bitmap :: see @QT_FT_GLYPH_FORMAT_BITMAP */
780 /* qt_ft_glyph_format_outline :: see @QT_FT_GLYPH_FORMAT_OUTLINE */
781 /* qt_ft_glyph_format_plotter :: see @QT_FT_GLYPH_FORMAT_PLOTTER */
783 #define qt_ft_glyph_format_none QT_FT_GLYPH_FORMAT_NONE
784 #define qt_ft_glyph_format_composite QT_FT_GLYPH_FORMAT_COMPOSITE
785 #define qt_ft_glyph_format_bitmap QT_FT_GLYPH_FORMAT_BITMAP
786 #define qt_ft_glyph_format_outline QT_FT_GLYPH_FORMAT_OUTLINE
787 #define qt_ft_glyph_format_plotter QT_FT_GLYPH_FORMAT_PLOTTER
790 /*************************************************************************/
791 /*************************************************************************/
792 /*************************************************************************/
794 /***** R A S T E R D E F I N I T I O N S *****/
796 /*************************************************************************/
797 /*************************************************************************/
798 /*************************************************************************/
801 /*************************************************************************/
803 /* A raster is a scan converter, in charge of rendering an outline into */
804 /* a a bitmap. This section contains the public API for rasters. */
806 /* Note that in FreeType 2, all rasters are now encapsulated within */
807 /* specific modules called `renderers'. See `freetype/ftrender.h' for */
808 /* more details on renderers. */
810 /*************************************************************************/
813 /*************************************************************************/
819 /* Scanline converter */
822 /* How vectorial outlines are converted into bitmaps and pixmaps. */
825 /* This section contains technical definitions. */
827 /*************************************************************************/
830 /*************************************************************************/
836 /* A handle (pointer) to a raster object. Each object can be used */
837 /* independently to convert an outline into a bitmap or pixmap. */
839 typedef struct TRaster_ *QT_FT_Raster;
842 /*************************************************************************/
848 /* A structure used to model a single span of gray (or black) pixels */
849 /* when rendering a monochrome or anti-aliased bitmap. */
852 /* x :: The span's horizontal start position. */
854 /* len :: The span's length in pixels. */
856 /* coverage :: The span color/coverage, ranging from 0 (background) */
857 /* to 255 (foreground). Only used for anti-aliased */
861 /* This structure is used by the span drawing callback type named */
862 /* QT_FT_SpanFunc which takes the y-coordinate of the span as a */
865 /* The coverage value is always between 0 and 255, even if the number */
866 /* of gray levels have been set through QT_FT_Set_Gray_Levels(). */
868 typedef struct QT_FT_Span_
873 unsigned char coverage;
877 /*************************************************************************/
883 /* A function used as a call-back by the anti-aliased renderer in */
884 /* order to let client applications draw themselves the gray pixel */
885 /* spans on each scan line. */
888 /* y :: The scanline's y-coordinate. */
890 /* count :: The number of spans to draw on this scanline. */
892 /* spans :: A table of `count' spans to draw on the scanline. */
894 /* user :: User-supplied data that is passed to the callback. */
897 /* This callback allows client applications to directly render the */
898 /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
900 /* This can be used to write anti-aliased outlines directly to a */
901 /* given background bitmap, and even perform translucency. */
903 /* Note that the `count' field cannot be greater than a fixed value */
904 /* defined by the QT_FT_MAX_GRAY_SPANS configuration macro in */
905 /* ftoption.h. By default, this value is set to 32, which means that */
906 /* if there are more than 32 spans on a given scanline, the callback */
907 /* will be called several times with the same `y' parameter in order */
908 /* to draw all callbacks. */
910 /* Otherwise, the callback is only called once per scan-line, and */
911 /* only for those scanlines that do have `gray' pixels on them. */
914 (*QT_FT_SpanFunc)(int count,
915 const QT_FT_Span* spans,
918 #define QT_FT_Raster_Span_Func QT_FT_SpanFunc
921 /*************************************************************************/
924 /* QT_FT_Raster_BitTest_Func */
927 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
929 /* A function used as a call-back by the monochrome scan-converter */
930 /* to test whether a given target pixel is already set to the drawing */
931 /* `color'. These tests are crucial to implement drop-out control */
932 /* per-se the TrueType spec. */
935 /* y :: The pixel's y-coordinate. */
937 /* x :: The pixel's x-coordinate. */
939 /* user :: User-supplied data that is passed to the callback. */
942 /* 1 if the pixel is `set', 0 otherwise. */
945 (*QT_FT_Raster_BitTest_Func)( int y,
950 /*************************************************************************/
953 /* QT_FT_Raster_BitSet_Func */
956 /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
958 /* A function used as a call-back by the monochrome scan-converter */
959 /* to set an individual target pixel. This is crucial to implement */
960 /* drop-out control according to the TrueType specification. */
963 /* y :: The pixel's y-coordinate. */
965 /* x :: The pixel's x-coordinate. */
967 /* user :: User-supplied data that is passed to the callback. */
970 /* 1 if the pixel is `set', 0 otherwise. */
973 (*QT_FT_Raster_BitSet_Func)( int y,
978 /*************************************************************************/
981 /* QT_FT_RASTER_FLAG_XXX */
984 /* A list of bit flag constants as used in the `flags' field of a */
985 /* @QT_FT_Raster_Params structure. */
988 /* QT_FT_RASTER_FLAG_DEFAULT :: This value is 0. */
990 /* QT_FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
991 /* anti-aliased glyph image should be */
992 /* generated. Otherwise, it will be */
993 /* monochrome (1-bit). */
995 /* QT_FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
996 /* rendering. In this mode, client */
997 /* applications must provide their own span */
998 /* callback. This lets them directly */
999 /* draw or compose over an existing bitmap. */
1000 /* If this bit is not set, the target */
1001 /* pixmap's buffer _must_ be zeroed before */
1004 /* Note that for now, direct rendering is */
1005 /* only possible with anti-aliased glyphs. */
1007 /* QT_FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
1008 /* rendering mode. If set, the output will */
1009 /* be clipped to a box specified in the */
1010 /* "clip_box" field of the QT_FT_Raster_Params */
1013 /* Note that by default, the glyph bitmap */
1014 /* is clipped to the target pixmap, except */
1015 /* in direct rendering mode where all spans */
1016 /* are generated if no clipping box is set. */
1018 #define QT_FT_RASTER_FLAG_DEFAULT 0x0
1019 #define QT_FT_RASTER_FLAG_AA 0x1
1020 #define QT_FT_RASTER_FLAG_DIRECT 0x2
1021 #define QT_FT_RASTER_FLAG_CLIP 0x4
1024 #define qt_ft_raster_flag_default QT_FT_RASTER_FLAG_DEFAULT
1025 #define qt_ft_raster_flag_aa QT_FT_RASTER_FLAG_AA
1026 #define qt_ft_raster_flag_direct QT_FT_RASTER_FLAG_DIRECT
1027 #define qt_ft_raster_flag_clip QT_FT_RASTER_FLAG_CLIP
1030 /*************************************************************************/
1033 /* QT_FT_Raster_Params */
1036 /* A structure to hold the arguments used by a raster's render */
1040 /* target :: The target bitmap. */
1042 /* source :: A pointer to the source glyph image (e.g. an */
1043 /* QT_FT_Outline). */
1045 /* flags :: The rendering flags. */
1047 /* gray_spans :: The gray span drawing callback. */
1049 /* black_spans :: The black span drawing callback. */
1051 /* bit_test :: The bit test callback. UNIMPLEMENTED! */
1053 /* bit_set :: The bit set callback. UNIMPLEMENTED! */
1055 /* user :: User-supplied data that is passed to each drawing */
1058 /* clip_box :: An optional clipping box. It is only used in */
1059 /* direct rendering mode. Note that coordinates here */
1060 /* should be expressed in _integer_ pixels (and not in */
1061 /* 26.6 fixed-point units). */
1064 /* An anti-aliased glyph bitmap is drawn if the QT_FT_RASTER_FLAG_AA bit */
1065 /* flag is set in the `flags' field, otherwise a monochrome bitmap */
1066 /* will be generated. */
1068 /* If the QT_FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
1069 /* raster will call the `gray_spans' callback to draw gray pixel */
1070 /* spans, in the case of an aa glyph bitmap, it will call */
1071 /* `black_spans', and `bit_test' and `bit_set' in the case of a */
1072 /* monochrome bitmap. This allows direct composition over a */
1073 /* pre-existing bitmap through user-provided callbacks to perform the */
1074 /* span drawing/composition. */
1076 /* Note that the `bit_test' and `bit_set' callbacks are required when */
1077 /* rendering a monochrome bitmap, as they are crucial to implement */
1078 /* correct drop-out control as defined in the TrueType specification. */
1080 typedef struct QT_FT_Raster_Params_
1082 QT_FT_Bitmap* target;
1085 QT_FT_SpanFunc gray_spans;
1086 QT_FT_SpanFunc black_spans;
1087 QT_FT_Raster_BitTest_Func bit_test; /* doesn't work! */
1088 QT_FT_Raster_BitSet_Func bit_set; /* doesn't work! */
1090 QT_FT_BBox clip_box;
1093 } QT_FT_Raster_Params;
1096 /*************************************************************************/
1099 /* QT_FT_Raster_NewFunc */
1102 /* A function used to create a new raster object. */
1105 /* memory :: A handle to the memory allocator. */
1108 /* raster :: A handle to the new raster object. */
1111 /* Error code. 0 means success. */
1114 /* The `memory' parameter is a typeless pointer in order to avoid */
1115 /* un-wanted dependencies on the rest of the FreeType code. In */
1116 /* practice, it is a QT_FT_Memory, i.e., a handle to the standard */
1117 /* FreeType memory allocator. However, this field can be completely */
1118 /* ignored by a given raster implementation. */
1121 (*QT_FT_Raster_NewFunc)( QT_FT_Raster* raster );
1123 #define QT_FT_Raster_New_Func QT_FT_Raster_NewFunc
1125 /*************************************************************************/
1128 /* QT_FT_Raster_DoneFunc */
1131 /* A function used to destroy a given raster object. */
1134 /* raster :: A handle to the raster object. */
1137 (*QT_FT_Raster_DoneFunc)( QT_FT_Raster raster );
1139 #define QT_FT_Raster_Done_Func QT_FT_Raster_DoneFunc
1141 /*************************************************************************/
1144 /* QT_FT_Raster_ResetFunc */
1147 /* FreeType provides an area of memory called the `render pool', */
1148 /* available to all registered rasters. This pool can be freely used */
1149 /* during a given scan-conversion but is shared by all rasters. Its */
1150 /* content is thus transient. */
1152 /* This function is called each time the render pool changes, or just */
1153 /* after a new raster object is created. */
1156 /* raster :: A handle to the new raster object. */
1158 /* pool_base :: The address in memory of the render pool. */
1160 /* pool_size :: The size in bytes of the render pool. */
1163 /* Rasters can ignore the render pool and rely on dynamic memory */
1164 /* allocation if they want to (a handle to the memory allocator is */
1165 /* passed to the raster constructor). However, this is not */
1166 /* recommended for efficiency purposes. */
1169 (*QT_FT_Raster_ResetFunc)( QT_FT_Raster raster,
1170 unsigned char* pool_base,
1171 unsigned long pool_size );
1173 #define QT_FT_Raster_Reset_Func QT_FT_Raster_ResetFunc
1175 /*************************************************************************/
1178 /* QT_FT_Raster_SetModeFunc */
1181 /* This function is a generic facility to change modes or attributes */
1182 /* in a given raster. This can be used for debugging purposes, or */
1183 /* simply to allow implementation-specific `features' in a given */
1184 /* raster module. */
1187 /* raster :: A handle to the new raster object. */
1189 /* mode :: A 4-byte tag used to name the mode or property. */
1191 /* args :: A pointer to the new mode/property to use. */
1194 (*QT_FT_Raster_SetModeFunc)( QT_FT_Raster raster,
1198 #define QT_FT_Raster_Set_Mode_Func QT_FT_Raster_SetModeFunc
1200 /*************************************************************************/
1203 /* QT_FT_Raster_RenderFunc */
1206 /* Invokes a given raster to scan-convert a given glyph image into a */
1207 /* target bitmap. */
1210 /* raster :: A handle to the raster object. */
1212 /* params :: A pointer to a QT_FT_Raster_Params structure used to store */
1213 /* the rendering parameters. */
1216 /* Error code. 0 means success. */
1219 /* The exact format of the source image depends on the raster's glyph */
1220 /* format defined in its QT_FT_Raster_Funcs structure. It can be an */
1221 /* QT_FT_Outline or anything else in order to support a large array of */
1222 /* glyph formats. */
1224 /* Note also that the render function can fail and return a */
1225 /* QT_FT_Err_Unimplemented_Feature error code if the raster used does */
1226 /* not support direct composition. */
1228 /* XXX: For now, the standard raster doesn't support direct */
1229 /* composition but this should change for the final release (see */
1230 /* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */
1231 /* examples of distinct implementations which support direct */
1235 (*QT_FT_Raster_RenderFunc)( QT_FT_Raster raster,
1236 QT_FT_Raster_Params* params );
1238 #define QT_FT_Raster_Render_Func QT_FT_Raster_RenderFunc
1240 /*************************************************************************/
1243 /* QT_FT_Raster_Funcs */
1246 /* A structure used to describe a given raster class to the library. */
1249 /* glyph_format :: The supported glyph format for this raster. */
1251 /* raster_new :: The raster constructor. */
1253 /* raster_reset :: Used to reset the render pool within the raster. */
1255 /* raster_render :: A function to render a glyph into a given bitmap. */
1257 /* raster_done :: The raster destructor. */
1259 typedef struct QT_FT_Raster_Funcs_
1261 QT_FT_Glyph_Format glyph_format;
1262 QT_FT_Raster_NewFunc raster_new;
1263 QT_FT_Raster_ResetFunc raster_reset;
1264 QT_FT_Raster_SetModeFunc raster_set_mode;
1265 QT_FT_Raster_RenderFunc raster_render;
1266 QT_FT_Raster_DoneFunc raster_done;
1268 } QT_FT_Raster_Funcs;
1276 #endif /* __FTIMAGE_H__ */