Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/freetype/include/ftimage.h

Issue 1413673003: Update bundled freetype to 2.6.1 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: DEPS for corpus Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/freetype/include/ftgzip.h ('k') | third_party/freetype/include/ftincrem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /***************************************************************************/
2 /* */
3 /* ftimage.h */
4 /* */
5 /* FreeType glyph image formats and default raster interface */
6 /* (specification). */
7 /* */
8 /* Copyright 1996-2010, 2013, 2014 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 /* _STANDALONE_ is from ftgrays.c */
32 #ifndef _STANDALONE_
33 #include <ft2build.h>
34 #endif
35
36
37 FT_BEGIN_HEADER
38
39
40 /*************************************************************************/
41 /* */
42 /* <Section> */
43 /* basic_types */
44 /* */
45 /*************************************************************************/
46
47
48 /*************************************************************************/
49 /* */
50 /* <Type> */
51 /* FT_Pos */
52 /* */
53 /* <Description> */
54 /* The type FT_Pos is used to store vectorial coordinates. Depending */
55 /* on the context, these can represent distances in integer font */
56 /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */
57 /* */
58 typedef signed long FT_Pos;
59
60
61 /*************************************************************************/
62 /* */
63 /* <Struct> */
64 /* FT_Vector */
65 /* */
66 /* <Description> */
67 /* A simple structure used to store a 2D vector; coordinates are of */
68 /* the FT_Pos type. */
69 /* */
70 /* <Fields> */
71 /* x :: The horizontal coordinate. */
72 /* y :: The vertical coordinate. */
73 /* */
74 typedef struct FT_Vector_
75 {
76 FT_Pos x;
77 FT_Pos y;
78
79 } FT_Vector;
80
81
82 /*************************************************************************/
83 /* */
84 /* <Struct> */
85 /* FT_BBox */
86 /* */
87 /* <Description> */
88 /* A structure used to hold an outline's bounding box, i.e., the */
89 /* coordinates of its extrema in the horizontal and vertical */
90 /* directions. */
91 /* */
92 /* <Fields> */
93 /* xMin :: The horizontal minimum (left-most). */
94 /* */
95 /* yMin :: The vertical minimum (bottom-most). */
96 /* */
97 /* xMax :: The horizontal maximum (right-most). */
98 /* */
99 /* yMax :: The vertical maximum (top-most). */
100 /* */
101 /* <Note> */
102 /* The bounding box is specified with the coordinates of the lower */
103 /* left and the upper right corner. In PostScript, those values are */
104 /* often called (llx,lly) and (urx,ury), respectively. */
105 /* */
106 /* If `yMin' is negative, this value gives the glyph's descender. */
107 /* Otherwise, the glyph doesn't descend below the baseline. */
108 /* Similarly, if `ymax' is positive, this value gives the glyph's */
109 /* ascender. */
110 /* */
111 /* `xMin' gives the horizontal distance from the glyph's origin to */
112 /* the left edge of the glyph's bounding box. If `xMin' is negative, */
113 /* the glyph extends to the left of the origin. */
114 /* */
115 typedef struct FT_BBox_
116 {
117 FT_Pos xMin, yMin;
118 FT_Pos xMax, yMax;
119
120 } FT_BBox;
121
122
123 /*************************************************************************/
124 /* */
125 /* <Enum> */
126 /* FT_Pixel_Mode */
127 /* */
128 /* <Description> */
129 /* An enumeration type used to describe the format of pixels in a */
130 /* given bitmap. Note that additional formats may be added in the */
131 /* future. */
132 /* */
133 /* <Values> */
134 /* FT_PIXEL_MODE_NONE :: */
135 /* Value~0 is reserved. */
136 /* */
137 /* FT_PIXEL_MODE_MONO :: */
138 /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */
139 /* are stored in most-significant order (MSB), which means that */
140 /* the left-most pixel in a byte has value 128. */
141 /* */
142 /* FT_PIXEL_MODE_GRAY :: */
143 /* An 8-bit bitmap, generally used to represent anti-aliased glyph */
144 /* images. Each pixel is stored in one byte. Note that the number */
145 /* of `gray' levels is stored in the `num_grays' field of the */
146 /* @FT_Bitmap structure (it generally is 256). */
147 /* */
148 /* FT_PIXEL_MODE_GRAY2 :: */
149 /* A 2-bit per pixel bitmap, used to represent embedded */
150 /* anti-aliased bitmaps in font files according to the OpenType */
151 /* specification. We haven't found a single font using this */
152 /* format, however. */
153 /* */
154 /* FT_PIXEL_MODE_GRAY4 :: */
155 /* A 4-bit per pixel bitmap, representing embedded anti-aliased */
156 /* bitmaps in font files according to the OpenType specification. */
157 /* We haven't found a single font using this format, however. */
158 /* */
159 /* FT_PIXEL_MODE_LCD :: */
160 /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
161 /* used for display on LCD displays; the bitmap is three times */
162 /* wider than the original glyph image. See also */
163 /* @FT_RENDER_MODE_LCD. */
164 /* */
165 /* FT_PIXEL_MODE_LCD_V :: */
166 /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
167 /* used for display on rotated LCD displays; the bitmap is three */
168 /* times taller than the original glyph image. See also */
169 /* @FT_RENDER_MODE_LCD_V. */
170 /* */
171 /* FT_PIXEL_MODE_BGRA :: */
172 /* An image with four 8-bit channels per pixel, representing a */
173 /* color image (such as emoticons) with alpha channel. For each */
174 /* pixel, the format is BGRA, which means, the blue channel comes */
175 /* first in memory. The color channels are pre-multiplied and in */
176 /* the sRGB colorspace. For example, full red at half-translucent */
177 /* opacity will be represented as `00,00,80,80', not `00,00,FF,80'. */
178 /* See also @FT_LOAD_COLOR. */
179 /* */
180 typedef enum FT_Pixel_Mode_
181 {
182 FT_PIXEL_MODE_NONE = 0,
183 FT_PIXEL_MODE_MONO,
184 FT_PIXEL_MODE_GRAY,
185 FT_PIXEL_MODE_GRAY2,
186 FT_PIXEL_MODE_GRAY4,
187 FT_PIXEL_MODE_LCD,
188 FT_PIXEL_MODE_LCD_V,
189 FT_PIXEL_MODE_BGRA,
190
191 FT_PIXEL_MODE_MAX /* do not remove */
192
193 } FT_Pixel_Mode;
194
195
196 /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */
197 /* values instead. */
198 #define ft_pixel_mode_none FT_PIXEL_MODE_NONE
199 #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
200 #define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
201 #define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
202 #define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
203
204
205 /*************************************************************************/
206 /* */
207 /* <Struct> */
208 /* FT_Bitmap */
209 /* */
210 /* <Description> */
211 /* A structure used to describe a bitmap or pixmap to the raster. */
212 /* Note that we now manage pixmaps of various depths through the */
213 /* `pixel_mode' field. */
214 /* */
215 /* <Fields> */
216 /* rows :: The number of bitmap rows. */
217 /* */
218 /* width :: The number of pixels in bitmap row. */
219 /* */
220 /* pitch :: The pitch's absolute value is the number of bytes */
221 /* taken by one bitmap row, including padding. */
222 /* However, the pitch is positive when the bitmap has */
223 /* a `down' flow, and negative when it has an `up' */
224 /* flow. In all cases, the pitch is an offset to add */
225 /* to a bitmap pointer in order to go down one row. */
226 /* */
227 /* Note that `padding' means the alignment of a */
228 /* bitmap to a byte border, and FreeType functions */
229 /* normally align to the smallest possible integer */
230 /* value. */
231 /* */
232 /* For the B/W rasterizer, `pitch' is always an even */
233 /* number. */
234 /* */
235 /* To change the pitch of a bitmap (say, to make it a */
236 /* multiple of 4), use @FT_Bitmap_Convert. */
237 /* Alternatively, you might use callback functions to */
238 /* directly render to the application's surface; see */
239 /* the file `example2.cpp' in the tutorial for a */
240 /* demonstration. */
241 /* */
242 /* buffer :: A typeless pointer to the bitmap buffer. This */
243 /* value should be aligned on 32-bit boundaries in */
244 /* most cases. */
245 /* */
246 /* num_grays :: This field is only used with */
247 /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */
248 /* levels used in the bitmap. */
249 /* */
250 /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
251 /* See @FT_Pixel_Mode for possible values. */
252 /* */
253 /* palette_mode :: This field is intended for paletted pixel modes; */
254 /* it indicates how the palette is stored. Not */
255 /* used currently. */
256 /* */
257 /* palette :: A typeless pointer to the bitmap palette; this */
258 /* field is intended for paletted pixel modes. Not */
259 /* used currently. */
260 /* */
261 /* <Note> */
262 /* For now, the only pixel modes supported by FreeType are mono and */
263 /* grays. However, drivers might be added in the future to support */
264 /* more `colorful' options. */
265 /* */
266 typedef struct FT_Bitmap_
267 {
268 unsigned int rows;
269 unsigned int width;
270 int pitch;
271 unsigned char* buffer;
272 unsigned short num_grays;
273 unsigned char pixel_mode;
274 unsigned char palette_mode;
275 void* palette;
276
277 } FT_Bitmap;
278
279
280 /*************************************************************************/
281 /* */
282 /* <Section> */
283 /* outline_processing */
284 /* */
285 /*************************************************************************/
286
287
288 /*************************************************************************/
289 /* */
290 /* <Struct> */
291 /* FT_Outline */
292 /* */
293 /* <Description> */
294 /* This structure is used to describe an outline to the scan-line */
295 /* converter. */
296 /* */
297 /* <Fields> */
298 /* n_contours :: The number of contours in the outline. */
299 /* */
300 /* n_points :: The number of points in the outline. */
301 /* */
302 /* points :: A pointer to an array of `n_points' @FT_Vector */
303 /* elements, giving the outline's point coordinates. */
304 /* */
305 /* tags :: A pointer to an array of `n_points' chars, giving */
306 /* each outline point's type. */
307 /* */
308 /* If bit~0 is unset, the point is `off' the curve, */
309 /* i.e., a Bézier control point, while it is `on' if */
310 /* set. */
311 /* */
312 /* Bit~1 is meaningful for `off' points only. If set, */
313 /* it indicates a third-order Bézier arc control point; */
314 /* and a second-order control point if unset. */
315 /* */
316 /* If bit~2 is set, bits 5-7 contain the drop-out mode */
317 /* (as defined in the OpenType specification; the value */
318 /* is the same as the argument to the SCANMODE */
319 /* instruction). */
320 /* */
321 /* Bits 3 and~4 are reserved for internal purposes. */
322 /* */
323 /* contours :: An array of `n_contours' shorts, giving the end */
324 /* point of each contour within the outline. For */
325 /* example, the first contour is defined by the points */
326 /* `0' to `contours[0]', the second one is defined by */
327 /* the points `contours[0]+1' to `contours[1]', etc. */
328 /* */
329 /* flags :: A set of bit flags used to characterize the outline */
330 /* and give hints to the scan-converter and hinter on */
331 /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */
332 /* */
333 /* <Note> */
334 /* The B/W rasterizer only checks bit~2 in the `tags' array for the */
335 /* first point of each contour. The drop-out mode as given with */
336 /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */
337 /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */
338 /* */
339 typedef struct FT_Outline_
340 {
341 short n_contours; /* number of contours in glyph */
342 short n_points; /* number of points in the glyph */
343
344 FT_Vector* points; /* the outline's points */
345 char* tags; /* the points flags */
346 short* contours; /* the contour end points */
347
348 int flags; /* outline masks */
349
350 } FT_Outline;
351
352 /* */
353
354 /* Following limits must be consistent with */
355 /* FT_Outline.{n_contours,n_points} */
356 #define FT_OUTLINE_CONTOURS_MAX SHRT_MAX
357 #define FT_OUTLINE_POINTS_MAX SHRT_MAX
358
359
360 /*************************************************************************/
361 /* */
362 /* <Enum> */
363 /* FT_OUTLINE_XXX */
364 /* */
365 /* <Description> */
366 /* A list of bit-field constants use for the flags in an outline's */
367 /* `flags' field. */
368 /* */
369 /* <Values> */
370 /* FT_OUTLINE_NONE :: */
371 /* Value~0 is reserved. */
372 /* */
373 /* FT_OUTLINE_OWNER :: */
374 /* If set, this flag indicates that the outline's field arrays */
375 /* (i.e., `points', `flags', and `contours') are `owned' by the */
376 /* outline object, and should thus be freed when it is destroyed. */
377 /* */
378 /* FT_OUTLINE_EVEN_ODD_FILL :: */
379 /* By default, outlines are filled using the non-zero winding rule. */
380 /* If set to 1, the outline will be filled using the even-odd fill */
381 /* rule (only works with the smooth rasterizer). */
382 /* */
383 /* FT_OUTLINE_REVERSE_FILL :: */
384 /* By default, outside contours of an outline are oriented in */
385 /* clock-wise direction, as defined in the TrueType specification. */
386 /* This flag is set if the outline uses the opposite direction */
387 /* (typically for Type~1 fonts). This flag is ignored by the scan */
388 /* converter. */
389 /* */
390 /* FT_OUTLINE_IGNORE_DROPOUTS :: */
391 /* By default, the scan converter will try to detect drop-outs in */
392 /* an outline and correct the glyph bitmap to ensure consistent */
393 /* shape continuity. If set, this flag hints the scan-line */
394 /* converter to ignore such cases. See below for more information. */
395 /* */
396 /* FT_OUTLINE_SMART_DROPOUTS :: */
397 /* Select smart dropout control. If unset, use simple dropout */
398 /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */
399 /* below for more information. */
400 /* */
401 /* FT_OUTLINE_INCLUDE_STUBS :: */
402 /* If set, turn pixels on for `stubs', otherwise exclude them. */
403 /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */
404 /* more information. */
405 /* */
406 /* FT_OUTLINE_HIGH_PRECISION :: */
407 /* This flag indicates that the scan-line converter should try to */
408 /* convert this outline to bitmaps with the highest possible */
409 /* quality. It is typically set for small character sizes. Note */
410 /* that this is only a hint that might be completely ignored by a */
411 /* given scan-converter. */
412 /* */
413 /* FT_OUTLINE_SINGLE_PASS :: */
414 /* This flag is set to force a given scan-converter to only use a */
415 /* single pass over the outline to render a bitmap glyph image. */
416 /* Normally, it is set for very large character sizes. It is only */
417 /* a hint that might be completely ignored by a given */
418 /* scan-converter. */
419 /* */
420 /* <Note> */
421 /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */
422 /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */
423 /* rasterizer. */
424 /* */
425 /* There exists a second mechanism to pass the drop-out mode to the */
426 /* B/W rasterizer; see the `tags' field in @FT_Outline. */
427 /* */
428 /* Please refer to the description of the `SCANTYPE' instruction in */
429 /* the OpenType specification (in file `ttinst1.doc') how simple */
430 /* drop-outs, smart drop-outs, and stubs are defined. */
431 /* */
432 #define FT_OUTLINE_NONE 0x0
433 #define FT_OUTLINE_OWNER 0x1
434 #define FT_OUTLINE_EVEN_ODD_FILL 0x2
435 #define FT_OUTLINE_REVERSE_FILL 0x4
436 #define FT_OUTLINE_IGNORE_DROPOUTS 0x8
437 #define FT_OUTLINE_SMART_DROPOUTS 0x10
438 #define FT_OUTLINE_INCLUDE_STUBS 0x20
439
440 #define FT_OUTLINE_HIGH_PRECISION 0x100
441 #define FT_OUTLINE_SINGLE_PASS 0x200
442
443
444 /* these constants are deprecated; use the corresponding */
445 /* `FT_OUTLINE_XXX' values instead */
446 #define ft_outline_none FT_OUTLINE_NONE
447 #define ft_outline_owner FT_OUTLINE_OWNER
448 #define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
449 #define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
450 #define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
451 #define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
452 #define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
453
454 /* */
455
456 #define FT_CURVE_TAG( flag ) ( flag & 3 )
457
458 #define FT_CURVE_TAG_ON 1
459 #define FT_CURVE_TAG_CONIC 0
460 #define FT_CURVE_TAG_CUBIC 2
461
462 #define FT_CURVE_TAG_HAS_SCANMODE 4
463
464 #define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
465 #define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
466
467 #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
468 FT_CURVE_TAG_TOUCH_Y )
469
470 #define FT_Curve_Tag_On FT_CURVE_TAG_ON
471 #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
472 #define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
473 #define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
474 #define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
475
476
477 /*************************************************************************/
478 /* */
479 /* <FuncType> */
480 /* FT_Outline_MoveToFunc */
481 /* */
482 /* <Description> */
483 /* A function pointer type used to describe the signature of a `move */
484 /* to' function during outline walking/decomposition. */
485 /* */
486 /* A `move to' is emitted to start a new contour in an outline. */
487 /* */
488 /* <Input> */
489 /* to :: A pointer to the target point of the `move to'. */
490 /* */
491 /* user :: A typeless pointer, which is passed from the caller of the */
492 /* decomposition function. */
493 /* */
494 /* <Return> */
495 /* Error code. 0~means success. */
496 /* */
497 typedef int
498 (*FT_Outline_MoveToFunc)( const FT_Vector* to,
499 void* user );
500
501 #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
502
503
504 /*************************************************************************/
505 /* */
506 /* <FuncType> */
507 /* FT_Outline_LineToFunc */
508 /* */
509 /* <Description> */
510 /* A function pointer type used to describe the signature of a `line */
511 /* to' function during outline walking/decomposition. */
512 /* */
513 /* A `line to' is emitted to indicate a segment in the outline. */
514 /* */
515 /* <Input> */
516 /* to :: A pointer to the target point of the `line to'. */
517 /* */
518 /* user :: A typeless pointer, which is passed from the caller of the */
519 /* decomposition function. */
520 /* */
521 /* <Return> */
522 /* Error code. 0~means success. */
523 /* */
524 typedef int
525 (*FT_Outline_LineToFunc)( const FT_Vector* to,
526 void* user );
527
528 #define FT_Outline_LineTo_Func FT_Outline_LineToFunc
529
530
531 /*************************************************************************/
532 /* */
533 /* <FuncType> */
534 /* FT_Outline_ConicToFunc */
535 /* */
536 /* <Description> */
537 /* A function pointer type used to describe the signature of a `conic */
538 /* to' function during outline walking or decomposition. */
539 /* */
540 /* A `conic to' is emitted to indicate a second-order Bézier arc in */
541 /* the outline. */
542 /* */
543 /* <Input> */
544 /* control :: An intermediate control point between the last position */
545 /* and the new target in `to'. */
546 /* */
547 /* to :: A pointer to the target end point of the conic arc. */
548 /* */
549 /* user :: A typeless pointer, which is passed from the caller of */
550 /* the decomposition function. */
551 /* */
552 /* <Return> */
553 /* Error code. 0~means success. */
554 /* */
555 typedef int
556 (*FT_Outline_ConicToFunc)( const FT_Vector* control,
557 const FT_Vector* to,
558 void* user );
559
560 #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
561
562
563 /*************************************************************************/
564 /* */
565 /* <FuncType> */
566 /* FT_Outline_CubicToFunc */
567 /* */
568 /* <Description> */
569 /* A function pointer type used to describe the signature of a `cubic */
570 /* to' function during outline walking or decomposition. */
571 /* */
572 /* A `cubic to' is emitted to indicate a third-order Bézier arc. */
573 /* */
574 /* <Input> */
575 /* control1 :: A pointer to the first Bézier control point. */
576 /* */
577 /* control2 :: A pointer to the second Bézier control point. */
578 /* */
579 /* to :: A pointer to the target end point. */
580 /* */
581 /* user :: A typeless pointer, which is passed from the caller of */
582 /* the decomposition function. */
583 /* */
584 /* <Return> */
585 /* Error code. 0~means success. */
586 /* */
587 typedef int
588 (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
589 const FT_Vector* control2,
590 const FT_Vector* to,
591 void* user );
592
593 #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
594
595
596 /*************************************************************************/
597 /* */
598 /* <Struct> */
599 /* FT_Outline_Funcs */
600 /* */
601 /* <Description> */
602 /* A structure to hold various function pointers used during outline */
603 /* decomposition in order to emit segments, conic, and cubic Béziers. */
604 /* */
605 /* <Fields> */
606 /* move_to :: The `move to' emitter. */
607 /* */
608 /* line_to :: The segment emitter. */
609 /* */
610 /* conic_to :: The second-order Bézier arc emitter. */
611 /* */
612 /* cubic_to :: The third-order Bézier arc emitter. */
613 /* */
614 /* shift :: The shift that is applied to coordinates before they */
615 /* are sent to the emitter. */
616 /* */
617 /* delta :: The delta that is applied to coordinates before they */
618 /* are sent to the emitter, but after the shift. */
619 /* */
620 /* <Note> */
621 /* The point coordinates sent to the emitters are the transformed */
622 /* version of the original coordinates (this is important for high */
623 /* accuracy during scan-conversion). The transformation is simple: */
624 /* */
625 /* { */
626 /* x' = (x << shift) - delta */
627 /* y' = (x << shift) - delta */
628 /* } */
629 /* */
630 /* Set the values of `shift' and `delta' to~0 to get the original */
631 /* point coordinates. */
632 /* */
633 typedef struct FT_Outline_Funcs_
634 {
635 FT_Outline_MoveToFunc move_to;
636 FT_Outline_LineToFunc line_to;
637 FT_Outline_ConicToFunc conic_to;
638 FT_Outline_CubicToFunc cubic_to;
639
640 int shift;
641 FT_Pos delta;
642
643 } FT_Outline_Funcs;
644
645
646 /*************************************************************************/
647 /* */
648 /* <Section> */
649 /* basic_types */
650 /* */
651 /*************************************************************************/
652
653
654 /*************************************************************************/
655 /* */
656 /* <Macro> */
657 /* FT_IMAGE_TAG */
658 /* */
659 /* <Description> */
660 /* This macro converts four-letter tags to an unsigned long type. */
661 /* */
662 /* <Note> */
663 /* Since many 16-bit compilers don't like 32-bit enumerations, you */
664 /* should redefine this macro in case of problems to something like */
665 /* this: */
666 /* */
667 /* { */
668 /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
669 /* } */
670 /* */
671 /* to get a simple enumeration without assigning special numbers. */
672 /* */
673 #ifndef FT_IMAGE_TAG
674 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
675 value = ( ( (unsigned long)_x1 << 24 ) | \
676 ( (unsigned long)_x2 << 16 ) | \
677 ( (unsigned long)_x3 << 8 ) | \
678 (unsigned long)_x4 )
679 #endif /* FT_IMAGE_TAG */
680
681
682 /*************************************************************************/
683 /* */
684 /* <Enum> */
685 /* FT_Glyph_Format */
686 /* */
687 /* <Description> */
688 /* An enumeration type used to describe the format of a given glyph */
689 /* image. Note that this version of FreeType only supports two image */
690 /* formats, even though future font drivers will be able to register */
691 /* their own format. */
692 /* */
693 /* <Values> */
694 /* FT_GLYPH_FORMAT_NONE :: */
695 /* The value~0 is reserved. */
696 /* */
697 /* FT_GLYPH_FORMAT_COMPOSITE :: */
698 /* The glyph image is a composite of several other images. This */
699 /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
700 /* report compound glyphs (like accented characters). */
701 /* */
702 /* FT_GLYPH_FORMAT_BITMAP :: */
703 /* The glyph image is a bitmap, and can be described as an */
704 /* @FT_Bitmap. You generally need to access the `bitmap' field of */
705 /* the @FT_GlyphSlotRec structure to read it. */
706 /* */
707 /* FT_GLYPH_FORMAT_OUTLINE :: */
708 /* The glyph image is a vectorial outline made of line segments */
709 /* and Bézier arcs; it can be described as an @FT_Outline; you */
710 /* generally want to access the `outline' field of the */
711 /* @FT_GlyphSlotRec structure to read it. */
712 /* */
713 /* FT_GLYPH_FORMAT_PLOTTER :: */
714 /* The glyph image is a vectorial path with no inside and outside */
715 /* contours. Some Type~1 fonts, like those in the Hershey family, */
716 /* contain glyphs in this format. These are described as */
717 /* @FT_Outline, but FreeType isn't currently capable of rendering */
718 /* them correctly. */
719 /* */
720 typedef enum FT_Glyph_Format_
721 {
722 FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
723
724 FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
725 FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
726 FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
727 FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
728
729 } FT_Glyph_Format;
730
731
732 /* these constants are deprecated; use the corresponding */
733 /* `FT_Glyph_Format' values instead. */
734 #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
735 #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
736 #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
737 #define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
738 #define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
739
740
741 /*************************************************************************/
742 /*************************************************************************/
743 /*************************************************************************/
744 /***** *****/
745 /***** R A S T E R D E F I N I T I O N S *****/
746 /***** *****/
747 /*************************************************************************/
748 /*************************************************************************/
749 /*************************************************************************/
750
751
752 /*************************************************************************/
753 /* */
754 /* A raster is a scan converter, in charge of rendering an outline into */
755 /* a a bitmap. This section contains the public API for rasters. */
756 /* */
757 /* Note that in FreeType 2, all rasters are now encapsulated within */
758 /* specific modules called `renderers'. See `ftrender.h' for more */
759 /* details on renderers. */
760 /* */
761 /*************************************************************************/
762
763
764 /*************************************************************************/
765 /* */
766 /* <Section> */
767 /* raster */
768 /* */
769 /* <Title> */
770 /* Scanline Converter */
771 /* */
772 /* <Abstract> */
773 /* How vectorial outlines are converted into bitmaps and pixmaps. */
774 /* */
775 /* <Description> */
776 /* This section contains technical definitions. */
777 /* */
778 /* <Order> */
779 /* FT_Raster */
780 /* FT_Span */
781 /* FT_SpanFunc */
782 /* */
783 /* FT_Raster_Params */
784 /* FT_RASTER_FLAG_XXX */
785 /* */
786 /* FT_Raster_NewFunc */
787 /* FT_Raster_DoneFunc */
788 /* FT_Raster_ResetFunc */
789 /* FT_Raster_SetModeFunc */
790 /* FT_Raster_RenderFunc */
791 /* FT_Raster_Funcs */
792 /* */
793 /*************************************************************************/
794
795
796 /*************************************************************************/
797 /* */
798 /* <Type> */
799 /* FT_Raster */
800 /* */
801 /* <Description> */
802 /* An opaque handle (pointer) to a raster object. Each object can be */
803 /* used independently to convert an outline into a bitmap or pixmap. */
804 /* */
805 typedef struct FT_RasterRec_* FT_Raster;
806
807
808 /*************************************************************************/
809 /* */
810 /* <Struct> */
811 /* FT_Span */
812 /* */
813 /* <Description> */
814 /* A structure used to model a single span of gray pixels when */
815 /* rendering an anti-aliased bitmap. */
816 /* */
817 /* <Fields> */
818 /* x :: The span's horizontal start position. */
819 /* */
820 /* len :: The span's length in pixels. */
821 /* */
822 /* coverage :: The span color/coverage, ranging from 0 (background) */
823 /* to 255 (foreground). */
824 /* */
825 /* <Note> */
826 /* This structure is used by the span drawing callback type named */
827 /* @FT_SpanFunc that takes the y~coordinate of the span as a */
828 /* parameter. */
829 /* */
830 /* The coverage value is always between 0 and 255. If you want less */
831 /* gray values, the callback function has to reduce them. */
832 /* */
833 typedef struct FT_Span_
834 {
835 short x;
836 unsigned short len;
837 unsigned char coverage;
838
839 } FT_Span;
840
841
842 /*************************************************************************/
843 /* */
844 /* <FuncType> */
845 /* FT_SpanFunc */
846 /* */
847 /* <Description> */
848 /* A function used as a call-back by the anti-aliased renderer in */
849 /* order to let client applications draw themselves the gray pixel */
850 /* spans on each scan line. */
851 /* */
852 /* <Input> */
853 /* y :: The scanline's y~coordinate. */
854 /* */
855 /* count :: The number of spans to draw on this scanline. */
856 /* */
857 /* spans :: A table of `count' spans to draw on the scanline. */
858 /* */
859 /* user :: User-supplied data that is passed to the callback. */
860 /* */
861 /* <Note> */
862 /* This callback allows client applications to directly render the */
863 /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
864 /* */
865 /* This can be used to write anti-aliased outlines directly to a */
866 /* given background bitmap, and even perform translucency. */
867 /* */
868 /* Note that the `count' field cannot be greater than a fixed value */
869 /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */
870 /* `ftoption.h'. By default, this value is set to~32, which means */
871 /* that if there are more than 32~spans on a given scanline, the */
872 /* callback is called several times with the same `y' parameter in */
873 /* order to draw all callbacks. */
874 /* */
875 /* Otherwise, the callback is only called once per scan-line, and */
876 /* only for those scanlines that do have `gray' pixels on them. */
877 /* */
878 typedef void
879 (*FT_SpanFunc)( int y,
880 int count,
881 const FT_Span* spans,
882 void* user );
883
884 #define FT_Raster_Span_Func FT_SpanFunc
885
886
887 /*************************************************************************/
888 /* */
889 /* <FuncType> */
890 /* FT_Raster_BitTest_Func */
891 /* */
892 /* <Description> */
893 /* Deprecated, unimplemented. */
894 /* */
895 typedef int
896 (*FT_Raster_BitTest_Func)( int y,
897 int x,
898 void* user );
899
900
901 /*************************************************************************/
902 /* */
903 /* <FuncType> */
904 /* FT_Raster_BitSet_Func */
905 /* */
906 /* <Description> */
907 /* Deprecated, unimplemented. */
908 /* */
909 typedef void
910 (*FT_Raster_BitSet_Func)( int y,
911 int x,
912 void* user );
913
914
915 /*************************************************************************/
916 /* */
917 /* <Enum> */
918 /* FT_RASTER_FLAG_XXX */
919 /* */
920 /* <Description> */
921 /* A list of bit flag constants as used in the `flags' field of a */
922 /* @FT_Raster_Params structure. */
923 /* */
924 /* <Values> */
925 /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
926 /* */
927 /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
928 /* anti-aliased glyph image should be */
929 /* generated. Otherwise, it will be */
930 /* monochrome (1-bit). */
931 /* */
932 /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
933 /* rendering. In this mode, client */
934 /* applications must provide their own span */
935 /* callback. This lets them directly */
936 /* draw or compose over an existing bitmap. */
937 /* If this bit is not set, the target */
938 /* pixmap's buffer _must_ be zeroed before */
939 /* rendering. */
940 /* */
941 /* Direct rendering is only possible with */
942 /* anti-aliased glyphs. */
943 /* */
944 /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
945 /* rendering mode. If set, the output will */
946 /* be clipped to a box specified in the */
947 /* `clip_box' field of the */
948 /* @FT_Raster_Params structure. */
949 /* */
950 /* Note that by default, the glyph bitmap */
951 /* is clipped to the target pixmap, except */
952 /* in direct rendering mode where all spans */
953 /* are generated if no clipping box is set. */
954 /* */
955 #define FT_RASTER_FLAG_DEFAULT 0x0
956 #define FT_RASTER_FLAG_AA 0x1
957 #define FT_RASTER_FLAG_DIRECT 0x2
958 #define FT_RASTER_FLAG_CLIP 0x4
959
960 /* these constants are deprecated; use the corresponding */
961 /* `FT_RASTER_FLAG_XXX' values instead */
962 #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
963 #define ft_raster_flag_aa FT_RASTER_FLAG_AA
964 #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
965 #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
966
967
968 /*************************************************************************/
969 /* */
970 /* <Struct> */
971 /* FT_Raster_Params */
972 /* */
973 /* <Description> */
974 /* A structure to hold the arguments used by a raster's render */
975 /* function. */
976 /* */
977 /* <Fields> */
978 /* target :: The target bitmap. */
979 /* */
980 /* source :: A pointer to the source glyph image (e.g., an */
981 /* @FT_Outline). */
982 /* */
983 /* flags :: The rendering flags. */
984 /* */
985 /* gray_spans :: The gray span drawing callback. */
986 /* */
987 /* black_spans :: Unused. */
988 /* */
989 /* bit_test :: Unused. */
990 /* */
991 /* bit_set :: Unused. */
992 /* */
993 /* user :: User-supplied data that is passed to each drawing */
994 /* callback. */
995 /* */
996 /* clip_box :: An optional clipping box. It is only used in */
997 /* direct rendering mode. Note that coordinates here */
998 /* should be expressed in _integer_ pixels (and not in */
999 /* 26.6 fixed-point units). */
1000 /* */
1001 /* <Note> */
1002 /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */
1003 /* bit flag is set in the `flags' field, otherwise a monochrome */
1004 /* bitmap is generated. */
1005 /* */
1006 /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
1007 /* raster will call the `gray_spans' callback to draw gray pixel */
1008 /* spans. This allows direct composition over a pre-existing bitmap */
1009 /* through user-provided callbacks to perform the span drawing and */
1010 /* composition. Not supported by the monochrome rasterizer. */
1011 /* */
1012 typedef struct FT_Raster_Params_
1013 {
1014 const FT_Bitmap* target;
1015 const void* source;
1016 int flags;
1017 FT_SpanFunc gray_spans;
1018 FT_SpanFunc black_spans; /* unused */
1019 FT_Raster_BitTest_Func bit_test; /* unused */
1020 FT_Raster_BitSet_Func bit_set; /* unused */
1021 void* user;
1022 FT_BBox clip_box;
1023
1024 } FT_Raster_Params;
1025
1026
1027 /*************************************************************************/
1028 /* */
1029 /* <FuncType> */
1030 /* FT_Raster_NewFunc */
1031 /* */
1032 /* <Description> */
1033 /* A function used to create a new raster object. */
1034 /* */
1035 /* <Input> */
1036 /* memory :: A handle to the memory allocator. */
1037 /* */
1038 /* <Output> */
1039 /* raster :: A handle to the new raster object. */
1040 /* */
1041 /* <Return> */
1042 /* Error code. 0~means success. */
1043 /* */
1044 /* <Note> */
1045 /* The `memory' parameter is a typeless pointer in order to avoid */
1046 /* un-wanted dependencies on the rest of the FreeType code. In */
1047 /* practice, it is an @FT_Memory object, i.e., a handle to the */
1048 /* standard FreeType memory allocator. However, this field can be */
1049 /* completely ignored by a given raster implementation. */
1050 /* */
1051 typedef int
1052 (*FT_Raster_NewFunc)( void* memory,
1053 FT_Raster* raster );
1054
1055 #define FT_Raster_New_Func FT_Raster_NewFunc
1056
1057
1058 /*************************************************************************/
1059 /* */
1060 /* <FuncType> */
1061 /* FT_Raster_DoneFunc */
1062 /* */
1063 /* <Description> */
1064 /* A function used to destroy a given raster object. */
1065 /* */
1066 /* <Input> */
1067 /* raster :: A handle to the raster object. */
1068 /* */
1069 typedef void
1070 (*FT_Raster_DoneFunc)( FT_Raster raster );
1071
1072 #define FT_Raster_Done_Func FT_Raster_DoneFunc
1073
1074
1075 /*************************************************************************/
1076 /* */
1077 /* <FuncType> */
1078 /* FT_Raster_ResetFunc */
1079 /* */
1080 /* <Description> */
1081 /* FreeType provides an area of memory called the `render pool', */
1082 /* available to all registered rasters. This pool can be freely used */
1083 /* during a given scan-conversion but is shared by all rasters. Its */
1084 /* content is thus transient. */
1085 /* */
1086 /* This function is called each time the render pool changes, or just */
1087 /* after a new raster object is created. */
1088 /* */
1089 /* <Input> */
1090 /* raster :: A handle to the new raster object. */
1091 /* */
1092 /* pool_base :: The address in memory of the render pool. */
1093 /* */
1094 /* pool_size :: The size in bytes of the render pool. */
1095 /* */
1096 /* <Note> */
1097 /* Rasters can ignore the render pool and rely on dynamic memory */
1098 /* allocation if they want to (a handle to the memory allocator is */
1099 /* passed to the raster constructor). However, this is not */
1100 /* recommended for efficiency purposes. */
1101 /* */
1102 typedef void
1103 (*FT_Raster_ResetFunc)( FT_Raster raster,
1104 unsigned char* pool_base,
1105 unsigned long pool_size );
1106
1107 #define FT_Raster_Reset_Func FT_Raster_ResetFunc
1108
1109
1110 /*************************************************************************/
1111 /* */
1112 /* <FuncType> */
1113 /* FT_Raster_SetModeFunc */
1114 /* */
1115 /* <Description> */
1116 /* This function is a generic facility to change modes or attributes */
1117 /* in a given raster. This can be used for debugging purposes, or */
1118 /* simply to allow implementation-specific `features' in a given */
1119 /* raster module. */
1120 /* */
1121 /* <Input> */
1122 /* raster :: A handle to the new raster object. */
1123 /* */
1124 /* mode :: A 4-byte tag used to name the mode or property. */
1125 /* */
1126 /* args :: A pointer to the new mode/property to use. */
1127 /* */
1128 typedef int
1129 (*FT_Raster_SetModeFunc)( FT_Raster raster,
1130 unsigned long mode,
1131 void* args );
1132
1133 #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1134
1135
1136 /*************************************************************************/
1137 /* */
1138 /* <FuncType> */
1139 /* FT_Raster_RenderFunc */
1140 /* */
1141 /* <Description> */
1142 /* Invoke a given raster to scan-convert a given glyph image into a */
1143 /* target bitmap. */
1144 /* */
1145 /* <Input> */
1146 /* raster :: A handle to the raster object. */
1147 /* */
1148 /* params :: A pointer to an @FT_Raster_Params structure used to */
1149 /* store the rendering parameters. */
1150 /* */
1151 /* <Return> */
1152 /* Error code. 0~means success. */
1153 /* */
1154 /* <Note> */
1155 /* The exact format of the source image depends on the raster's glyph */
1156 /* format defined in its @FT_Raster_Funcs structure. It can be an */
1157 /* @FT_Outline or anything else in order to support a large array of */
1158 /* glyph formats. */
1159 /* */
1160 /* Note also that the render function can fail and return a */
1161 /* `FT_Err_Unimplemented_Feature' error code if the raster used does */
1162 /* not support direct composition. */
1163 /* */
1164 /* XXX: For now, the standard raster doesn't support direct */
1165 /* composition but this should change for the final release (see */
1166 /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */
1167 /* for examples of distinct implementations that support direct */
1168 /* composition). */
1169 /* */
1170 typedef int
1171 (*FT_Raster_RenderFunc)( FT_Raster raster,
1172 const FT_Raster_Params* params );
1173
1174 #define FT_Raster_Render_Func FT_Raster_RenderFunc
1175
1176
1177 /*************************************************************************/
1178 /* */
1179 /* <Struct> */
1180 /* FT_Raster_Funcs */
1181 /* */
1182 /* <Description> */
1183 /* A structure used to describe a given raster class to the library. */
1184 /* */
1185 /* <Fields> */
1186 /* glyph_format :: The supported glyph format for this raster. */
1187 /* */
1188 /* raster_new :: The raster constructor. */
1189 /* */
1190 /* raster_reset :: Used to reset the render pool within the raster. */
1191 /* */
1192 /* raster_render :: A function to render a glyph into a given bitmap. */
1193 /* */
1194 /* raster_done :: The raster destructor. */
1195 /* */
1196 typedef struct FT_Raster_Funcs_
1197 {
1198 FT_Glyph_Format glyph_format;
1199 FT_Raster_NewFunc raster_new;
1200 FT_Raster_ResetFunc raster_reset;
1201 FT_Raster_SetModeFunc raster_set_mode;
1202 FT_Raster_RenderFunc raster_render;
1203 FT_Raster_DoneFunc raster_done;
1204
1205 } FT_Raster_Funcs;
1206
1207 /* */
1208
1209
1210 FT_END_HEADER
1211
1212 #endif /* __FTIMAGE_H__ */
1213
1214
1215 /* END */
1216
1217
1218 /* Local Variables: */
1219 /* coding: utf-8 */
1220 /* End: */
OLDNEW
« no previous file with comments | « third_party/freetype/include/ftgzip.h ('k') | third_party/freetype/include/ftincrem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698