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