|
|
|||
Warning, file /include/freetype2/freetype/ftimage.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /**************************************************************************** 0002 * 0003 * ftimage.h 0004 * 0005 * FreeType glyph image formats and default raster interface 0006 * (specification). 0007 * 0008 * Copyright (C) 1996-2023 by 0009 * David Turner, Robert Wilhelm, and Werner Lemberg. 0010 * 0011 * This file is part of the FreeType project, and may only be used, 0012 * modified, and distributed under the terms of the FreeType project 0013 * license, LICENSE.TXT. By continuing to use, modify, or distribute 0014 * this file you indicate that you have read the license and 0015 * understand and accept it fully. 0016 * 0017 */ 0018 0019 /************************************************************************** 0020 * 0021 * Note: A 'raster' is simply a scan-line converter, used to render 0022 * `FT_Outline`s into `FT_Bitmap`s. 0023 * 0024 */ 0025 0026 0027 #ifndef FTIMAGE_H_ 0028 #define FTIMAGE_H_ 0029 0030 0031 FT_BEGIN_HEADER 0032 0033 0034 /************************************************************************** 0035 * 0036 * @section: 0037 * basic_types 0038 * 0039 */ 0040 0041 0042 /************************************************************************** 0043 * 0044 * @type: 0045 * FT_Pos 0046 * 0047 * @description: 0048 * The type FT_Pos is used to store vectorial coordinates. Depending on 0049 * the context, these can represent distances in integer font units, or 0050 * 16.16, or 26.6 fixed-point pixel coordinates. 0051 */ 0052 typedef signed long FT_Pos; 0053 0054 0055 /************************************************************************** 0056 * 0057 * @struct: 0058 * FT_Vector 0059 * 0060 * @description: 0061 * A simple structure used to store a 2D vector; coordinates are of the 0062 * FT_Pos type. 0063 * 0064 * @fields: 0065 * x :: 0066 * The horizontal coordinate. 0067 * y :: 0068 * The vertical coordinate. 0069 */ 0070 typedef struct FT_Vector_ 0071 { 0072 FT_Pos x; 0073 FT_Pos y; 0074 0075 } FT_Vector; 0076 0077 0078 /************************************************************************** 0079 * 0080 * @struct: 0081 * FT_BBox 0082 * 0083 * @description: 0084 * A structure used to hold an outline's bounding box, i.e., the 0085 * coordinates of its extrema in the horizontal and vertical directions. 0086 * 0087 * @fields: 0088 * xMin :: 0089 * The horizontal minimum (left-most). 0090 * 0091 * yMin :: 0092 * The vertical minimum (bottom-most). 0093 * 0094 * xMax :: 0095 * The horizontal maximum (right-most). 0096 * 0097 * yMax :: 0098 * The vertical maximum (top-most). 0099 * 0100 * @note: 0101 * The bounding box is specified with the coordinates of the lower left 0102 * and the upper right corner. In PostScript, those values are often 0103 * called (llx,lly) and (urx,ury), respectively. 0104 * 0105 * If `yMin` is negative, this value gives the glyph's descender. 0106 * Otherwise, the glyph doesn't descend below the baseline. Similarly, 0107 * if `ymax` is positive, this value gives the glyph's ascender. 0108 * 0109 * `xMin` gives the horizontal distance from the glyph's origin to the 0110 * left edge of the glyph's bounding box. If `xMin` is negative, the 0111 * glyph extends to the left of the origin. 0112 */ 0113 typedef struct FT_BBox_ 0114 { 0115 FT_Pos xMin, yMin; 0116 FT_Pos xMax, yMax; 0117 0118 } FT_BBox; 0119 0120 0121 /************************************************************************** 0122 * 0123 * @enum: 0124 * FT_Pixel_Mode 0125 * 0126 * @description: 0127 * An enumeration type used to describe the format of pixels in a given 0128 * bitmap. Note that additional formats may be added in the future. 0129 * 0130 * @values: 0131 * FT_PIXEL_MODE_NONE :: 0132 * Value~0 is reserved. 0133 * 0134 * FT_PIXEL_MODE_MONO :: 0135 * A monochrome bitmap, using 1~bit per pixel. Note that pixels are 0136 * stored in most-significant order (MSB), which means that the 0137 * left-most pixel in a byte has value 128. 0138 * 0139 * FT_PIXEL_MODE_GRAY :: 0140 * An 8-bit bitmap, generally used to represent anti-aliased glyph 0141 * images. Each pixel is stored in one byte. Note that the number of 0142 * 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap 0143 * structure (it generally is 256). 0144 * 0145 * FT_PIXEL_MODE_GRAY2 :: 0146 * A 2-bit per pixel bitmap, used to represent embedded anti-aliased 0147 * bitmaps in font files according to the OpenType specification. We 0148 * haven't found a single font using this format, however. 0149 * 0150 * FT_PIXEL_MODE_GRAY4 :: 0151 * A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps 0152 * in font files according to the OpenType specification. We haven't 0153 * found a single font using this format, however. 0154 * 0155 * FT_PIXEL_MODE_LCD :: 0156 * An 8-bit bitmap, representing RGB or BGR decimated glyph images used 0157 * for display on LCD displays; the bitmap is three times wider than 0158 * the original glyph image. See also @FT_RENDER_MODE_LCD. 0159 * 0160 * FT_PIXEL_MODE_LCD_V :: 0161 * An 8-bit bitmap, representing RGB or BGR decimated glyph images used 0162 * for display on rotated LCD displays; the bitmap is three times 0163 * taller than the original glyph image. See also 0164 * @FT_RENDER_MODE_LCD_V. 0165 * 0166 * FT_PIXEL_MODE_BGRA :: 0167 * [Since 2.5] An image with four 8-bit channels per pixel, 0168 * representing a color image (such as emoticons) with alpha channel. 0169 * For each pixel, the format is BGRA, which means, the blue channel 0170 * comes first in memory. The color channels are pre-multiplied and in 0171 * the sRGB colorspace. For example, full red at half-translucent 0172 * opacity will be represented as '00,00,80,80', not '00,00,FF,80'. 0173 * See also @FT_LOAD_COLOR. 0174 */ 0175 typedef enum FT_Pixel_Mode_ 0176 { 0177 FT_PIXEL_MODE_NONE = 0, 0178 FT_PIXEL_MODE_MONO, 0179 FT_PIXEL_MODE_GRAY, 0180 FT_PIXEL_MODE_GRAY2, 0181 FT_PIXEL_MODE_GRAY4, 0182 FT_PIXEL_MODE_LCD, 0183 FT_PIXEL_MODE_LCD_V, 0184 FT_PIXEL_MODE_BGRA, 0185 0186 FT_PIXEL_MODE_MAX /* do not remove */ 0187 0188 } FT_Pixel_Mode; 0189 0190 0191 /* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */ 0192 /* values instead. */ 0193 #define ft_pixel_mode_none FT_PIXEL_MODE_NONE 0194 #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO 0195 #define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY 0196 #define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2 0197 #define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 0198 0199 /* */ 0200 0201 /* For debugging, the @FT_Pixel_Mode enumeration must stay in sync */ 0202 /* with the `pixel_modes` array in file `ftobjs.c`. */ 0203 0204 0205 /************************************************************************** 0206 * 0207 * @struct: 0208 * FT_Bitmap 0209 * 0210 * @description: 0211 * A structure used to describe a bitmap or pixmap to the raster. Note 0212 * that we now manage pixmaps of various depths through the `pixel_mode` 0213 * field. 0214 * 0215 * @fields: 0216 * rows :: 0217 * The number of bitmap rows. 0218 * 0219 * width :: 0220 * The number of pixels in bitmap row. 0221 * 0222 * pitch :: 0223 * The pitch's absolute value is the number of bytes taken by one 0224 * bitmap row, including padding. However, the pitch is positive when 0225 * the bitmap has a 'down' flow, and negative when it has an 'up' flow. 0226 * In all cases, the pitch is an offset to add to a bitmap pointer in 0227 * order to go down one row. 0228 * 0229 * Note that 'padding' means the alignment of a bitmap to a byte 0230 * border, and FreeType functions normally align to the smallest 0231 * possible integer value. 0232 * 0233 * For the B/W rasterizer, `pitch` is always an even number. 0234 * 0235 * To change the pitch of a bitmap (say, to make it a multiple of 4), 0236 * use @FT_Bitmap_Convert. Alternatively, you might use callback 0237 * functions to directly render to the application's surface; see the 0238 * file `example2.cpp` in the tutorial for a demonstration. 0239 * 0240 * buffer :: 0241 * A typeless pointer to the bitmap buffer. This value should be 0242 * aligned on 32-bit boundaries in most cases. 0243 * 0244 * num_grays :: 0245 * This field is only used with @FT_PIXEL_MODE_GRAY; it gives the 0246 * number of gray levels used in the bitmap. 0247 * 0248 * pixel_mode :: 0249 * The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode 0250 * for possible values. 0251 * 0252 * palette_mode :: 0253 * This field is intended for paletted pixel modes; it indicates how 0254 * the palette is stored. Not used currently. 0255 * 0256 * palette :: 0257 * A typeless pointer to the bitmap palette; this field is intended for 0258 * paletted pixel modes. Not used currently. 0259 * 0260 * @note: 0261 * `width` and `rows` refer to the *physical* size of the bitmap, not the 0262 * *logical* one. For example, if @FT_Pixel_Mode is set to 0263 * `FT_PIXEL_MODE_LCD`, the logical width is a just a third of the 0264 * physical one. 0265 */ 0266 typedef struct FT_Bitmap_ 0267 { 0268 unsigned int rows; 0269 unsigned int width; 0270 int pitch; 0271 unsigned char* buffer; 0272 unsigned short num_grays; 0273 unsigned char pixel_mode; 0274 unsigned char palette_mode; 0275 void* palette; 0276 0277 } FT_Bitmap; 0278 0279 0280 /************************************************************************** 0281 * 0282 * @section: 0283 * outline_processing 0284 * 0285 */ 0286 0287 0288 /************************************************************************** 0289 * 0290 * @struct: 0291 * FT_Outline 0292 * 0293 * @description: 0294 * This structure is used to describe an outline to the scan-line 0295 * converter. 0296 * 0297 * @fields: 0298 * n_contours :: 0299 * The number of contours in the outline. 0300 * 0301 * n_points :: 0302 * The number of points in the outline. 0303 * 0304 * points :: 0305 * A pointer to an array of `n_points` @FT_Vector elements, giving the 0306 * outline's point coordinates. 0307 * 0308 * tags :: 0309 * A pointer to an array of `n_points` chars, giving each outline 0310 * point's type. 0311 * 0312 * If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier 0313 * control point, while it is 'on' if set. 0314 * 0315 * Bit~1 is meaningful for 'off' points only. If set, it indicates a 0316 * third-order Bezier arc control point; and a second-order control 0317 * point if unset. 0318 * 0319 * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in 0320 * the OpenType specification; the value is the same as the argument to 0321 * the 'SCANMODE' instruction). 0322 * 0323 * Bits 3 and~4 are reserved for internal purposes. 0324 * 0325 * contours :: 0326 * An array of `n_contours` shorts, giving the end point of each 0327 * contour within the outline. For example, the first contour is 0328 * defined by the points '0' to `contours[0]`, the second one is 0329 * defined by the points `contours[0]+1` to `contours[1]`, etc. 0330 * 0331 * flags :: 0332 * A set of bit flags used to characterize the outline and give hints 0333 * to the scan-converter and hinter on how to convert/grid-fit it. See 0334 * @FT_OUTLINE_XXX. 0335 * 0336 * @note: 0337 * The B/W rasterizer only checks bit~2 in the `tags` array for the first 0338 * point of each contour. The drop-out mode as given with 0339 * @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and 0340 * @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden. 0341 */ 0342 typedef struct FT_Outline_ 0343 { 0344 short n_contours; /* number of contours in glyph */ 0345 short n_points; /* number of points in the glyph */ 0346 0347 FT_Vector* points; /* the outline's points */ 0348 char* tags; /* the points flags */ 0349 short* contours; /* the contour end points */ 0350 0351 int flags; /* outline masks */ 0352 0353 } FT_Outline; 0354 0355 /* */ 0356 0357 /* Following limits must be consistent with */ 0358 /* FT_Outline.{n_contours,n_points} */ 0359 #define FT_OUTLINE_CONTOURS_MAX SHRT_MAX 0360 #define FT_OUTLINE_POINTS_MAX SHRT_MAX 0361 0362 0363 /************************************************************************** 0364 * 0365 * @enum: 0366 * FT_OUTLINE_XXX 0367 * 0368 * @description: 0369 * A list of bit-field constants used for the flags in an outline's 0370 * `flags` field. 0371 * 0372 * @values: 0373 * FT_OUTLINE_NONE :: 0374 * Value~0 is reserved. 0375 * 0376 * FT_OUTLINE_OWNER :: 0377 * If set, this flag indicates that the outline's field arrays (i.e., 0378 * `points`, `flags`, and `contours`) are 'owned' by the outline 0379 * object, and should thus be freed when it is destroyed. 0380 * 0381 * FT_OUTLINE_EVEN_ODD_FILL :: 0382 * By default, outlines are filled using the non-zero winding rule. If 0383 * set to 1, the outline will be filled using the even-odd fill rule 0384 * (only works with the smooth rasterizer). 0385 * 0386 * FT_OUTLINE_REVERSE_FILL :: 0387 * By default, outside contours of an outline are oriented in 0388 * clock-wise direction, as defined in the TrueType specification. 0389 * This flag is set if the outline uses the opposite direction 0390 * (typically for Type~1 fonts). This flag is ignored by the scan 0391 * converter. 0392 * 0393 * FT_OUTLINE_IGNORE_DROPOUTS :: 0394 * By default, the scan converter will try to detect drop-outs in an 0395 * outline and correct the glyph bitmap to ensure consistent shape 0396 * continuity. If set, this flag hints the scan-line converter to 0397 * ignore such cases. See below for more information. 0398 * 0399 * FT_OUTLINE_SMART_DROPOUTS :: 0400 * Select smart dropout control. If unset, use simple dropout control. 0401 * Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more 0402 * information. 0403 * 0404 * FT_OUTLINE_INCLUDE_STUBS :: 0405 * If set, turn pixels on for 'stubs', otherwise exclude them. Ignored 0406 * if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more 0407 * information. 0408 * 0409 * FT_OUTLINE_OVERLAP :: 0410 * [Since 2.10.3] This flag indicates that this outline contains 0411 * overlapping contours and the anti-aliased renderer should perform 0412 * oversampling to mitigate possible artifacts. This flag should _not_ 0413 * be set for well designed glyphs without overlaps because it quadruples 0414 * the rendering time. 0415 * 0416 * FT_OUTLINE_HIGH_PRECISION :: 0417 * This flag indicates that the scan-line converter should try to 0418 * convert this outline to bitmaps with the highest possible quality. 0419 * It is typically set for small character sizes. Note that this is 0420 * only a hint that might be completely ignored by a given 0421 * scan-converter. 0422 * 0423 * FT_OUTLINE_SINGLE_PASS :: 0424 * This flag is set to force a given scan-converter to only use a 0425 * single pass over the outline to render a bitmap glyph image. 0426 * Normally, it is set for very large character sizes. It is only a 0427 * hint that might be completely ignored by a given scan-converter. 0428 * 0429 * @note: 0430 * The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and 0431 * @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer. 0432 * 0433 * There exists a second mechanism to pass the drop-out mode to the B/W 0434 * rasterizer; see the `tags` field in @FT_Outline. 0435 * 0436 * Please refer to the description of the 'SCANTYPE' instruction in the 0437 * OpenType specification (in file `ttinst1.doc`) how simple drop-outs, 0438 * smart drop-outs, and stubs are defined. 0439 */ 0440 #define FT_OUTLINE_NONE 0x0 0441 #define FT_OUTLINE_OWNER 0x1 0442 #define FT_OUTLINE_EVEN_ODD_FILL 0x2 0443 #define FT_OUTLINE_REVERSE_FILL 0x4 0444 #define FT_OUTLINE_IGNORE_DROPOUTS 0x8 0445 #define FT_OUTLINE_SMART_DROPOUTS 0x10 0446 #define FT_OUTLINE_INCLUDE_STUBS 0x20 0447 #define FT_OUTLINE_OVERLAP 0x40 0448 0449 #define FT_OUTLINE_HIGH_PRECISION 0x100 0450 #define FT_OUTLINE_SINGLE_PASS 0x200 0451 0452 0453 /* these constants are deprecated; use the corresponding */ 0454 /* `FT_OUTLINE_XXX` values instead */ 0455 #define ft_outline_none FT_OUTLINE_NONE 0456 #define ft_outline_owner FT_OUTLINE_OWNER 0457 #define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL 0458 #define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL 0459 #define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS 0460 #define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION 0461 #define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS 0462 0463 /* */ 0464 0465 #define FT_CURVE_TAG( flag ) ( flag & 0x03 ) 0466 0467 /* see the `tags` field in `FT_Outline` for a description of the values */ 0468 #define FT_CURVE_TAG_ON 0x01 0469 #define FT_CURVE_TAG_CONIC 0x00 0470 #define FT_CURVE_TAG_CUBIC 0x02 0471 0472 #define FT_CURVE_TAG_HAS_SCANMODE 0x04 0473 0474 #define FT_CURVE_TAG_TOUCH_X 0x08 /* reserved for TrueType hinter */ 0475 #define FT_CURVE_TAG_TOUCH_Y 0x10 /* reserved for TrueType hinter */ 0476 0477 #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ 0478 FT_CURVE_TAG_TOUCH_Y ) 0479 /* values 0x20, 0x40, and 0x80 are reserved */ 0480 0481 0482 /* these constants are deprecated; use the corresponding */ 0483 /* `FT_CURVE_TAG_XXX` values instead */ 0484 #define FT_Curve_Tag_On FT_CURVE_TAG_ON 0485 #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC 0486 #define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC 0487 #define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X 0488 #define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y 0489 0490 0491 /************************************************************************** 0492 * 0493 * @functype: 0494 * FT_Outline_MoveToFunc 0495 * 0496 * @description: 0497 * A function pointer type used to describe the signature of a 'move to' 0498 * function during outline walking/decomposition. 0499 * 0500 * A 'move to' is emitted to start a new contour in an outline. 0501 * 0502 * @input: 0503 * to :: 0504 * A pointer to the target point of the 'move to'. 0505 * 0506 * user :: 0507 * A typeless pointer, which is passed from the caller of the 0508 * decomposition function. 0509 * 0510 * @return: 0511 * Error code. 0~means success. 0512 */ 0513 typedef int 0514 (*FT_Outline_MoveToFunc)( const FT_Vector* to, 0515 void* user ); 0516 0517 #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc 0518 0519 0520 /************************************************************************** 0521 * 0522 * @functype: 0523 * FT_Outline_LineToFunc 0524 * 0525 * @description: 0526 * A function pointer type used to describe the signature of a 'line to' 0527 * function during outline walking/decomposition. 0528 * 0529 * A 'line to' is emitted to indicate a segment in the outline. 0530 * 0531 * @input: 0532 * to :: 0533 * A pointer to the target point of the 'line to'. 0534 * 0535 * user :: 0536 * A typeless pointer, which is passed from the caller of the 0537 * decomposition function. 0538 * 0539 * @return: 0540 * Error code. 0~means success. 0541 */ 0542 typedef int 0543 (*FT_Outline_LineToFunc)( const FT_Vector* to, 0544 void* user ); 0545 0546 #define FT_Outline_LineTo_Func FT_Outline_LineToFunc 0547 0548 0549 /************************************************************************** 0550 * 0551 * @functype: 0552 * FT_Outline_ConicToFunc 0553 * 0554 * @description: 0555 * A function pointer type used to describe the signature of a 'conic to' 0556 * function during outline walking or decomposition. 0557 * 0558 * A 'conic to' is emitted to indicate a second-order Bezier arc in the 0559 * outline. 0560 * 0561 * @input: 0562 * control :: 0563 * An intermediate control point between the last position and the new 0564 * target in `to`. 0565 * 0566 * to :: 0567 * A pointer to the target end point of the conic arc. 0568 * 0569 * user :: 0570 * A typeless pointer, which is passed from the caller of the 0571 * decomposition function. 0572 * 0573 * @return: 0574 * Error code. 0~means success. 0575 */ 0576 typedef int 0577 (*FT_Outline_ConicToFunc)( const FT_Vector* control, 0578 const FT_Vector* to, 0579 void* user ); 0580 0581 #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc 0582 0583 0584 /************************************************************************** 0585 * 0586 * @functype: 0587 * FT_Outline_CubicToFunc 0588 * 0589 * @description: 0590 * A function pointer type used to describe the signature of a 'cubic to' 0591 * function during outline walking or decomposition. 0592 * 0593 * A 'cubic to' is emitted to indicate a third-order Bezier arc. 0594 * 0595 * @input: 0596 * control1 :: 0597 * A pointer to the first Bezier control point. 0598 * 0599 * control2 :: 0600 * A pointer to the second Bezier control point. 0601 * 0602 * to :: 0603 * A pointer to the target end point. 0604 * 0605 * user :: 0606 * A typeless pointer, which is passed from the caller of the 0607 * decomposition function. 0608 * 0609 * @return: 0610 * Error code. 0~means success. 0611 */ 0612 typedef int 0613 (*FT_Outline_CubicToFunc)( const FT_Vector* control1, 0614 const FT_Vector* control2, 0615 const FT_Vector* to, 0616 void* user ); 0617 0618 #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc 0619 0620 0621 /************************************************************************** 0622 * 0623 * @struct: 0624 * FT_Outline_Funcs 0625 * 0626 * @description: 0627 * A structure to hold various function pointers used during outline 0628 * decomposition in order to emit segments, conic, and cubic Beziers. 0629 * 0630 * @fields: 0631 * move_to :: 0632 * The 'move to' emitter. 0633 * 0634 * line_to :: 0635 * The segment emitter. 0636 * 0637 * conic_to :: 0638 * The second-order Bezier arc emitter. 0639 * 0640 * cubic_to :: 0641 * The third-order Bezier arc emitter. 0642 * 0643 * shift :: 0644 * The shift that is applied to coordinates before they are sent to the 0645 * emitter. 0646 * 0647 * delta :: 0648 * The delta that is applied to coordinates before they are sent to the 0649 * emitter, but after the shift. 0650 * 0651 * @note: 0652 * The point coordinates sent to the emitters are the transformed version 0653 * of the original coordinates (this is important for high accuracy 0654 * during scan-conversion). The transformation is simple: 0655 * 0656 * ``` 0657 * x' = (x << shift) - delta 0658 * y' = (y << shift) - delta 0659 * ``` 0660 * 0661 * Set the values of `shift` and `delta` to~0 to get the original point 0662 * coordinates. 0663 */ 0664 typedef struct FT_Outline_Funcs_ 0665 { 0666 FT_Outline_MoveToFunc move_to; 0667 FT_Outline_LineToFunc line_to; 0668 FT_Outline_ConicToFunc conic_to; 0669 FT_Outline_CubicToFunc cubic_to; 0670 0671 int shift; 0672 FT_Pos delta; 0673 0674 } FT_Outline_Funcs; 0675 0676 0677 /************************************************************************** 0678 * 0679 * @section: 0680 * basic_types 0681 * 0682 */ 0683 0684 0685 /************************************************************************** 0686 * 0687 * @macro: 0688 * FT_IMAGE_TAG 0689 * 0690 * @description: 0691 * This macro converts four-letter tags to an unsigned long type. 0692 * 0693 * @note: 0694 * Since many 16-bit compilers don't like 32-bit enumerations, you should 0695 * redefine this macro in case of problems to something like this: 0696 * 0697 * ``` 0698 * #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value 0699 * ``` 0700 * 0701 * to get a simple enumeration without assigning special numbers. 0702 */ 0703 #ifndef FT_IMAGE_TAG 0704 0705 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ 0706 value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \ 0707 ( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \ 0708 ( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8 ) | \ 0709 FT_STATIC_BYTE_CAST( unsigned long, _x4 ) ) 0710 0711 #endif /* FT_IMAGE_TAG */ 0712 0713 0714 /************************************************************************** 0715 * 0716 * @enum: 0717 * FT_Glyph_Format 0718 * 0719 * @description: 0720 * An enumeration type used to describe the format of a given glyph 0721 * image. Note that this version of FreeType only supports two image 0722 * formats, even though future font drivers will be able to register 0723 * their own format. 0724 * 0725 * @values: 0726 * FT_GLYPH_FORMAT_NONE :: 0727 * The value~0 is reserved. 0728 * 0729 * FT_GLYPH_FORMAT_COMPOSITE :: 0730 * The glyph image is a composite of several other images. This format 0731 * is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report 0732 * compound glyphs (like accented characters). 0733 * 0734 * FT_GLYPH_FORMAT_BITMAP :: 0735 * The glyph image is a bitmap, and can be described as an @FT_Bitmap. 0736 * You generally need to access the `bitmap` field of the 0737 * @FT_GlyphSlotRec structure to read it. 0738 * 0739 * FT_GLYPH_FORMAT_OUTLINE :: 0740 * The glyph image is a vectorial outline made of line segments and 0741 * Bezier arcs; it can be described as an @FT_Outline; you generally 0742 * want to access the `outline` field of the @FT_GlyphSlotRec structure 0743 * to read it. 0744 * 0745 * FT_GLYPH_FORMAT_PLOTTER :: 0746 * The glyph image is a vectorial path with no inside and outside 0747 * contours. Some Type~1 fonts, like those in the Hershey family, 0748 * contain glyphs in this format. These are described as @FT_Outline, 0749 * but FreeType isn't currently capable of rendering them correctly. 0750 * 0751 * FT_GLYPH_FORMAT_SVG :: 0752 * [Since 2.12] The glyph is represented by an SVG document in the 0753 * 'SVG~' table. 0754 */ 0755 typedef enum FT_Glyph_Format_ 0756 { 0757 FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), 0758 0759 FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), 0760 FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), 0761 FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), 0762 FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ), 0763 FT_IMAGE_TAG( FT_GLYPH_FORMAT_SVG, 'S', 'V', 'G', ' ' ) 0764 0765 } FT_Glyph_Format; 0766 0767 0768 /* these constants are deprecated; use the corresponding */ 0769 /* `FT_Glyph_Format` values instead. */ 0770 #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE 0771 #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE 0772 #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP 0773 #define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE 0774 #define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER 0775 0776 0777 /*************************************************************************/ 0778 /*************************************************************************/ 0779 /*************************************************************************/ 0780 /***** *****/ 0781 /***** R A S T E R D E F I N I T I O N S *****/ 0782 /***** *****/ 0783 /*************************************************************************/ 0784 /*************************************************************************/ 0785 /*************************************************************************/ 0786 0787 0788 0789 /************************************************************************** 0790 * 0791 * @section: 0792 * raster 0793 * 0794 * @title: 0795 * Scanline Converter 0796 * 0797 * @abstract: 0798 * How vectorial outlines are converted into bitmaps and pixmaps. 0799 * 0800 * @description: 0801 * A raster or a rasterizer is a scan converter in charge of producing a 0802 * pixel coverage bitmap that can be used as an alpha channel when 0803 * compositing a glyph with a background. FreeType comes with two 0804 * rasterizers: bilevel `raster1` and anti-aliased `smooth` are two 0805 * separate modules. They are usually called from the high-level 0806 * @FT_Load_Glyph or @FT_Render_Glyph functions and produce the entire 0807 * coverage bitmap at once, while staying largely invisible to users. 0808 * 0809 * Instead of working with complete coverage bitmaps, it is also possible 0810 * to intercept consecutive pixel runs on the same scanline with the same 0811 * coverage, called _spans_, and process them individually. Only the 0812 * `smooth` rasterizer permits this when calling @FT_Outline_Render with 0813 * @FT_Raster_Params as described below. 0814 * 0815 * Working with either complete bitmaps or spans it is important to think 0816 * of them as colorless coverage objects suitable as alpha channels to 0817 * blend arbitrary colors with a background. For best results, it is 0818 * recommended to use gamma correction, too. 0819 * 0820 * This section also describes the public API needed to set up alternative 0821 * @FT_Renderer modules. 0822 * 0823 * @order: 0824 * FT_Span 0825 * FT_SpanFunc 0826 * FT_Raster_Params 0827 * FT_RASTER_FLAG_XXX 0828 * 0829 * FT_Raster 0830 * FT_Raster_NewFunc 0831 * FT_Raster_DoneFunc 0832 * FT_Raster_ResetFunc 0833 * FT_Raster_SetModeFunc 0834 * FT_Raster_RenderFunc 0835 * FT_Raster_Funcs 0836 * 0837 */ 0838 0839 0840 /************************************************************************** 0841 * 0842 * @struct: 0843 * FT_Span 0844 * 0845 * @description: 0846 * A structure to model a single span of consecutive pixels when 0847 * rendering an anti-aliased bitmap. 0848 * 0849 * @fields: 0850 * x :: 0851 * The span's horizontal start position. 0852 * 0853 * len :: 0854 * The span's length in pixels. 0855 * 0856 * coverage :: 0857 * The span color/coverage, ranging from 0 (background) to 255 0858 * (foreground). 0859 * 0860 * @note: 0861 * This structure is used by the span drawing callback type named 0862 * @FT_SpanFunc that takes the y~coordinate of the span as a parameter. 0863 * 0864 * The anti-aliased rasterizer produces coverage values from 0 to 255, 0865 * that is, from completely transparent to completely opaque. 0866 */ 0867 typedef struct FT_Span_ 0868 { 0869 short x; 0870 unsigned short len; 0871 unsigned char coverage; 0872 0873 } FT_Span; 0874 0875 0876 /************************************************************************** 0877 * 0878 * @functype: 0879 * FT_SpanFunc 0880 * 0881 * @description: 0882 * A function used as a call-back by the anti-aliased renderer in order 0883 * to let client applications draw themselves the pixel spans on each 0884 * scan line. 0885 * 0886 * @input: 0887 * y :: 0888 * The scanline's upward y~coordinate. 0889 * 0890 * count :: 0891 * The number of spans to draw on this scanline. 0892 * 0893 * spans :: 0894 * A table of `count` spans to draw on the scanline. 0895 * 0896 * user :: 0897 * User-supplied data that is passed to the callback. 0898 * 0899 * @note: 0900 * This callback allows client applications to directly render the spans 0901 * of the anti-aliased bitmap to any kind of surfaces. 0902 * 0903 * This can be used to write anti-aliased outlines directly to a given 0904 * background bitmap using alpha compositing. It can also be used for 0905 * oversampling and averaging. 0906 */ 0907 typedef void 0908 (*FT_SpanFunc)( int y, 0909 int count, 0910 const FT_Span* spans, 0911 void* user ); 0912 0913 #define FT_Raster_Span_Func FT_SpanFunc 0914 0915 0916 /************************************************************************** 0917 * 0918 * @functype: 0919 * FT_Raster_BitTest_Func 0920 * 0921 * @description: 0922 * Deprecated, unimplemented. 0923 */ 0924 typedef int 0925 (*FT_Raster_BitTest_Func)( int y, 0926 int x, 0927 void* user ); 0928 0929 0930 /************************************************************************** 0931 * 0932 * @functype: 0933 * FT_Raster_BitSet_Func 0934 * 0935 * @description: 0936 * Deprecated, unimplemented. 0937 */ 0938 typedef void 0939 (*FT_Raster_BitSet_Func)( int y, 0940 int x, 0941 void* user ); 0942 0943 0944 /************************************************************************** 0945 * 0946 * @enum: 0947 * FT_RASTER_FLAG_XXX 0948 * 0949 * @description: 0950 * A list of bit flag constants as used in the `flags` field of a 0951 * @FT_Raster_Params structure. 0952 * 0953 * @values: 0954 * FT_RASTER_FLAG_DEFAULT :: 0955 * This value is 0. 0956 * 0957 * FT_RASTER_FLAG_AA :: 0958 * This flag is set to indicate that an anti-aliased glyph image should 0959 * be generated. Otherwise, it will be monochrome (1-bit). 0960 * 0961 * FT_RASTER_FLAG_DIRECT :: 0962 * This flag is set to indicate direct rendering. In this mode, client 0963 * applications must provide their own span callback. This lets them 0964 * directly draw or compose over an existing bitmap. If this bit is 0965 * _not_ set, the target pixmap's buffer _must_ be zeroed before 0966 * rendering and the output will be clipped to its size. 0967 * 0968 * Direct rendering is only possible with anti-aliased glyphs. 0969 * 0970 * FT_RASTER_FLAG_CLIP :: 0971 * This flag is only used in direct rendering mode. If set, the output 0972 * will be clipped to a box specified in the `clip_box` field of the 0973 * @FT_Raster_Params structure. Otherwise, the `clip_box` is 0974 * effectively set to the bounding box and all spans are generated. 0975 * 0976 * FT_RASTER_FLAG_SDF :: 0977 * This flag is set to indicate that a signed distance field glyph 0978 * image should be generated. This is only used while rendering with 0979 * the @FT_RENDER_MODE_SDF render mode. 0980 */ 0981 #define FT_RASTER_FLAG_DEFAULT 0x0 0982 #define FT_RASTER_FLAG_AA 0x1 0983 #define FT_RASTER_FLAG_DIRECT 0x2 0984 #define FT_RASTER_FLAG_CLIP 0x4 0985 #define FT_RASTER_FLAG_SDF 0x8 0986 0987 /* these constants are deprecated; use the corresponding */ 0988 /* `FT_RASTER_FLAG_XXX` values instead */ 0989 #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT 0990 #define ft_raster_flag_aa FT_RASTER_FLAG_AA 0991 #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT 0992 #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP 0993 0994 0995 /************************************************************************** 0996 * 0997 * @struct: 0998 * FT_Raster_Params 0999 * 1000 * @description: 1001 * A structure to hold the parameters used by a raster's render function, 1002 * passed as an argument to @FT_Outline_Render. 1003 * 1004 * @fields: 1005 * target :: 1006 * The target bitmap. 1007 * 1008 * source :: 1009 * A pointer to the source glyph image (e.g., an @FT_Outline). 1010 * 1011 * flags :: 1012 * The rendering flags. 1013 * 1014 * gray_spans :: 1015 * The gray span drawing callback. 1016 * 1017 * black_spans :: 1018 * Unused. 1019 * 1020 * bit_test :: 1021 * Unused. 1022 * 1023 * bit_set :: 1024 * Unused. 1025 * 1026 * user :: 1027 * User-supplied data that is passed to each drawing callback. 1028 * 1029 * clip_box :: 1030 * An optional span clipping box expressed in _integer_ pixels 1031 * (not in 26.6 fixed-point units). 1032 * 1033 * @note: 1034 * The @FT_RASTER_FLAG_AA bit flag must be set in the `flags` to 1035 * generate an anti-aliased glyph bitmap, otherwise a monochrome bitmap 1036 * is generated. The `target` should have appropriate pixel mode and its 1037 * dimensions define the clipping region. 1038 * 1039 * If both @FT_RASTER_FLAG_AA and @FT_RASTER_FLAG_DIRECT bit flags 1040 * are set in `flags`, the raster calls an @FT_SpanFunc callback 1041 * `gray_spans` with `user` data as an argument ignoring `target`. This 1042 * allows direct composition over a pre-existing user surface to perform 1043 * the span drawing and composition. To optionally clip the spans, set 1044 * the @FT_RASTER_FLAG_CLIP flag and `clip_box`. The monochrome raster 1045 * does not support the direct mode. 1046 * 1047 * The gray-level rasterizer always uses 256 gray levels. If you want 1048 * fewer gray levels, you have to use @FT_RASTER_FLAG_DIRECT and reduce 1049 * the levels in the callback function. 1050 */ 1051 typedef struct FT_Raster_Params_ 1052 { 1053 const FT_Bitmap* target; 1054 const void* source; 1055 int flags; 1056 FT_SpanFunc gray_spans; 1057 FT_SpanFunc black_spans; /* unused */ 1058 FT_Raster_BitTest_Func bit_test; /* unused */ 1059 FT_Raster_BitSet_Func bit_set; /* unused */ 1060 void* user; 1061 FT_BBox clip_box; 1062 1063 } FT_Raster_Params; 1064 1065 1066 /************************************************************************** 1067 * 1068 * @type: 1069 * FT_Raster 1070 * 1071 * @description: 1072 * An opaque handle (pointer) to a raster object. Each object can be 1073 * used independently to convert an outline into a bitmap or pixmap. 1074 * 1075 * @note: 1076 * In FreeType 2, all rasters are now encapsulated within specific 1077 * @FT_Renderer modules and only used in their context. 1078 * 1079 */ 1080 typedef struct FT_RasterRec_* FT_Raster; 1081 1082 1083 /************************************************************************** 1084 * 1085 * @functype: 1086 * FT_Raster_NewFunc 1087 * 1088 * @description: 1089 * A function used to create a new raster object. 1090 * 1091 * @input: 1092 * memory :: 1093 * A handle to the memory allocator. 1094 * 1095 * @output: 1096 * raster :: 1097 * A handle to the new raster object. 1098 * 1099 * @return: 1100 * Error code. 0~means success. 1101 * 1102 * @note: 1103 * The `memory` parameter is a typeless pointer in order to avoid 1104 * un-wanted dependencies on the rest of the FreeType code. In practice, 1105 * it is an @FT_Memory object, i.e., a handle to the standard FreeType 1106 * memory allocator. However, this field can be completely ignored by a 1107 * given raster implementation. 1108 */ 1109 typedef int 1110 (*FT_Raster_NewFunc)( void* memory, 1111 FT_Raster* raster ); 1112 1113 #define FT_Raster_New_Func FT_Raster_NewFunc 1114 1115 1116 /************************************************************************** 1117 * 1118 * @functype: 1119 * FT_Raster_DoneFunc 1120 * 1121 * @description: 1122 * A function used to destroy a given raster object. 1123 * 1124 * @input: 1125 * raster :: 1126 * A handle to the raster object. 1127 */ 1128 typedef void 1129 (*FT_Raster_DoneFunc)( FT_Raster raster ); 1130 1131 #define FT_Raster_Done_Func FT_Raster_DoneFunc 1132 1133 1134 /************************************************************************** 1135 * 1136 * @functype: 1137 * FT_Raster_ResetFunc 1138 * 1139 * @description: 1140 * FreeType used to provide an area of memory called the 'render pool' 1141 * available to all registered rasterizers. This was not thread safe, 1142 * however, and now FreeType never allocates this pool. 1143 * 1144 * This function is called after a new raster object is created. 1145 * 1146 * @input: 1147 * raster :: 1148 * A handle to the new raster object. 1149 * 1150 * pool_base :: 1151 * Previously, the address in memory of the render pool. Set this to 1152 * `NULL`. 1153 * 1154 * pool_size :: 1155 * Previously, the size in bytes of the render pool. Set this to 0. 1156 * 1157 * @note: 1158 * Rasterizers should rely on dynamic or stack allocation if they want to 1159 * (a handle to the memory allocator is passed to the rasterizer 1160 * constructor). 1161 */ 1162 typedef void 1163 (*FT_Raster_ResetFunc)( FT_Raster raster, 1164 unsigned char* pool_base, 1165 unsigned long pool_size ); 1166 1167 #define FT_Raster_Reset_Func FT_Raster_ResetFunc 1168 1169 1170 /************************************************************************** 1171 * 1172 * @functype: 1173 * FT_Raster_SetModeFunc 1174 * 1175 * @description: 1176 * This function is a generic facility to change modes or attributes in a 1177 * given raster. This can be used for debugging purposes, or simply to 1178 * allow implementation-specific 'features' in a given raster module. 1179 * 1180 * @input: 1181 * raster :: 1182 * A handle to the new raster object. 1183 * 1184 * mode :: 1185 * A 4-byte tag used to name the mode or property. 1186 * 1187 * args :: 1188 * A pointer to the new mode/property to use. 1189 */ 1190 typedef int 1191 (*FT_Raster_SetModeFunc)( FT_Raster raster, 1192 unsigned long mode, 1193 void* args ); 1194 1195 #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc 1196 1197 1198 /************************************************************************** 1199 * 1200 * @functype: 1201 * FT_Raster_RenderFunc 1202 * 1203 * @description: 1204 * Invoke a given raster to scan-convert a given glyph image into a 1205 * target bitmap. 1206 * 1207 * @input: 1208 * raster :: 1209 * A handle to the raster object. 1210 * 1211 * params :: 1212 * A pointer to an @FT_Raster_Params structure used to store the 1213 * rendering parameters. 1214 * 1215 * @return: 1216 * Error code. 0~means success. 1217 * 1218 * @note: 1219 * The exact format of the source image depends on the raster's glyph 1220 * format defined in its @FT_Raster_Funcs structure. It can be an 1221 * @FT_Outline or anything else in order to support a large array of 1222 * glyph formats. 1223 * 1224 * Note also that the render function can fail and return a 1225 * `FT_Err_Unimplemented_Feature` error code if the raster used does not 1226 * support direct composition. 1227 */ 1228 typedef int 1229 (*FT_Raster_RenderFunc)( FT_Raster raster, 1230 const FT_Raster_Params* params ); 1231 1232 #define FT_Raster_Render_Func FT_Raster_RenderFunc 1233 1234 1235 /************************************************************************** 1236 * 1237 * @struct: 1238 * FT_Raster_Funcs 1239 * 1240 * @description: 1241 * A structure used to describe a given raster class to the library. 1242 * 1243 * @fields: 1244 * glyph_format :: 1245 * The supported glyph format for this raster. 1246 * 1247 * raster_new :: 1248 * The raster constructor. 1249 * 1250 * raster_reset :: 1251 * Used to reset the render pool within the raster. 1252 * 1253 * raster_render :: 1254 * A function to render a glyph into a given bitmap. 1255 * 1256 * raster_done :: 1257 * The raster destructor. 1258 */ 1259 typedef struct FT_Raster_Funcs_ 1260 { 1261 FT_Glyph_Format glyph_format; 1262 1263 FT_Raster_NewFunc raster_new; 1264 FT_Raster_ResetFunc raster_reset; 1265 FT_Raster_SetModeFunc raster_set_mode; 1266 FT_Raster_RenderFunc raster_render; 1267 FT_Raster_DoneFunc raster_done; 1268 1269 } FT_Raster_Funcs; 1270 1271 /* */ 1272 1273 1274 FT_END_HEADER 1275 1276 #endif /* FTIMAGE_H_ */ 1277 1278 1279 /* END */ 1280 1281 1282 /* Local Variables: */ 1283 /* coding: utf-8 */ 1284 /* End: */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|