| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | /***************************************************************************/ |
| 5 | /* */ |
| 6 | /* ftimage.h */ |
| 7 | /* */ |
| 8 | /* FreeType glyph image formats and default raster interface */ |
| 9 | /* (specification). */ |
| 10 | /* */ |
| 11 | /* Copyright 1996-2001, 2002, 2003, 2004 by */ |
| 12 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 13 | /* */ |
| 14 | /* This file is part of the FreeType project, and may only be used, */ |
| 15 | /* modified, and distributed under the terms of the FreeType project */ |
| 16 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 17 | /* this file you indicate that you have read the license and */ |
| 18 | /* understand and accept it fully. */ |
| 19 | /* */ |
| 20 | /***************************************************************************/ |
| 21 | |
| 22 | /*************************************************************************/ |
| 23 | /* */ |
| 24 | /* Note: A `raster' is simply a scan-line converter, used to render */ |
| 25 | /* QT_FT_Outlines into QT_FT_Bitmaps. */ |
| 26 | /* */ |
| 27 | /*************************************************************************/ |
| 28 | |
| 29 | |
| 30 | #ifndef __QT_FTIMAGE_H__ |
| 31 | #define __QT_FTIMAGE_H__ |
| 32 | |
| 33 | /* |
| 34 | // W A R N I N G |
| 35 | // ------------- |
| 36 | // |
| 37 | // This file is not part of the Qt API. It exists purely as an |
| 38 | // implementation detail. This header file may change from version to |
| 39 | // version without notice, or even be removed. |
| 40 | // |
| 41 | // We mean it. |
| 42 | */ |
| 43 | |
| 44 | QT_FT_BEGIN_HEADER |
| 45 | |
| 46 | /*************************************************************************/ |
| 47 | /* */ |
| 48 | /* <Section> */ |
| 49 | /* basic_types */ |
| 50 | /* */ |
| 51 | /*************************************************************************/ |
| 52 | |
| 53 | |
| 54 | /*************************************************************************/ |
| 55 | /* */ |
| 56 | /* <Type> */ |
| 57 | /* QT_FT_Pos */ |
| 58 | /* */ |
| 59 | /* <Description> */ |
| 60 | /* The type QT_FT_Pos is a 32-bit integer used to store vectorial */ |
| 61 | /* coordinates. Depending on the context, these can represent */ |
| 62 | /* distances in integer font units, or 16,16, or 26.6 fixed float */ |
| 63 | /* pixel coordinates. */ |
| 64 | /* */ |
| 65 | typedef signed int QT_FT_Pos; |
| 66 | |
| 67 | |
| 68 | /*************************************************************************/ |
| 69 | /* */ |
| 70 | /* <Struct> */ |
| 71 | /* QT_FT_Vector */ |
| 72 | /* */ |
| 73 | /* <Description> */ |
| 74 | /* A simple structure used to store a 2D vector; coordinates are of */ |
| 75 | /* the QT_FT_Pos type. */ |
| 76 | /* */ |
| 77 | /* <Fields> */ |
| 78 | /* x :: The horizontal coordinate. */ |
| 79 | /* y :: The vertical coordinate. */ |
| 80 | /* */ |
| 81 | typedef struct QT_FT_Vector_ |
| 82 | { |
| 83 | QT_FT_Pos x; |
| 84 | QT_FT_Pos y; |
| 85 | |
| 86 | } QT_FT_Vector; |
| 87 | |
| 88 | |
| 89 | /*************************************************************************/ |
| 90 | /* */ |
| 91 | /* <Struct> */ |
| 92 | /* QT_FT_BBox */ |
| 93 | /* */ |
| 94 | /* <Description> */ |
| 95 | /* A structure used to hold an outline's bounding box, i.e., the */ |
| 96 | /* coordinates of its extrema in the horizontal and vertical */ |
| 97 | /* directions. */ |
| 98 | /* */ |
| 99 | /* <Fields> */ |
| 100 | /* xMin :: The horizontal minimum (left-most). */ |
| 101 | /* */ |
| 102 | /* yMin :: The vertical minimum (bottom-most). */ |
| 103 | /* */ |
| 104 | /* xMax :: The horizontal maximum (right-most). */ |
| 105 | /* */ |
| 106 | /* yMax :: The vertical maximum (top-most). */ |
| 107 | /* */ |
| 108 | typedef struct QT_FT_BBox_ |
| 109 | { |
| 110 | QT_FT_Pos xMin, yMin; |
| 111 | QT_FT_Pos xMax, yMax; |
| 112 | |
| 113 | } QT_FT_BBox; |
| 114 | |
| 115 | |
| 116 | /*************************************************************************/ |
| 117 | /* */ |
| 118 | /* <Enum> */ |
| 119 | /* QT_FT_Pixel_Mode */ |
| 120 | /* */ |
| 121 | /* <Description> */ |
| 122 | /* An enumeration type used to describe the format of pixels in a */ |
| 123 | /* given bitmap. Note that additional formats may be added in the */ |
| 124 | /* future. */ |
| 125 | /* */ |
| 126 | /* <Values> */ |
| 127 | /* QT_FT_PIXEL_MODE_NONE :: */ |
| 128 | /* Value 0 is reserved. */ |
| 129 | /* */ |
| 130 | /* QT_FT_PIXEL_MODE_MONO :: */ |
| 131 | /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */ |
| 132 | /* are stored in most-significant order (MSB), which means that */ |
| 133 | /* the left-most pixel in a byte has value 128. */ |
| 134 | /* */ |
| 135 | /* QT_FT_PIXEL_MODE_GRAY :: */ |
| 136 | /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ |
| 137 | /* images. Each pixel is stored in one byte. Note that the number */ |
| 138 | /* of value "gray" levels is stored in the `num_bytes' field of */ |
| 139 | /* the @QT_FT_Bitmap structure (it generally is 256). */ |
| 140 | /* */ |
| 141 | /* QT_FT_PIXEL_MODE_GRAY2 :: */ |
| 142 | /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */ |
| 143 | /* bitmaps in font files according to the OpenType specification. */ |
| 144 | /* We haven't found a single font using this format, however. */ |
| 145 | /* */ |
| 146 | /* QT_FT_PIXEL_MODE_GRAY4 :: */ |
| 147 | /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */ |
| 148 | /* bitmaps in font files according to the OpenType specification. */ |
| 149 | /* We haven't found a single font using this format, however. */ |
| 150 | /* */ |
| 151 | /* QT_FT_PIXEL_MODE_LCD :: */ |
| 152 | /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ |
| 153 | /* images used for display on LCD displays; the bitmap's width is */ |
| 154 | /* three times wider than the original glyph image. See also */ |
| 155 | /* @QT_FT_RENDER_MODE_LCD. */ |
| 156 | /* */ |
| 157 | /* QT_FT_PIXEL_MODE_LCD_V :: */ |
| 158 | /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ |
| 159 | /* images used for display on rotated LCD displays; the bitmap's */ |
| 160 | /* height is three times taller than the original glyph image. */ |
| 161 | /* See also @QT_FT_RENDER_MODE_LCD_V. */ |
| 162 | /* */ |
| 163 | typedef enum QT_FT_Pixel_Mode_ |
| 164 | { |
| 165 | QT_FT_PIXEL_MODE_NONE = 0, |
| 166 | QT_FT_PIXEL_MODE_MONO, |
| 167 | QT_FT_PIXEL_MODE_GRAY, |
| 168 | QT_FT_PIXEL_MODE_GRAY2, |
| 169 | QT_FT_PIXEL_MODE_GRAY4, |
| 170 | QT_FT_PIXEL_MODE_LCD, |
| 171 | QT_FT_PIXEL_MODE_LCD_V, |
| 172 | |
| 173 | QT_FT_PIXEL_MODE_MAX /* do not remove */ |
| 174 | |
| 175 | } QT_FT_Pixel_Mode; |
| 176 | |
| 177 | |
| 178 | /*************************************************************************/ |
| 179 | /* */ |
| 180 | /* <Enum> */ |
| 181 | /* qt_ft_pixel_mode_xxx */ |
| 182 | /* */ |
| 183 | /* <Description> */ |
| 184 | /* A list of deprecated constants. Use the corresponding */ |
| 185 | /* @QT_FT_Pixel_Mode values instead. */ |
| 186 | /* */ |
| 187 | /* <Values> */ |
| 188 | /* qt_ft_pixel_mode_none :: see @QT_FT_PIXEL_MODE_NONE */ |
| 189 | /* qt_ft_pixel_mode_mono :: see @QT_FT_PIXEL_MODE_MONO */ |
| 190 | /* qt_ft_pixel_mode_grays :: see @QT_FT_PIXEL_MODE_GRAY */ |
| 191 | /* qt_ft_pixel_mode_pal2 :: see @QT_FT_PIXEL_MODE_GRAY2 */ |
| 192 | /* qt_ft_pixel_mode_pal4 :: see @QT_FT_PIXEL_MODE_GRAY4 */ |
| 193 | /* */ |
| 194 | #define qt_ft_pixel_mode_none QT_FT_PIXEL_MODE_NONE |
| 195 | #define qt_ft_pixel_mode_mono QT_FT_PIXEL_MODE_MONO |
| 196 | #define qt_ft_pixel_mode_grays QT_FT_PIXEL_MODE_GRAY |
| 197 | #define qt_ft_pixel_mode_pal2 QT_FT_PIXEL_MODE_GRAY2 |
| 198 | #define qt_ft_pixel_mode_pal4 QT_FT_PIXEL_MODE_GRAY4 |
| 199 | |
| 200 | /* */ |
| 201 | |
| 202 | #if 0 |
| 203 | |
| 204 | /*************************************************************************/ |
| 205 | /* */ |
| 206 | /* <Enum> */ |
| 207 | /* QT_FT_Palette_Mode */ |
| 208 | /* */ |
| 209 | /* <Description> */ |
| 210 | /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */ |
| 211 | /* */ |
| 212 | /* An enumeration type used to describe the format of a bitmap */ |
| 213 | /* palette, used with qt_ft_pixel_mode_pal4 and qt_ft_pixel_mode_pal8. */ |
| 214 | /* */ |
| 215 | /* <Fields> */ |
| 216 | /* qt_ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */ |
| 217 | /* records. */ |
| 218 | /* */ |
| 219 | /* qt_ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */ |
| 220 | /* records. */ |
| 221 | /* */ |
| 222 | /* <Note> */ |
| 223 | /* As qt_ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */ |
| 224 | /* FreeType, these types are not handled by the library itself. */ |
| 225 | /* */ |
| 226 | typedef enum QT_FT_Palette_Mode_ |
| 227 | { |
| 228 | qt_ft_palette_mode_rgb = 0, |
| 229 | qt_ft_palette_mode_rgba, |
| 230 | |
| 231 | qt_ft_palettte_mode_max /* do not remove */ |
| 232 | |
| 233 | } QT_FT_Palette_Mode; |
| 234 | |
| 235 | /* */ |
| 236 | |
| 237 | #endif |
| 238 | |
| 239 | |
| 240 | /*************************************************************************/ |
| 241 | /* */ |
| 242 | /* <Struct> */ |
| 243 | /* QT_FT_Bitmap */ |
| 244 | /* */ |
| 245 | /* <Description> */ |
| 246 | /* A structure used to describe a bitmap or pixmap to the raster. */ |
| 247 | /* Note that we now manage pixmaps of various depths through the */ |
| 248 | /* `pixel_mode' field. */ |
| 249 | /* */ |
| 250 | /* <Fields> */ |
| 251 | /* rows :: The number of bitmap rows. */ |
| 252 | /* */ |
| 253 | /* width :: The number of pixels in bitmap row. */ |
| 254 | /* */ |
| 255 | /* pitch :: The pitch's absolute value is the number of bytes */ |
| 256 | /* taken by one bitmap row, including padding. */ |
| 257 | /* However, the pitch is positive when the bitmap has */ |
| 258 | /* a `down' flow, and negative when it has an `up' */ |
| 259 | /* flow. In all cases, the pitch is an offset to add */ |
| 260 | /* to a bitmap pointer in order to go down one row. */ |
| 261 | /* */ |
| 262 | /* buffer :: A typeless pointer to the bitmap buffer. This */ |
| 263 | /* value should be aligned on 32-bit boundaries in */ |
| 264 | /* most cases. */ |
| 265 | /* */ |
| 266 | /* num_grays :: This field is only used with */ |
| 267 | /* `QT_FT_PIXEL_MODE_GRAY'; it gives the number of gray */ |
| 268 | /* levels used in the bitmap. */ |
| 269 | /* */ |
| 270 | /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ |
| 271 | /* See @QT_FT_Pixel_Mode for possible values. */ |
| 272 | /* */ |
| 273 | /* palette_mode :: This field is only used with paletted pixel modes; */ |
| 274 | /* it indicates how the palette is stored. */ |
| 275 | /* */ |
| 276 | /* palette :: A typeless pointer to the bitmap palette; only */ |
| 277 | /* used for paletted pixel modes. */ |
| 278 | /* */ |
| 279 | /* <Note> */ |
| 280 | /* For now, the only pixel mode supported by FreeType are mono and */ |
| 281 | /* grays. However, drivers might be added in the future to support */ |
| 282 | /* more `colorful' options. */ |
| 283 | /* */ |
| 284 | /* When using pixel modes pal2, pal4 and pal8 with a void `palette' */ |
| 285 | /* field, a gray pixmap with respectively 4, 16, and 256 levels of */ |
| 286 | /* gray is assumed. This, in order to be compatible with some */ |
| 287 | /* embedded bitmap formats defined in the TrueType specification. */ |
| 288 | /* */ |
| 289 | /* Note that no font was found presenting such embedded bitmaps, so */ |
| 290 | /* this is currently completely unhandled by the library. */ |
| 291 | /* */ |
| 292 | typedef struct QT_FT_Bitmap_ |
| 293 | { |
| 294 | int rows; |
| 295 | int width; |
| 296 | int pitch; |
| 297 | unsigned char* buffer; |
| 298 | short num_grays; |
| 299 | char pixel_mode; |
| 300 | char palette_mode; |
| 301 | void* palette; |
| 302 | |
| 303 | } QT_FT_Bitmap; |
| 304 | |
| 305 | |
| 306 | /*************************************************************************/ |
| 307 | /* */ |
| 308 | /* <Section> */ |
| 309 | /* outline_processing */ |
| 310 | /* */ |
| 311 | /*************************************************************************/ |
| 312 | |
| 313 | |
| 314 | /*************************************************************************/ |
| 315 | /* */ |
| 316 | /* <Struct> */ |
| 317 | /* QT_FT_Outline */ |
| 318 | /* */ |
| 319 | /* <Description> */ |
| 320 | /* This structure is used to describe an outline to the scan-line */ |
| 321 | /* converter. */ |
| 322 | /* */ |
| 323 | /* <Fields> */ |
| 324 | /* n_contours :: The number of contours in the outline. */ |
| 325 | /* */ |
| 326 | /* n_points :: The number of points in the outline. */ |
| 327 | /* */ |
| 328 | /* points :: A pointer to an array of `n_points' QT_FT_Vector */ |
| 329 | /* elements, giving the outline's point coordinates. */ |
| 330 | /* */ |
| 331 | /* tags :: A pointer to an array of `n_points' chars, giving */ |
| 332 | /* each outline point's type. If bit 0 is unset, the */ |
| 333 | /* point is `off' the curve, i.e. a Bezier control */ |
| 334 | /* point, while it is `on' when set. */ |
| 335 | /* */ |
| 336 | /* Bit 1 is meaningful for `off' points only. If set, */ |
| 337 | /* it indicates a third-order Bezier arc control point; */ |
| 338 | /* and a second-order control point if unset. */ |
| 339 | /* */ |
| 340 | /* contours :: An array of `n_contours' shorts, giving the end */ |
| 341 | /* point of each contour within the outline. For */ |
| 342 | /* example, the first contour is defined by the points */ |
| 343 | /* `0' to `contours[0]', the second one is defined by */ |
| 344 | /* the points `contours[0]+1' to `contours[1]', etc. */ |
| 345 | /* */ |
| 346 | /* flags :: A set of bit flags used to characterize the outline */ |
| 347 | /* and give hints to the scan-converter and hinter on */ |
| 348 | /* how to convert/grid-fit it. See QT_FT_Outline_Flags. */ |
| 349 | /* */ |
| 350 | typedef struct QT_FT_Outline_ |
| 351 | { |
| 352 | int n_contours; /* number of contours in glyph */ |
| 353 | int n_points; /* number of points in the glyph */ |
| 354 | |
| 355 | QT_FT_Vector* points; /* the outline's points */ |
| 356 | char* tags; /* the points flags */ |
| 357 | int* contours; /* the contour end points */ |
| 358 | |
| 359 | int flags; /* outline masks */ |
| 360 | |
| 361 | } QT_FT_Outline; |
| 362 | |
| 363 | |
| 364 | /*************************************************************************/ |
| 365 | /* */ |
| 366 | /* <Enum> */ |
| 367 | /* QT_FT_OUTLINE_FLAGS */ |
| 368 | /* */ |
| 369 | /* <Description> */ |
| 370 | /* A list of bit-field constants use for the flags in an outline's */ |
| 371 | /* `flags' field. */ |
| 372 | /* */ |
| 373 | /* <Values> */ |
| 374 | /* QT_FT_OUTLINE_NONE :: Value 0 is reserved. */ |
| 375 | /* */ |
| 376 | /* QT_FT_OUTLINE_OWNER :: If set, this flag indicates that the */ |
| 377 | /* outline's field arrays (i.e. */ |
| 378 | /* `points', `flags' & `contours') are */ |
| 379 | /* `owned' by the outline object, and */ |
| 380 | /* should thus be freed when it is */ |
| 381 | /* destroyed. */ |
| 382 | /* */ |
| 383 | /* QT_FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */ |
| 384 | /* the non-zero winding rule. If set to */ |
| 385 | /* 1, the outline will be filled using */ |
| 386 | /* the even-odd fill rule (only works */ |
| 387 | /* with the smooth raster). */ |
| 388 | /* */ |
| 389 | /* QT_FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */ |
| 390 | /* outline are oriented in clock-wise */ |
| 391 | /* direction, as defined in the TrueType */ |
| 392 | /* specification. This flag is set if */ |
| 393 | /* the outline uses the opposite */ |
| 394 | /* direction (typically for Type 1 */ |
| 395 | /* fonts). This flag is ignored by the */ |
| 396 | /* scan-converter. However, it is very */ |
| 397 | /* important for the auto-hinter. */ |
| 398 | /* */ |
| 399 | /* QT_FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */ |
| 400 | /* try to detect drop-outs in an outline */ |
| 401 | /* and correct the glyph bitmap to */ |
| 402 | /* ensure consistent shape continuity. */ |
| 403 | /* If set, this flag hints the scan-line */ |
| 404 | /* converter to ignore such cases. */ |
| 405 | /* */ |
| 406 | /* QT_FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */ |
| 407 | /* scan-line converter should try to */ |
| 408 | /* convert this outline to bitmaps with */ |
| 409 | /* the highest possible quality. It is */ |
| 410 | /* typically set for small character */ |
| 411 | /* sizes. Note that this is only a */ |
| 412 | /* hint, that might be completely */ |
| 413 | /* ignored by a given scan-converter. */ |
| 414 | /* */ |
| 415 | /* QT_FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */ |
| 416 | /* scan-converter to only use a single */ |
| 417 | /* pass over the outline to render a */ |
| 418 | /* bitmap glyph image. Normally, it is */ |
| 419 | /* set for very large character sizes. */ |
| 420 | /* It is only a hint, that might be */ |
| 421 | /* completely ignored by a given */ |
| 422 | /* scan-converter. */ |
| 423 | /* */ |
| 424 | #define QT_FT_OUTLINE_NONE 0x0 |
| 425 | #define QT_FT_OUTLINE_OWNER 0x1 |
| 426 | #define QT_FT_OUTLINE_EVEN_ODD_FILL 0x2 |
| 427 | #define QT_FT_OUTLINE_REVERSE_FILL 0x4 |
| 428 | #define QT_FT_OUTLINE_IGNORE_DROPOUTS 0x8 |
| 429 | |
| 430 | #define QT_FT_OUTLINE_HIGH_PRECISION 0x100 |
| 431 | #define QT_FT_OUTLINE_SINGLE_PASS 0x200 |
| 432 | |
| 433 | |
| 434 | /************************************************************************* |
| 435 | * |
| 436 | * @enum: |
| 437 | * qt_ft_outline_flags |
| 438 | * |
| 439 | * @description: |
| 440 | * These constants are deprecated. Please use the corresponding |
| 441 | * @QT_FT_OUTLINE_FLAGS values. |
| 442 | * |
| 443 | * @values: |
| 444 | * qt_ft_outline_none :: See @QT_FT_OUTLINE_NONE. |
| 445 | * qt_ft_outline_owner :: See @QT_FT_OUTLINE_OWNER. |
| 446 | * qt_ft_outline_even_odd_fill :: See @QT_FT_OUTLINE_EVEN_ODD_FILL. |
| 447 | * qt_ft_outline_reverse_fill :: See @QT_FT_OUTLINE_REVERSE_FILL. |
| 448 | * qt_ft_outline_ignore_dropouts :: See @QT_FT_OUTLINE_IGNORE_DROPOUTS. |
| 449 | * qt_ft_outline_high_precision :: See @QT_FT_OUTLINE_HIGH_PRECISION. |
| 450 | * qt_ft_outline_single_pass :: See @QT_FT_OUTLINE_SINGLE_PASS. |
| 451 | */ |
| 452 | #define qt_ft_outline_none QT_FT_OUTLINE_NONE |
| 453 | #define qt_ft_outline_owner QT_FT_OUTLINE_OWNER |
| 454 | #define qt_ft_outline_even_odd_fill QT_FT_OUTLINE_EVEN_ODD_FILL |
| 455 | #define qt_ft_outline_reverse_fill QT_FT_OUTLINE_REVERSE_FILL |
| 456 | #define qt_ft_outline_ignore_dropouts QT_FT_OUTLINE_IGNORE_DROPOUTS |
| 457 | #define qt_ft_outline_high_precision QT_FT_OUTLINE_HIGH_PRECISION |
| 458 | #define qt_ft_outline_single_pass QT_FT_OUTLINE_SINGLE_PASS |
| 459 | |
| 460 | /* */ |
| 461 | |
| 462 | #define QT_FT_CURVE_TAG( flag ) ( flag & 3 ) |
| 463 | |
| 464 | #define QT_FT_CURVE_TAG_ON 1 |
| 465 | #define QT_FT_CURVE_TAG_CONIC 0 |
| 466 | #define QT_FT_CURVE_TAG_CUBIC 2 |
| 467 | |
| 468 | #define QT_FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ |
| 469 | #define QT_FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ |
| 470 | |
| 471 | #define QT_FT_CURVE_TAG_TOUCH_BOTH ( QT_FT_CURVE_TAG_TOUCH_X | \ |
| 472 | QT_FT_CURVE_TAG_TOUCH_Y ) |
| 473 | |
| 474 | #define QT_FT_Curve_Tag_On QT_FT_CURVE_TAG_ON |
| 475 | #define QT_FT_Curve_Tag_Conic QT_FT_CURVE_TAG_CONIC |
| 476 | #define QT_FT_Curve_Tag_Cubic QT_FT_CURVE_TAG_CUBIC |
| 477 | #define QT_FT_Curve_Tag_Touch_X QT_FT_CURVE_TAG_TOUCH_X |
| 478 | #define QT_FT_Curve_Tag_Touch_Y QT_FT_CURVE_TAG_TOUCH_Y |
| 479 | |
| 480 | /*************************************************************************/ |
| 481 | /* */ |
| 482 | /* <FuncType> */ |
| 483 | /* QT_FT_Outline_MoveToFunc */ |
| 484 | /* */ |
| 485 | /* <Description> */ |
| 486 | /* A function pointer type used to describe the signature of a `move */ |
| 487 | /* to' function during outline walking/decomposition. */ |
| 488 | /* */ |
| 489 | /* A `move to' is emitted to start a new contour in an outline. */ |
| 490 | /* */ |
| 491 | /* <Input> */ |
| 492 | /* to :: A pointer to the target point of the `move to'. */ |
| 493 | /* */ |
| 494 | /* user :: A typeless pointer which is passed from the caller of the */ |
| 495 | /* decomposition function. */ |
| 496 | /* */ |
| 497 | /* <Return> */ |
| 498 | /* Error code. 0 means success. */ |
| 499 | /* */ |
| 500 | typedef int |
| 501 | (*QT_FT_Outline_MoveToFunc)( QT_FT_Vector* to, |
| 502 | void* user ); |
| 503 | |
| 504 | #define QT_FT_Outline_MoveTo_Func QT_FT_Outline_MoveToFunc |
| 505 | |
| 506 | /*************************************************************************/ |
| 507 | /* */ |
| 508 | /* <FuncType> */ |
| 509 | /* QT_FT_Outline_LineToFunc */ |
| 510 | /* */ |
| 511 | /* <Description> */ |
| 512 | /* A function pointer type used to describe the signature of a `line */ |
| 513 | /* to' function during outline walking/decomposition. */ |
| 514 | /* */ |
| 515 | /* A `line to' is emitted to indicate a segment in the outline. */ |
| 516 | /* */ |
| 517 | /* <Input> */ |
| 518 | /* to :: A pointer to the target point of the `line to'. */ |
| 519 | /* */ |
| 520 | /* user :: A typeless pointer which is passed from the caller of the */ |
| 521 | /* decomposition function. */ |
| 522 | /* */ |
| 523 | /* <Return> */ |
| 524 | /* Error code. 0 means success. */ |
| 525 | /* */ |
| 526 | typedef int |
| 527 | (*QT_FT_Outline_LineToFunc)( QT_FT_Vector* to, |
| 528 | void* user ); |
| 529 | |
| 530 | #define QT_FT_Outline_LineTo_Func QT_FT_Outline_LineToFunc |
| 531 | |
| 532 | /*************************************************************************/ |
| 533 | /* */ |
| 534 | /* <FuncType> */ |
| 535 | /* QT_FT_Outline_ConicToFunc */ |
| 536 | /* */ |
| 537 | /* <Description> */ |
| 538 | /* A function pointer type use to describe the signature of a `conic */ |
| 539 | /* to' function during outline walking/decomposition. */ |
| 540 | /* */ |
| 541 | /* A `conic to' is emitted to indicate a second-order Bezier arc in */ |
| 542 | /* the outline. */ |
| 543 | /* */ |
| 544 | /* <Input> */ |
| 545 | /* control :: An intermediate control point between the last position */ |
| 546 | /* and the new target in `to'. */ |
| 547 | /* */ |
| 548 | /* to :: A pointer to the target end point of the conic arc. */ |
| 549 | /* */ |
| 550 | /* user :: A typeless pointer which is passed from the caller of */ |
| 551 | /* the decomposition function. */ |
| 552 | /* */ |
| 553 | /* <Return> */ |
| 554 | /* Error code. 0 means success. */ |
| 555 | /* */ |
| 556 | typedef int |
| 557 | (*QT_FT_Outline_ConicToFunc)( QT_FT_Vector* control, |
| 558 | QT_FT_Vector* to, |
| 559 | void* user ); |
| 560 | |
| 561 | #define QT_FT_Outline_ConicTo_Func QT_FT_Outline_ConicToFunc |
| 562 | |
| 563 | /*************************************************************************/ |
| 564 | /* */ |
| 565 | /* <FuncType> */ |
| 566 | /* QT_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/decomposition. */ |
| 571 | /* */ |
| 572 | /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ |
| 573 | /* */ |
| 574 | /* <Input> */ |
| 575 | /* control1 :: A pointer to the first Bezier control point. */ |
| 576 | /* */ |
| 577 | /* control2 :: A pointer to the second Bezier 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 | (*QT_FT_Outline_CubicToFunc)( QT_FT_Vector* control1, |
| 589 | QT_FT_Vector* control2, |
| 590 | QT_FT_Vector* to, |
| 591 | void* user ); |
| 592 | |
| 593 | #define QT_FT_Outline_CubicTo_Func QT_FT_Outline_CubicToFunc |
| 594 | |
| 595 | |
| 596 | /*************************************************************************/ |
| 597 | /* */ |
| 598 | /* <Struct> */ |
| 599 | /* QT_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 Beziers, */ |
| 604 | /* as well as `move to' and `close to' operations. */ |
| 605 | /* */ |
| 606 | /* <Fields> */ |
| 607 | /* move_to :: The `move to' emitter. */ |
| 608 | /* */ |
| 609 | /* line_to :: The segment emitter. */ |
| 610 | /* */ |
| 611 | /* conic_to :: The second-order Bezier arc emitter. */ |
| 612 | /* */ |
| 613 | /* cubic_to :: The third-order Bezier arc emitter. */ |
| 614 | /* */ |
| 615 | /* shift :: The shift that is applied to coordinates before they */ |
| 616 | /* are sent to the emitter. */ |
| 617 | /* */ |
| 618 | /* delta :: The delta that is applied to coordinates before they */ |
| 619 | /* are sent to the emitter, but after the shift. */ |
| 620 | /* */ |
| 621 | /* <Note> */ |
| 622 | /* The point coordinates sent to the emitters are the transformed */ |
| 623 | /* version of the original coordinates (this is important for high */ |
| 624 | /* accuracy during scan-conversion). The transformation is simple: */ |
| 625 | /* */ |
| 626 | /* x' = (x << shift) - delta */ |
| 627 | /* y' = (x << shift) - delta */ |
| 628 | /* */ |
| 629 | /* Set the value of `shift' and `delta' to 0 to get the original */ |
| 630 | /* point coordinates. */ |
| 631 | /* */ |
| 632 | typedef struct QT_FT_Outline_Funcs_ |
| 633 | { |
| 634 | QT_FT_Outline_MoveToFunc move_to; |
| 635 | QT_FT_Outline_LineToFunc line_to; |
| 636 | QT_FT_Outline_ConicToFunc conic_to; |
| 637 | QT_FT_Outline_CubicToFunc cubic_to; |
| 638 | |
| 639 | int shift; |
| 640 | QT_FT_Pos delta; |
| 641 | |
| 642 | } QT_FT_Outline_Funcs; |
| 643 | |
| 644 | |
| 645 | /*************************************************************************/ |
| 646 | /* */ |
| 647 | /* <Section> */ |
| 648 | /* basic_types */ |
| 649 | /* */ |
| 650 | /*************************************************************************/ |
| 651 | |
| 652 | |
| 653 | /*************************************************************************/ |
| 654 | /* */ |
| 655 | /* <Macro> */ |
| 656 | /* QT_FT_IMAGE_TAG */ |
| 657 | /* */ |
| 658 | /* <Description> */ |
| 659 | /* This macro converts four letter tags into an unsigned long. */ |
| 660 | /* */ |
| 661 | /* <Note> */ |
| 662 | /* Since many 16bit compilers don't like 32bit enumerations, you */ |
| 663 | /* should redefine this macro in case of problems to something like */ |
| 664 | /* this: */ |
| 665 | /* */ |
| 666 | /* #define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ |
| 667 | /* */ |
| 668 | /* to get a simple enumeration without assigning special numbers. */ |
| 669 | /* */ |
| 670 | #ifndef QT_FT_IMAGE_TAG |
| 671 | #define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ |
| 672 | value = ( ( (unsigned long)_x1 << 24 ) | \ |
| 673 | ( (unsigned long)_x2 << 16 ) | \ |
| 674 | ( (unsigned long)_x3 << 8 ) | \ |
| 675 | (unsigned long)_x4 ) |
| 676 | #endif /* QT_FT_IMAGE_TAG */ |
| 677 | |
| 678 | |
| 679 | /*************************************************************************/ |
| 680 | /* */ |
| 681 | /* <Enum> */ |
| 682 | /* QT_FT_Glyph_Format */ |
| 683 | /* */ |
| 684 | /* <Description> */ |
| 685 | /* An enumeration type used to describe the format of a given glyph */ |
| 686 | /* image. Note that this version of FreeType only supports two image */ |
| 687 | /* formats, even though future font drivers will be able to register */ |
| 688 | /* their own format. */ |
| 689 | /* */ |
| 690 | /* <Values> */ |
| 691 | /* QT_FT_GLYPH_FORMAT_NONE :: */ |
| 692 | /* The value 0 is reserved and does describe a glyph format. */ |
| 693 | /* */ |
| 694 | /* QT_FT_GLYPH_FORMAT_COMPOSITE :: */ |
| 695 | /* The glyph image is a composite of several other images. This */ |
| 696 | /* format is _only_ used with @QT_FT_LOAD_NO_RECURSE, and is used to */ |
| 697 | /* report compound glyphs (like accented characters). */ |
| 698 | /* */ |
| 699 | /* QT_FT_GLYPH_FORMAT_BITMAP :: */ |
| 700 | /* The glyph image is a bitmap, and can be described as an */ |
| 701 | /* @QT_FT_Bitmap. You generally need to access the `bitmap' field of */ |
| 702 | /* the @QT_FT_GlyphSlotRec structure to read it. */ |
| 703 | /* */ |
| 704 | /* QT_FT_GLYPH_FORMAT_OUTLINE :: */ |
| 705 | /* The glyph image is a vertorial outline made of line segments */ |
| 706 | /* and Bezier arcs; it can be described as an @QT_FT_Outline; you */ |
| 707 | /* generally want to access the `outline' field of the */ |
| 708 | /* @QT_FT_GlyphSlotRec structure to read it. */ |
| 709 | /* */ |
| 710 | /* QT_FT_GLYPH_FORMAT_PLOTTER :: */ |
| 711 | /* The glyph image is a vectorial path with no inside/outside */ |
| 712 | /* contours. Some Type 1 fonts, like those in the Hershey family, */ |
| 713 | /* contain glyphs in this format. These are described as */ |
| 714 | /* @QT_FT_Outline, but FreeType isn't currently capable of rendering */ |
| 715 | /* them correctly. */ |
| 716 | /* */ |
| 717 | typedef enum QT_FT_Glyph_Format_ |
| 718 | { |
| 719 | QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), |
| 720 | |
| 721 | QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), |
| 722 | QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), |
| 723 | QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), |
| 724 | QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) |
| 725 | |
| 726 | } QT_FT_Glyph_Format; |
| 727 | |
| 728 | |
| 729 | /*************************************************************************/ |
| 730 | /* */ |
| 731 | /* <Enum> */ |
| 732 | /* qt_ft_glyph_format_xxx */ |
| 733 | /* */ |
| 734 | /* <Description> */ |
| 735 | /* A list of decprecated constants. Use the corresponding */ |
| 736 | /* @QT_FT_Glyph_Format values instead. */ |
| 737 | /* */ |
| 738 | /* <Values> */ |
| 739 | /* qt_ft_glyph_format_none :: see @QT_FT_GLYPH_FORMAT_NONE */ |
| 740 | /* qt_ft_glyph_format_composite :: see @QT_FT_GLYPH_FORMAT_COMPOSITE */ |
| 741 | /* qt_ft_glyph_format_bitmap :: see @QT_FT_GLYPH_FORMAT_BITMAP */ |
| 742 | /* qt_ft_glyph_format_outline :: see @QT_FT_GLYPH_FORMAT_OUTLINE */ |
| 743 | /* qt_ft_glyph_format_plotter :: see @QT_FT_GLYPH_FORMAT_PLOTTER */ |
| 744 | /* */ |
| 745 | #define qt_ft_glyph_format_none QT_FT_GLYPH_FORMAT_NONE |
| 746 | #define qt_ft_glyph_format_composite QT_FT_GLYPH_FORMAT_COMPOSITE |
| 747 | #define qt_ft_glyph_format_bitmap QT_FT_GLYPH_FORMAT_BITMAP |
| 748 | #define qt_ft_glyph_format_outline QT_FT_GLYPH_FORMAT_OUTLINE |
| 749 | #define qt_ft_glyph_format_plotter QT_FT_GLYPH_FORMAT_PLOTTER |
| 750 | |
| 751 | |
| 752 | /*************************************************************************/ |
| 753 | /*************************************************************************/ |
| 754 | /*************************************************************************/ |
| 755 | /***** *****/ |
| 756 | /***** R A S T E R D E F I N I T I O N S *****/ |
| 757 | /***** *****/ |
| 758 | /*************************************************************************/ |
| 759 | /*************************************************************************/ |
| 760 | /*************************************************************************/ |
| 761 | |
| 762 | |
| 763 | /*************************************************************************/ |
| 764 | /* */ |
| 765 | /* A raster is a scan converter, in charge of rendering an outline into */ |
| 766 | /* a a bitmap. This section contains the public API for rasters. */ |
| 767 | /* */ |
| 768 | /* Note that in FreeType 2, all rasters are now encapsulated within */ |
| 769 | /* specific modules called `renderers'. See `freetype/ftrender.h' for */ |
| 770 | /* more details on renderers. */ |
| 771 | /* */ |
| 772 | /*************************************************************************/ |
| 773 | |
| 774 | |
| 775 | /*************************************************************************/ |
| 776 | /* */ |
| 777 | /* <Section> */ |
| 778 | /* raster */ |
| 779 | /* */ |
| 780 | /* <Title> */ |
| 781 | /* Scanline converter */ |
| 782 | /* */ |
| 783 | /* <Abstract> */ |
| 784 | /* How vectorial outlines are converted into bitmaps and pixmaps. */ |
| 785 | /* */ |
| 786 | /* <Description> */ |
| 787 | /* This section contains technical definitions. */ |
| 788 | /* */ |
| 789 | /*************************************************************************/ |
| 790 | |
| 791 | |
| 792 | /*************************************************************************/ |
| 793 | /* */ |
| 794 | /* <Type> */ |
| 795 | /* QT_FT_Raster */ |
| 796 | /* */ |
| 797 | /* <Description> */ |
| 798 | /* A handle (pointer) to a raster object. Each object can be used */ |
| 799 | /* independently to convert an outline into a bitmap or pixmap. */ |
| 800 | /* */ |
| 801 | typedef struct TRaster_ *QT_FT_Raster; |
| 802 | |
| 803 | |
| 804 | /*************************************************************************/ |
| 805 | /* */ |
| 806 | /* <Struct> */ |
| 807 | /* QT_FT_Span */ |
| 808 | /* */ |
| 809 | /* <Description> */ |
| 810 | /* A structure used to model a single span of gray (or black) pixels */ |
| 811 | /* when rendering a monochrome or anti-aliased bitmap. */ |
| 812 | /* */ |
| 813 | /* <Fields> */ |
| 814 | /* x :: The span's horizontal start position. */ |
| 815 | /* */ |
| 816 | /* len :: The span's length in pixels. */ |
| 817 | /* */ |
| 818 | /* coverage :: The span color/coverage, ranging from 0 (background) */ |
| 819 | /* to 255 (foreground). Only used for anti-aliased */ |
| 820 | /* rendering. */ |
| 821 | /* */ |
| 822 | /* <Note> */ |
| 823 | /* This structure is used by the span drawing callback type named */ |
| 824 | /* QT_FT_SpanFunc which takes the y-coordinate of the span as a */ |
| 825 | /* a parameter. */ |
| 826 | /* */ |
| 827 | /* The coverage value is always between 0 and 255, even if the number */ |
| 828 | /* of gray levels have been set through QT_FT_Set_Gray_Levels(). */ |
| 829 | /* */ |
| 830 | typedef struct QT_FT_Span_ |
| 831 | { |
| 832 | int x; |
| 833 | int len; |
| 834 | int y; |
| 835 | unsigned char coverage; |
| 836 | } QT_FT_Span; |
| 837 | |
| 838 | |
| 839 | /*************************************************************************/ |
| 840 | /* */ |
| 841 | /* <FuncType> */ |
| 842 | /* QT_FT_SpanFunc */ |
| 843 | /* */ |
| 844 | /* <Description> */ |
| 845 | /* A function used as a call-back by the anti-aliased renderer in */ |
| 846 | /* order to let client applications draw themselves the gray pixel */ |
| 847 | /* spans on each scan line. */ |
| 848 | /* */ |
| 849 | /* <Input> */ |
| 850 | /* y :: The scanline's y-coordinate. */ |
| 851 | /* */ |
| 852 | /* count :: The number of spans to draw on this scanline. */ |
| 853 | /* */ |
| 854 | /* spans :: A table of `count' spans to draw on the scanline. */ |
| 855 | /* */ |
| 856 | /* user :: User-supplied data that is passed to the callback. */ |
| 857 | /* */ |
| 858 | /* <Note> */ |
| 859 | /* This callback allows client applications to directly render the */ |
| 860 | /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ |
| 861 | /* */ |
| 862 | /* This can be used to write anti-aliased outlines directly to a */ |
| 863 | /* given background bitmap, and even perform translucency. */ |
| 864 | /* */ |
| 865 | /* Note that the `count' field cannot be greater than a fixed value */ |
| 866 | /* defined by the QT_FT_MAX_GRAY_SPANS configuration macro in */ |
| 867 | /* ftoption.h. By default, this value is set to 32, which means that */ |
| 868 | /* if there are more than 32 spans on a given scanline, the callback */ |
| 869 | /* will be called several times with the same `y' parameter in order */ |
| 870 | /* to draw all callbacks. */ |
| 871 | /* */ |
| 872 | /* Otherwise, the callback is only called once per scan-line, and */ |
| 873 | /* only for those scanlines that do have `gray' pixels on them. */ |
| 874 | /* */ |
| 875 | typedef void |
| 876 | (*QT_FT_SpanFunc)(int count, |
| 877 | const QT_FT_Span* spans, |
| 878 | void* worker); |
| 879 | |
| 880 | #define QT_FT_Raster_Span_Func QT_FT_SpanFunc |
| 881 | |
| 882 | |
| 883 | /*************************************************************************/ |
| 884 | /* */ |
| 885 | /* <FuncType> */ |
| 886 | /* QT_FT_Raster_BitTest_Func */ |
| 887 | /* */ |
| 888 | /* <Description> */ |
| 889 | /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ |
| 890 | /* */ |
| 891 | /* A function used as a call-back by the monochrome scan-converter */ |
| 892 | /* to test whether a given target pixel is already set to the drawing */ |
| 893 | /* `color'. These tests are crucial to implement drop-out control */ |
| 894 | /* per-se the TrueType spec. */ |
| 895 | /* */ |
| 896 | /* <Input> */ |
| 897 | /* y :: The pixel's y-coordinate. */ |
| 898 | /* */ |
| 899 | /* x :: The pixel's x-coordinate. */ |
| 900 | /* */ |
| 901 | /* user :: User-supplied data that is passed to the callback. */ |
| 902 | /* */ |
| 903 | /* <Return> */ |
| 904 | /* 1 if the pixel is `set', 0 otherwise. */ |
| 905 | /* */ |
| 906 | typedef int |
| 907 | (*QT_FT_Raster_BitTest_Func)( int y, |
| 908 | int x, |
| 909 | void* user ); |
| 910 | |
| 911 | |
| 912 | /*************************************************************************/ |
| 913 | /* */ |
| 914 | /* <FuncType> */ |
| 915 | /* QT_FT_Raster_BitSet_Func */ |
| 916 | /* */ |
| 917 | /* <Description> */ |
| 918 | /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ |
| 919 | /* */ |
| 920 | /* A function used as a call-back by the monochrome scan-converter */ |
| 921 | /* to set an individual target pixel. This is crucial to implement */ |
| 922 | /* drop-out control according to the TrueType specification. */ |
| 923 | /* */ |
| 924 | /* <Input> */ |
| 925 | /* y :: The pixel's y-coordinate. */ |
| 926 | /* */ |
| 927 | /* x :: The pixel's x-coordinate. */ |
| 928 | /* */ |
| 929 | /* user :: User-supplied data that is passed to the callback. */ |
| 930 | /* */ |
| 931 | /* <Return> */ |
| 932 | /* 1 if the pixel is `set', 0 otherwise. */ |
| 933 | /* */ |
| 934 | typedef void |
| 935 | (*QT_FT_Raster_BitSet_Func)( int y, |
| 936 | int x, |
| 937 | void* user ); |
| 938 | |
| 939 | |
| 940 | /*************************************************************************/ |
| 941 | /* */ |
| 942 | /* <Enum> */ |
| 943 | /* QT_FT_RASTER_FLAG_XXX */ |
| 944 | /* */ |
| 945 | /* <Description> */ |
| 946 | /* A list of bit flag constants as used in the `flags' field of a */ |
| 947 | /* @QT_FT_Raster_Params structure. */ |
| 948 | /* */ |
| 949 | /* <Values> */ |
| 950 | /* QT_FT_RASTER_FLAG_DEFAULT :: This value is 0. */ |
| 951 | /* */ |
| 952 | /* QT_FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ |
| 953 | /* anti-aliased glyph image should be */ |
| 954 | /* generated. Otherwise, it will be */ |
| 955 | /* monochrome (1-bit). */ |
| 956 | /* */ |
| 957 | /* QT_FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ |
| 958 | /* rendering. In this mode, client */ |
| 959 | /* applications must provide their own span */ |
| 960 | /* callback. This lets them directly */ |
| 961 | /* draw or compose over an existing bitmap. */ |
| 962 | /* If this bit is not set, the target */ |
| 963 | /* pixmap's buffer _must_ be zeroed before */ |
| 964 | /* rendering. */ |
| 965 | /* */ |
| 966 | /* Note that for now, direct rendering is */ |
| 967 | /* only possible with anti-aliased glyphs. */ |
| 968 | /* */ |
| 969 | /* QT_FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ |
| 970 | /* rendering mode. If set, the output will */ |
| 971 | /* be clipped to a box specified in the */ |
| 972 | /* "clip_box" field of the QT_FT_Raster_Params */ |
| 973 | /* structure. */ |
| 974 | /* */ |
| 975 | /* Note that by default, the glyph bitmap */ |
| 976 | /* is clipped to the target pixmap, except */ |
| 977 | /* in direct rendering mode where all spans */ |
| 978 | /* are generated if no clipping box is set. */ |
| 979 | /* */ |
| 980 | #define QT_FT_RASTER_FLAG_DEFAULT 0x0 |
| 981 | #define QT_FT_RASTER_FLAG_AA 0x1 |
| 982 | #define QT_FT_RASTER_FLAG_DIRECT 0x2 |
| 983 | #define QT_FT_RASTER_FLAG_CLIP 0x4 |
| 984 | |
| 985 | /* deprecated */ |
| 986 | #define qt_ft_raster_flag_default QT_FT_RASTER_FLAG_DEFAULT |
| 987 | #define qt_ft_raster_flag_aa QT_FT_RASTER_FLAG_AA |
| 988 | #define qt_ft_raster_flag_direct QT_FT_RASTER_FLAG_DIRECT |
| 989 | #define qt_ft_raster_flag_clip QT_FT_RASTER_FLAG_CLIP |
| 990 | |
| 991 | |
| 992 | /*************************************************************************/ |
| 993 | /* */ |
| 994 | /* <Struct> */ |
| 995 | /* QT_FT_Raster_Params */ |
| 996 | /* */ |
| 997 | /* <Description> */ |
| 998 | /* A structure to hold the arguments used by a raster's render */ |
| 999 | /* function. */ |
| 1000 | /* */ |
| 1001 | /* <Fields> */ |
| 1002 | /* target :: The target bitmap. */ |
| 1003 | /* */ |
| 1004 | /* source :: A pointer to the source glyph image (e.g. an */ |
| 1005 | /* QT_FT_Outline). */ |
| 1006 | /* */ |
| 1007 | /* flags :: The rendering flags. */ |
| 1008 | /* */ |
| 1009 | /* gray_spans :: The gray span drawing callback. */ |
| 1010 | /* */ |
| 1011 | /* black_spans :: The black span drawing callback. */ |
| 1012 | /* */ |
| 1013 | /* bit_test :: The bit test callback. UNIMPLEMENTED! */ |
| 1014 | /* */ |
| 1015 | /* bit_set :: The bit set callback. UNIMPLEMENTED! */ |
| 1016 | /* */ |
| 1017 | /* user :: User-supplied data that is passed to each drawing */ |
| 1018 | /* callback. */ |
| 1019 | /* */ |
| 1020 | /* clip_box :: An optional clipping box. It is only used in */ |
| 1021 | /* direct rendering mode. Note that coordinates here */ |
| 1022 | /* should be expressed in _integer_ pixels (and not in */ |
| 1023 | /* 26.6 fixed-point units). */ |
| 1024 | /* */ |
| 1025 | /* <Note> */ |
| 1026 | /* An anti-aliased glyph bitmap is drawn if the QT_FT_RASTER_FLAG_AA bit */ |
| 1027 | /* flag is set in the `flags' field, otherwise a monochrome bitmap */ |
| 1028 | /* will be generated. */ |
| 1029 | /* */ |
| 1030 | /* If the QT_FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ |
| 1031 | /* raster will call the `gray_spans' callback to draw gray pixel */ |
| 1032 | /* spans, in the case of an aa glyph bitmap, it will call */ |
| 1033 | /* `black_spans', and `bit_test' and `bit_set' in the case of a */ |
| 1034 | /* monochrome bitmap. This allows direct composition over a */ |
| 1035 | /* pre-existing bitmap through user-provided callbacks to perform the */ |
| 1036 | /* span drawing/composition. */ |
| 1037 | /* */ |
| 1038 | /* Note that the `bit_test' and `bit_set' callbacks are required when */ |
| 1039 | /* rendering a monochrome bitmap, as they are crucial to implement */ |
| 1040 | /* correct drop-out control as defined in the TrueType specification. */ |
| 1041 | /* */ |
| 1042 | typedef struct QT_FT_Raster_Params_ |
| 1043 | { |
| 1044 | QT_FT_Bitmap* target; |
| 1045 | void* source; |
| 1046 | int flags; |
| 1047 | QT_FT_SpanFunc gray_spans; |
| 1048 | QT_FT_SpanFunc black_spans; |
| 1049 | QT_FT_Raster_BitTest_Func bit_test; /* doesn't work! */ |
| 1050 | QT_FT_Raster_BitSet_Func bit_set; /* doesn't work! */ |
| 1051 | void* user; |
| 1052 | QT_FT_BBox clip_box; |
| 1053 | int skip_spans; |
| 1054 | |
| 1055 | } QT_FT_Raster_Params; |
| 1056 | |
| 1057 | |
| 1058 | /*************************************************************************/ |
| 1059 | /* */ |
| 1060 | /* <FuncType> */ |
| 1061 | /* QT_FT_Raster_NewFunc */ |
| 1062 | /* */ |
| 1063 | /* <Description> */ |
| 1064 | /* A function used to create a new raster object. */ |
| 1065 | /* */ |
| 1066 | /* <Input> */ |
| 1067 | /* memory :: A handle to the memory allocator. */ |
| 1068 | /* */ |
| 1069 | /* <Output> */ |
| 1070 | /* raster :: A handle to the new raster object. */ |
| 1071 | /* */ |
| 1072 | /* <Return> */ |
| 1073 | /* Error code. 0 means success. */ |
| 1074 | /* */ |
| 1075 | /* <Note> */ |
| 1076 | /* The `memory' parameter is a typeless pointer in order to avoid */ |
| 1077 | /* un-wanted dependencies on the rest of the FreeType code. In */ |
| 1078 | /* practice, it is a QT_FT_Memory, i.e., a handle to the standard */ |
| 1079 | /* FreeType memory allocator. However, this field can be completely */ |
| 1080 | /* ignored by a given raster implementation. */ |
| 1081 | /* */ |
| 1082 | typedef int |
| 1083 | (*QT_FT_Raster_NewFunc)( QT_FT_Raster* raster ); |
| 1084 | |
| 1085 | #define QT_FT_Raster_New_Func QT_FT_Raster_NewFunc |
| 1086 | |
| 1087 | /*************************************************************************/ |
| 1088 | /* */ |
| 1089 | /* <FuncType> */ |
| 1090 | /* QT_FT_Raster_DoneFunc */ |
| 1091 | /* */ |
| 1092 | /* <Description> */ |
| 1093 | /* A function used to destroy a given raster object. */ |
| 1094 | /* */ |
| 1095 | /* <Input> */ |
| 1096 | /* raster :: A handle to the raster object. */ |
| 1097 | /* */ |
| 1098 | typedef void |
| 1099 | (*QT_FT_Raster_DoneFunc)( QT_FT_Raster raster ); |
| 1100 | |
| 1101 | #define QT_FT_Raster_Done_Func QT_FT_Raster_DoneFunc |
| 1102 | |
| 1103 | /*************************************************************************/ |
| 1104 | /* */ |
| 1105 | /* <FuncType> */ |
| 1106 | /* QT_FT_Raster_ResetFunc */ |
| 1107 | /* */ |
| 1108 | /* <Description> */ |
| 1109 | /* FreeType provides an area of memory called the `render pool', */ |
| 1110 | /* available to all registered rasters. This pool can be freely used */ |
| 1111 | /* during a given scan-conversion but is shared by all rasters. Its */ |
| 1112 | /* content is thus transient. */ |
| 1113 | /* */ |
| 1114 | /* This function is called each time the render pool changes, or just */ |
| 1115 | /* after a new raster object is created. */ |
| 1116 | /* */ |
| 1117 | /* <Input> */ |
| 1118 | /* raster :: A handle to the new raster object. */ |
| 1119 | /* */ |
| 1120 | /* pool_base :: The address in memory of the render pool. */ |
| 1121 | /* */ |
| 1122 | /* pool_size :: The size in bytes of the render pool. */ |
| 1123 | /* */ |
| 1124 | /* <Note> */ |
| 1125 | /* Rasters can ignore the render pool and rely on dynamic memory */ |
| 1126 | /* allocation if they want to (a handle to the memory allocator is */ |
| 1127 | /* passed to the raster constructor). However, this is not */ |
| 1128 | /* recommended for efficiency purposes. */ |
| 1129 | /* */ |
| 1130 | typedef void |
| 1131 | (*QT_FT_Raster_ResetFunc)( QT_FT_Raster raster, |
| 1132 | unsigned char* pool_base, |
| 1133 | unsigned long pool_size ); |
| 1134 | |
| 1135 | #define QT_FT_Raster_Reset_Func QT_FT_Raster_ResetFunc |
| 1136 | |
| 1137 | /*************************************************************************/ |
| 1138 | /* */ |
| 1139 | /* <FuncType> */ |
| 1140 | /* QT_FT_Raster_SetModeFunc */ |
| 1141 | /* */ |
| 1142 | /* <Description> */ |
| 1143 | /* This function is a generic facility to change modes or attributes */ |
| 1144 | /* in a given raster. This can be used for debugging purposes, or */ |
| 1145 | /* simply to allow implementation-specific `features' in a given */ |
| 1146 | /* raster module. */ |
| 1147 | /* */ |
| 1148 | /* <Input> */ |
| 1149 | /* raster :: A handle to the new raster object. */ |
| 1150 | /* */ |
| 1151 | /* mode :: A 4-byte tag used to name the mode or property. */ |
| 1152 | /* */ |
| 1153 | /* args :: A pointer to the new mode/property to use. */ |
| 1154 | /* */ |
| 1155 | typedef int |
| 1156 | (*QT_FT_Raster_SetModeFunc)( QT_FT_Raster raster, |
| 1157 | unsigned long mode, |
| 1158 | void* args ); |
| 1159 | |
| 1160 | #define QT_FT_Raster_Set_Mode_Func QT_FT_Raster_SetModeFunc |
| 1161 | |
| 1162 | /*************************************************************************/ |
| 1163 | /* */ |
| 1164 | /* <FuncType> */ |
| 1165 | /* QT_FT_Raster_RenderFunc */ |
| 1166 | /* */ |
| 1167 | /* <Description> */ |
| 1168 | /* Invokes a given raster to scan-convert a given glyph image into a */ |
| 1169 | /* target bitmap. */ |
| 1170 | /* */ |
| 1171 | /* <Input> */ |
| 1172 | /* raster :: A handle to the raster object. */ |
| 1173 | /* */ |
| 1174 | /* params :: A pointer to a QT_FT_Raster_Params structure used to store */ |
| 1175 | /* the rendering parameters. */ |
| 1176 | /* */ |
| 1177 | /* <Return> */ |
| 1178 | /* Error code. 0 means success. */ |
| 1179 | /* */ |
| 1180 | /* <Note> */ |
| 1181 | /* The exact format of the source image depends on the raster's glyph */ |
| 1182 | /* format defined in its QT_FT_Raster_Funcs structure. It can be an */ |
| 1183 | /* QT_FT_Outline or anything else in order to support a large array of */ |
| 1184 | /* glyph formats. */ |
| 1185 | /* */ |
| 1186 | /* Note also that the render function can fail and return a */ |
| 1187 | /* QT_FT_Err_Unimplemented_Feature error code if the raster used does */ |
| 1188 | /* not support direct composition. */ |
| 1189 | /* */ |
| 1190 | /* XXX: For now, the standard raster doesn't support direct */ |
| 1191 | /* composition but this should change for the final release (see */ |
| 1192 | /* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */ |
| 1193 | /* examples of distinct implementations which support direct */ |
| 1194 | /* composition). */ |
| 1195 | /* */ |
| 1196 | typedef int |
| 1197 | (*QT_FT_Raster_RenderFunc)( QT_FT_Raster raster, |
| 1198 | QT_FT_Raster_Params* params ); |
| 1199 | |
| 1200 | #define QT_FT_Raster_Render_Func QT_FT_Raster_RenderFunc |
| 1201 | |
| 1202 | /*************************************************************************/ |
| 1203 | /* */ |
| 1204 | /* <Struct> */ |
| 1205 | /* QT_FT_Raster_Funcs */ |
| 1206 | /* */ |
| 1207 | /* <Description> */ |
| 1208 | /* A structure used to describe a given raster class to the library. */ |
| 1209 | /* */ |
| 1210 | /* <Fields> */ |
| 1211 | /* glyph_format :: The supported glyph format for this raster. */ |
| 1212 | /* */ |
| 1213 | /* raster_new :: The raster constructor. */ |
| 1214 | /* */ |
| 1215 | /* raster_reset :: Used to reset the render pool within the raster. */ |
| 1216 | /* */ |
| 1217 | /* raster_render :: A function to render a glyph into a given bitmap. */ |
| 1218 | /* */ |
| 1219 | /* raster_done :: The raster destructor. */ |
| 1220 | /* */ |
| 1221 | typedef struct QT_FT_Raster_Funcs_ |
| 1222 | { |
| 1223 | QT_FT_Glyph_Format glyph_format; |
| 1224 | QT_FT_Raster_NewFunc raster_new; |
| 1225 | QT_FT_Raster_ResetFunc raster_reset; |
| 1226 | QT_FT_Raster_SetModeFunc raster_set_mode; |
| 1227 | QT_FT_Raster_RenderFunc raster_render; |
| 1228 | QT_FT_Raster_DoneFunc raster_done; |
| 1229 | |
| 1230 | } QT_FT_Raster_Funcs; |
| 1231 | |
| 1232 | |
| 1233 | /* */ |
| 1234 | |
| 1235 | |
| 1236 | QT_FT_END_HEADER |
| 1237 | |
| 1238 | #endif /* __FTIMAGE_H__ */ |
| 1239 | |
| 1240 | |
| 1241 | /* END */ |
| 1242 | |