tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

hb-paint.h (40140B)


      1 /*
      2 * Copyright © 2022 Matthias Clasen
      3 *
      4 *  This is part of HarfBuzz, a text shaping library.
      5 *
      6 * Permission is hereby granted, without written agreement and without
      7 * license or royalty fees, to use, copy, modify, and distribute this
      8 * software and its documentation for any purpose, provided that the
      9 * above copyright notice and the following two paragraphs appear in
     10 * all copies of this software.
     11 *
     12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
     13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
     14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
     15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
     16 * DAMAGE.
     17 *
     18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
     19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     20 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
     21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
     22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
     23 */
     24 
     25 #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
     26 #error "Include <hb.h> instead."
     27 #endif
     28 
     29 #ifndef HB_PAINT_H
     30 #define HB_PAINT_H
     31 
     32 #include "hb-common.h"
     33 
     34 HB_BEGIN_DECLS
     35 
     36 
     37 /**
     38 * hb_paint_funcs_t:
     39 *
     40 * Glyph paint callbacks.
     41 *
     42 * The callbacks assume that the caller maintains a stack
     43 * of current transforms, clips and intermediate surfaces,
     44 * as evidenced by the pairs of push/pop callbacks. The
     45 * push/pop calls will be properly nested, so it is fine
     46 * to store the different kinds of object on a single stack.
     47 *
     48 * Not all callbacks are required for all kinds of glyphs.
     49 * For rendering COLRv0 or non-color outline glyphs, the
     50 * gradient callbacks are not needed, and the composite
     51 * callback only needs to handle simple alpha compositing
     52 * (#HB_PAINT_COMPOSITE_MODE_SRC_OVER).
     53 *
     54 * The paint-image callback is only needed for glyphs
     55 * with image blobs in the CBDT, sbix or SVG tables.
     56 *
     57 * The custom-palette-color callback is only necessary if
     58 * you want to override colors from the font palette with
     59 * custom colors.
     60 *
     61 * Since: 7.0.0
     62 **/
     63 typedef struct hb_paint_funcs_t hb_paint_funcs_t;
     64 
     65 HB_EXTERN hb_paint_funcs_t *
     66 hb_paint_funcs_create (void);
     67 
     68 HB_EXTERN hb_paint_funcs_t *
     69 hb_paint_funcs_get_empty (void);
     70 
     71 HB_EXTERN hb_paint_funcs_t *
     72 hb_paint_funcs_reference (hb_paint_funcs_t *funcs);
     73 
     74 HB_EXTERN void
     75 hb_paint_funcs_destroy (hb_paint_funcs_t *funcs);
     76 
     77 HB_EXTERN hb_bool_t
     78 hb_paint_funcs_set_user_data (hb_paint_funcs_t *funcs,
     79 		      hb_user_data_key_t *key,
     80 		      void *              data,
     81 		      hb_destroy_func_t   destroy,
     82 		      hb_bool_t           replace);
     83 
     84 
     85 HB_EXTERN void *
     86 hb_paint_funcs_get_user_data (const hb_paint_funcs_t *funcs,
     87 		      hb_user_data_key_t       *key);
     88 
     89 HB_EXTERN void
     90 hb_paint_funcs_make_immutable (hb_paint_funcs_t *funcs);
     91 
     92 HB_EXTERN hb_bool_t
     93 hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs);
     94 
     95 /**
     96 * hb_paint_push_transform_func_t:
     97 * @funcs: paint functions object
     98 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
     99 * @xx: xx component of the transform matrix
    100 * @yx: yx component of the transform matrix
    101 * @xy: xy component of the transform matrix
    102 * @yy: yy component of the transform matrix
    103 * @dx: dx component of the transform matrix
    104 * @dy: dy component of the transform matrix
    105 * @user_data: User data pointer passed to hb_paint_funcs_set_push_transform_func()
    106 *
    107 * A virtual method for the #hb_paint_funcs_t to apply
    108 * a transform to subsequent paint calls.
    109 *
    110 * This transform is applied after the current transform,
    111 * and remains in effect until a matching call to
    112 * the #hb_paint_funcs_pop_transform_func_t vfunc.
    113 *
    114 * Since: 7.0.0
    115 */
    116 typedef void (*hb_paint_push_transform_func_t) (hb_paint_funcs_t *funcs,
    117                                                void *paint_data,
    118                                                float xx, float yx,
    119                                                float xy, float yy,
    120                                                float dx, float dy,
    121                                                void *user_data);
    122 
    123 /**
    124 * hb_paint_pop_transform_func_t:
    125 * @funcs: paint functions object
    126 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    127 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_transform_func()
    128 *
    129 * A virtual method for the #hb_paint_funcs_t to undo
    130 * the effect of a prior call to the #hb_paint_funcs_push_transform_func_t
    131 * vfunc.
    132 *
    133 * Since: 7.0.0
    134 */
    135 typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,
    136                                               void *paint_data,
    137                                               void *user_data);
    138 
    139 /**
    140 * hb_paint_color_glyph_func_t:
    141 * @funcs: paint functions object
    142 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    143 * @glyph: the glyph ID
    144 * @font: the font
    145 * @user_data: User data pointer passed to hb_paint_funcs_set_color_glyph_func()
    146 *
    147 * A virtual method for the #hb_paint_funcs_t to render a color glyph by glyph index.
    148 *
    149 * Return value: `true` if the glyph was painted, `false` otherwise.
    150 *
    151 * Since: 8.2.0
    152 */
    153 typedef hb_bool_t (*hb_paint_color_glyph_func_t) (hb_paint_funcs_t *funcs,
    154                                                  void *paint_data,
    155                                                  hb_codepoint_t glyph,
    156                                                  hb_font_t *font,
    157                                                  void *user_data);
    158 
    159 /**
    160 * hb_paint_push_clip_glyph_func_t:
    161 * @funcs: paint functions object
    162 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    163 * @glyph: the glyph ID
    164 * @font: the font
    165 * @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_glyph_func()
    166 *
    167 * A virtual method for the #hb_paint_funcs_t to clip
    168 * subsequent paint calls to the outline of a glyph.
    169 *
    170 * The coordinates of the glyph outline are expected in the
    171 * current @font scale (ie. the results of calling
    172 * hb_font_draw_glyph() with @font). The outline is
    173 * transformed by the current transform.
    174 *
    175 * This clip is applied in addition to the current clip,
    176 * and remains in effect until a matching call to
    177 * the #hb_paint_funcs_pop_clip_func_t vfunc.
    178 *
    179 * Since: 7.0.0
    180 */
    181 typedef void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs,
    182                                                 void *paint_data,
    183                                                 hb_codepoint_t glyph,
    184                                                 hb_font_t *font,
    185                                                 void *user_data);
    186 
    187 /**
    188 * hb_paint_push_clip_rectangle_func_t:
    189 * @funcs: paint functions object
    190 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    191 * @xmin: min X for the rectangle
    192 * @ymin: min Y for the rectangle
    193 * @xmax: max X for the rectangle
    194 * @ymax: max Y for the rectangle
    195 * @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_rectangle_func()
    196 *
    197 * A virtual method for the #hb_paint_funcs_t to clip
    198 * subsequent paint calls to a rectangle.
    199 *
    200 * The coordinates of the rectangle are interpreted according
    201 * to the current transform.
    202 *
    203 * This clip is applied in addition to the current clip,
    204 * and remains in effect until a matching call to
    205 * the #hb_paint_funcs_pop_clip_func_t vfunc.
    206 *
    207 * Since: 7.0.0
    208 */
    209 typedef void (*hb_paint_push_clip_rectangle_func_t) (hb_paint_funcs_t *funcs,
    210                                                     void *paint_data,
    211                                                     float xmin, float ymin,
    212                                                     float xmax, float ymax,
    213                                                     void *user_data);
    214 
    215 /**
    216 * hb_paint_pop_clip_func_t:
    217 * @funcs: paint functions object
    218 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    219 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_clip_func()
    220 *
    221 * A virtual method for the #hb_paint_funcs_t to undo
    222 * the effect of a prior call to the #hb_paint_funcs_push_clip_glyph_func_t
    223 * or #hb_paint_funcs_push_clip_rectangle_func_t vfuncs.
    224 *
    225 * Since: 7.0.0
    226 */
    227 typedef void (*hb_paint_pop_clip_func_t) (hb_paint_funcs_t *funcs,
    228                                          void *paint_data,
    229                                          void *user_data);
    230 
    231 /**
    232 * hb_paint_color_func_t:
    233 * @funcs: paint functions object
    234 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    235 * @is_foreground: whether the color is the foreground
    236 * @color: The color to use, unpremultiplied
    237 * @user_data: User data pointer passed to hb_paint_funcs_set_color_func()
    238 *
    239 * A virtual method for the #hb_paint_funcs_t to paint a
    240 * color everywhere within the current clip.
    241 *
    242 * Since: 7.0.0
    243 */
    244 typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
    245                                       void *paint_data,
    246                                       hb_bool_t is_foreground,
    247                                       hb_color_t color,
    248                                       void *user_data);
    249 
    250 /**
    251 * HB_PAINT_IMAGE_FORMAT_PNG:
    252 *
    253 * Tag identifying PNG images in #hb_paint_image_func_t callbacks.
    254 *
    255 * Since: 7.0.0
    256 */
    257 #define HB_PAINT_IMAGE_FORMAT_PNG HB_TAG('p','n','g',' ')
    258 
    259 /**
    260 * HB_PAINT_IMAGE_FORMAT_SVG:
    261 *
    262 * Tag identifying SVG images in #hb_paint_image_func_t callbacks.
    263 *
    264 * Since: 7.0.0
    265 */
    266 #define HB_PAINT_IMAGE_FORMAT_SVG HB_TAG('s','v','g',' ')
    267 
    268 /**
    269 * HB_PAINT_IMAGE_FORMAT_BGRA:
    270 *
    271 * Tag identifying raw pixel-data images in #hb_paint_image_func_t callbacks.
    272 * The data is in BGRA pre-multiplied sRGBA color-space format.
    273 *
    274 * Since: 7.0.0
    275 */
    276 #define HB_PAINT_IMAGE_FORMAT_BGRA HB_TAG('B','G','R','A')
    277 
    278 /**
    279 * hb_paint_image_func_t:
    280 * @funcs: paint functions object
    281 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    282 * @image: the image data
    283 * @width: width of the raster image in pixels, or 0
    284 * @height: height of the raster image in pixels, or 0
    285 * @format: the image format as a tag
    286 * @slant: Deprecated. Always set to 0.0.
    287 * @extents: (nullable): glyph extents for desired rendering
    288 * @user_data: User data pointer passed to hb_paint_funcs_set_image_func()
    289 *
    290 * A virtual method for the #hb_paint_funcs_t to paint a glyph image.
    291 *
    292 * This method is called for glyphs with image blobs in the CBDT,
    293 * sbix or SVG tables. The @format identifies the kind of data that
    294 * is contained in @image. Possible values include #HB_PAINT_IMAGE_FORMAT_PNG,
    295 * #HB_PAINT_IMAGE_FORMAT_SVG and #HB_PAINT_IMAGE_FORMAT_BGRA.
    296 *
    297 * The image dimensions and glyph extents are provided if available,
    298 * and should be used to size and position the image.
    299 *
    300 * Return value: Whether the operation was successful.
    301 *
    302 * Since: 7.0.0
    303 */
    304 typedef hb_bool_t (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,
    305 				    void *paint_data,
    306 				    hb_blob_t *image,
    307 				    unsigned int width,
    308 				    unsigned int height,
    309 				    hb_tag_t format,
    310 				    float slant,
    311 				    hb_glyph_extents_t *extents,
    312 				    void *user_data);
    313 
    314 /**
    315 * hb_color_stop_t:
    316 * @offset: the offset of the color stop
    317 * @is_foreground: whether the color is the foreground
    318 * @color: the color, unpremultiplied
    319 *
    320 * Information about a color stop on a color line.
    321 *
    322 * Color lines typically have offsets ranging between 0 and 1,
    323 * but that is not required.
    324 *
    325 * Note: despite @color being unpremultiplied here, interpolation in
    326 * gradients shall happen in premultiplied space. See the OpenType spec
    327 * [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
    328 * section for details.
    329 *
    330 * Since: 7.0.0
    331 */
    332 typedef struct {
    333  float offset;
    334  hb_bool_t is_foreground;
    335  hb_color_t color;
    336 } hb_color_stop_t;
    337 
    338 /**
    339 * hb_paint_extend_t:
    340 * @HB_PAINT_EXTEND_PAD: Outside the defined interval,
    341 *   the color of the closest color stop is used.
    342 * @HB_PAINT_EXTEND_REPEAT: The color line is repeated over
    343 *   repeated multiples of the defined interval
    344 * @HB_PAINT_EXTEND_REFLECT: The color line is repeated over
    345 *      repeated intervals, as for the repeat mode.
    346 *      However, in each repeated interval, the ordering of
    347 *      color stops is the reverse of the adjacent interval.
    348 *
    349 * The values of this enumeration determine how color values
    350 * outside the minimum and maximum defined offset on a #hb_color_line_t
    351 * are determined.
    352 *
    353 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
    354 * section for details.
    355 *
    356 * Since: 7.0.0
    357 */
    358 typedef enum {
    359  HB_PAINT_EXTEND_PAD,
    360  HB_PAINT_EXTEND_REPEAT,
    361  HB_PAINT_EXTEND_REFLECT
    362 } hb_paint_extend_t;
    363 
    364 typedef struct hb_color_line_t hb_color_line_t;
    365 
    366 /**
    367 * hb_color_line_get_color_stops_func_t:
    368 * @color_line: a #hb_color_line_t object
    369 * @color_line_data: the data accompanying @color_line
    370 * @start: the index of the first color stop to return
    371 * @count: (inout) (optional): Input = the maximum number of feature tags to return;
    372 *     Output = the actual number of feature tags returned (may be zero)
    373 * @color_stops: (out) (array length=count) (optional): Array of #hb_color_stop_t to populate
    374 * @user_data: the data accompanying this method
    375 *
    376 * A virtual method for the #hb_color_line_t to fetch color stops.
    377 *
    378 * Return value: the total number of color stops in @color_line
    379 *
    380 * Since: 7.0.0
    381 */
    382 typedef unsigned int (*hb_color_line_get_color_stops_func_t) (hb_color_line_t *color_line,
    383 						      void *color_line_data,
    384 						      unsigned int start,
    385 						      unsigned int *count,
    386 						      hb_color_stop_t *color_stops,
    387 						      void *user_data);
    388 
    389 /**
    390 * hb_color_line_get_extend_func_t:
    391 * @color_line: a #hb_color_line_t object
    392 * @color_line_data: the data accompanying @color_line
    393 * @user_data: the data accompanying this method
    394 *
    395 * A virtual method for the @hb_color_line_t to fetches the extend mode.
    396 *
    397 * Return value: the extend mode of @color_line
    398 *
    399 * Since: 7.0.0
    400 */
    401 typedef hb_paint_extend_t (*hb_color_line_get_extend_func_t) (hb_color_line_t *color_line,
    402 						      void *color_line_data,
    403 						      void *user_data);
    404 
    405 /**
    406 * hb_color_line_t:
    407 *
    408 * A struct containing color information for a gradient.
    409 *
    410 * Since: 7.0.0
    411 */
    412 struct hb_color_line_t {
    413  void *data;
    414 
    415  hb_color_line_get_color_stops_func_t get_color_stops;
    416  void *get_color_stops_user_data;
    417 
    418  hb_color_line_get_extend_func_t get_extend;
    419  void *get_extend_user_data;
    420 
    421  void *reserved0;
    422  void *reserved1;
    423  void *reserved2;
    424  void *reserved3;
    425  void *reserved5;
    426  void *reserved6;
    427  void *reserved7;
    428  void *reserved8;
    429 };
    430 
    431 HB_EXTERN unsigned int
    432 hb_color_line_get_color_stops (hb_color_line_t *color_line,
    433                               unsigned int start,
    434                               unsigned int *count,
    435                               hb_color_stop_t *color_stops);
    436 
    437 HB_EXTERN hb_paint_extend_t
    438 hb_color_line_get_extend (hb_color_line_t *color_line);
    439 
    440 /**
    441 * hb_paint_linear_gradient_func_t:
    442 * @funcs: paint functions object
    443 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    444 * @color_line: Color information for the gradient
    445 * @x0: X coordinate of the first point
    446 * @y0: Y coordinate of the first point
    447 * @x1: X coordinate of the second point
    448 * @y1: Y coordinate of the second point
    449 * @x2: X coordinate of the third point
    450 * @y2: Y coordinate of the third point
    451 * @user_data: User data pointer passed to hb_paint_funcs_set_linear_gradient_func()
    452 *
    453 * A virtual method for the #hb_paint_funcs_t to paint a linear
    454 * gradient everywhere within the current clip.
    455 *
    456 * The @color_line object contains information about the colors of the gradients.
    457 * It is only valid for the duration of the callback, you cannot keep it around.
    458 *
    459 * The coordinates of the points are interpreted according
    460 * to the current transform.
    461 *
    462 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
    463 * section for details on how the points define the direction
    464 * of the gradient, and how to interpret the @color_line.
    465 *
    466 * Since: 7.0.0
    467 */
    468 typedef void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,
    469                                                 void *paint_data,
    470                                                 hb_color_line_t *color_line,
    471                                                 float x0, float y0,
    472                                                 float x1, float y1,
    473                                                 float x2, float y2,
    474                                                 void *user_data);
    475 
    476 /**
    477 * hb_paint_radial_gradient_func_t:
    478 * @funcs: paint functions object
    479 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    480 * @color_line: Color information for the gradient
    481 * @x0: X coordinate of the first circle's center
    482 * @y0: Y coordinate of the first circle's center
    483 * @r0: radius of the first circle
    484 * @x1: X coordinate of the second circle's center
    485 * @y1: Y coordinate of the second circle's center
    486 * @r1: radius of the second circle
    487 * @user_data: User data pointer passed to hb_paint_funcs_set_radial_gradient_func()
    488 *
    489 * A virtual method for the #hb_paint_funcs_t to paint a radial
    490 * gradient everywhere within the current clip.
    491 *
    492 * The @color_line object contains information about the colors of the gradients.
    493 * It is only valid for the duration of the callback, you cannot keep it around.
    494 *
    495 * The coordinates of the points are interpreted according
    496 * to the current transform.
    497 *
    498 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
    499 * section for details on how the points define the direction
    500 * of the gradient, and how to interpret the @color_line.
    501 *
    502 * Since: 7.0.0
    503 */
    504 typedef void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,
    505                                                 void *paint_data,
    506                                                 hb_color_line_t *color_line,
    507                                                 float x0, float y0, float r0,
    508                                                 float x1, float y1, float r1,
    509                                                 void *user_data);
    510 
    511 /**
    512 * hb_paint_sweep_gradient_func_t:
    513 * @funcs: paint functions object
    514 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    515 * @color_line: Color information for the gradient
    516 * @x0: X coordinate of the circle's center
    517 * @y0: Y coordinate of the circle's center
    518 * @start_angle: the start angle, in radians
    519 * @end_angle: the end angle, in radians
    520 * @user_data: User data pointer passed to hb_paint_funcs_set_sweep_gradient_func()
    521 *
    522 * A virtual method for the #hb_paint_funcs_t to paint a sweep
    523 * gradient everywhere within the current clip.
    524 *
    525 * The @color_line object contains information about the colors of the gradients.
    526 * It is only valid for the duration of the callback, you cannot keep it around.
    527 *
    528 * The coordinates of the points are interpreted according
    529 * to the current transform.
    530 *
    531 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
    532 * section for details on how the points define the direction
    533 * of the gradient, and how to interpret the @color_line.
    534 *
    535 * Since: 7.0.0
    536 */
    537 typedef void (*hb_paint_sweep_gradient_func_t)  (hb_paint_funcs_t *funcs,
    538                                                 void *paint_data,
    539                                                 hb_color_line_t *color_line,
    540                                                 float x0, float y0,
    541                                                 float start_angle,
    542                                                 float end_angle,
    543                                                 void *user_data);
    544 
    545 /**
    546 * hb_paint_composite_mode_t:
    547 * @HB_PAINT_COMPOSITE_MODE_CLEAR: clear destination layer (bounded)
    548 * @HB_PAINT_COMPOSITE_MODE_SRC: replace destination layer (bounded)
    549 * @HB_PAINT_COMPOSITE_MODE_SRC_OVER: draw source layer on top of destination layer
    550 * (bounded)
    551 * @HB_PAINT_COMPOSITE_MODE_SRC_IN: draw source where there was destination content
    552 * (unbounded)
    553 * @HB_PAINT_COMPOSITE_MODE_SRC_OUT: draw source where there was no destination
    554 * content (unbounded)
    555 * @HB_PAINT_COMPOSITE_MODE_SRC_ATOP: draw source on top of destination content and
    556 * only there
    557 * @HB_PAINT_COMPOSITE_MODE_DEST: ignore the source
    558 * @HB_PAINT_COMPOSITE_MODE_DEST_OVER: draw destination on top of source
    559 * @HB_PAINT_COMPOSITE_MODE_DEST_IN: leave destination only where there was
    560 * source content (unbounded)
    561 * @HB_PAINT_COMPOSITE_MODE_DEST_OUT: leave destination only where there was no
    562 * source content
    563 * @HB_PAINT_COMPOSITE_MODE_DEST_ATOP: leave destination on top of source content
    564 * and only there (unbounded)
    565 * @HB_PAINT_COMPOSITE_MODE_XOR: source and destination are shown where there is only
    566 * one of them
    567 * @HB_PAINT_COMPOSITE_MODE_PLUS: source and destination layers are accumulated
    568 * @HB_PAINT_COMPOSITE_MODE_MULTIPLY: source and destination layers are multiplied.
    569 * This causes the result to be at least as dark as the darker inputs.
    570 * @HB_PAINT_COMPOSITE_MODE_SCREEN: source and destination are complemented and
    571 * multiplied. This causes the result to be at least as light as the lighter
    572 * inputs.
    573 * @HB_PAINT_COMPOSITE_MODE_OVERLAY: multiplies or screens, depending on the
    574 * lightness of the destination color.
    575 * @HB_PAINT_COMPOSITE_MODE_DARKEN: replaces the destination with the source if it
    576 * is darker, otherwise keeps the source.
    577 * @HB_PAINT_COMPOSITE_MODE_LIGHTEN: replaces the destination with the source if it
    578 * is lighter, otherwise keeps the source.
    579 * @HB_PAINT_COMPOSITE_MODE_COLOR_DODGE: brightens the destination color to reflect
    580 * the source color.
    581 * @HB_PAINT_COMPOSITE_MODE_COLOR_BURN: darkens the destination color to reflect
    582 * the source color.
    583 * @HB_PAINT_COMPOSITE_MODE_HARD_LIGHT: Multiplies or screens, dependent on source
    584 * color.
    585 * @HB_PAINT_COMPOSITE_MODE_SOFT_LIGHT: Darkens or lightens, dependent on source
    586 * color.
    587 * @HB_PAINT_COMPOSITE_MODE_DIFFERENCE: Takes the difference of the source and
    588 * destination color.
    589 * @HB_PAINT_COMPOSITE_MODE_EXCLUSION: Produces an effect similar to difference, but
    590 * with lower contrast.
    591 * @HB_PAINT_COMPOSITE_MODE_HSL_HUE: Creates a color with the hue of the source
    592 * and the saturation and luminosity of the target.
    593 * @HB_PAINT_COMPOSITE_MODE_HSL_SATURATION: Creates a color with the saturation
    594 * of the source and the hue and luminosity of the target. Painting with
    595 * this mode onto a gray area produces no change.
    596 * @HB_PAINT_COMPOSITE_MODE_HSL_COLOR: Creates a color with the hue and saturation
    597 * of the source and the luminosity of the target. This preserves the gray
    598 * levels of the target and is useful for coloring monochrome images or
    599 * tinting color images.
    600 * @HB_PAINT_COMPOSITE_MODE_HSL_LUMINOSITY: Creates a color with the luminosity of
    601 * the source and the hue and saturation of the target. This produces an
    602 * inverse effect to @HB_PAINT_COMPOSITE_MODE_HSL_COLOR.
    603 *
    604 * The values of this enumeration describe the compositing modes
    605 * that can be used when combining temporary redirected drawing
    606 * with the backdrop.
    607 *
    608 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
    609 * section for details.
    610 *
    611 * Since: 7.0.0
    612 */
    613 typedef enum {
    614  HB_PAINT_COMPOSITE_MODE_CLEAR,
    615  HB_PAINT_COMPOSITE_MODE_SRC,
    616  HB_PAINT_COMPOSITE_MODE_DEST,
    617  HB_PAINT_COMPOSITE_MODE_SRC_OVER,
    618  HB_PAINT_COMPOSITE_MODE_DEST_OVER,
    619  HB_PAINT_COMPOSITE_MODE_SRC_IN,
    620  HB_PAINT_COMPOSITE_MODE_DEST_IN,
    621  HB_PAINT_COMPOSITE_MODE_SRC_OUT,
    622  HB_PAINT_COMPOSITE_MODE_DEST_OUT,
    623  HB_PAINT_COMPOSITE_MODE_SRC_ATOP,
    624  HB_PAINT_COMPOSITE_MODE_DEST_ATOP,
    625  HB_PAINT_COMPOSITE_MODE_XOR,
    626  HB_PAINT_COMPOSITE_MODE_PLUS,
    627  HB_PAINT_COMPOSITE_MODE_SCREEN,
    628  HB_PAINT_COMPOSITE_MODE_OVERLAY,
    629  HB_PAINT_COMPOSITE_MODE_DARKEN,
    630  HB_PAINT_COMPOSITE_MODE_LIGHTEN,
    631  HB_PAINT_COMPOSITE_MODE_COLOR_DODGE,
    632  HB_PAINT_COMPOSITE_MODE_COLOR_BURN,
    633  HB_PAINT_COMPOSITE_MODE_HARD_LIGHT,
    634  HB_PAINT_COMPOSITE_MODE_SOFT_LIGHT,
    635  HB_PAINT_COMPOSITE_MODE_DIFFERENCE,
    636  HB_PAINT_COMPOSITE_MODE_EXCLUSION,
    637  HB_PAINT_COMPOSITE_MODE_MULTIPLY,
    638  HB_PAINT_COMPOSITE_MODE_HSL_HUE,
    639  HB_PAINT_COMPOSITE_MODE_HSL_SATURATION,
    640  HB_PAINT_COMPOSITE_MODE_HSL_COLOR,
    641  HB_PAINT_COMPOSITE_MODE_HSL_LUMINOSITY
    642 } hb_paint_composite_mode_t;
    643 
    644 /**
    645 * hb_paint_push_group_func_t:
    646 * @funcs: paint functions object
    647 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    648 * @user_data: User data pointer passed to hb_paint_funcs_set_push_group_func()
    649 *
    650 * A virtual method for the #hb_paint_funcs_t to use
    651 * an intermediate surface for subsequent paint calls.
    652 *
    653 * The drawing will be redirected to an intermediate surface
    654 * until a matching call to the #hb_paint_funcs_pop_group_func_t
    655 * vfunc.
    656 *
    657 * Since: 7.0.0
    658 */
    659 typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
    660                                            void *paint_data,
    661                                            void *user_data);
    662 
    663 /**
    664 * hb_paint_pop_group_func_t:
    665 * @funcs: paint functions object
    666 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    667 * @mode: the compositing mode to use
    668 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_group_func()
    669 *
    670 * A virtual method for the #hb_paint_funcs_t to undo
    671 * the effect of a prior call to the #hb_paint_funcs_push_group_func_t
    672 * vfunc.
    673 *
    674 * This call stops the redirection to the intermediate surface,
    675 * and then composites it on the previous surface, using the
    676 * compositing mode passed to this call.
    677 *
    678 * Since: 7.0.0
    679 */
    680 typedef void (*hb_paint_pop_group_func_t) (hb_paint_funcs_t *funcs,
    681                                           void *paint_data,
    682                                           hb_paint_composite_mode_t mode,
    683                                           void *user_data);
    684 
    685 /**
    686 * hb_paint_custom_palette_color_func_t:
    687 * @funcs: paint functions object
    688 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
    689 * @color_index: the color index
    690 * @color: (out): fetched color
    691 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_group_func()
    692 *
    693 * A virtual method for the #hb_paint_funcs_t to fetch a color from the custom
    694 * color palette.
    695 *
    696 * Custom palette colors override the colors from the fonts selected color
    697 * palette. It is not necessary to override all palette entries; for entries
    698 * that should be taken from the font palette, return `false`.
    699 *
    700 * This function might get called multiple times, but the custom palette is
    701 * expected to remain unchanged for duration of a hb_font_paint_glyph() call.
    702 *
    703 * Return value: `true` if found, `false` otherwise
    704 *
    705 * Since: 7.0.0
    706 */
    707 typedef hb_bool_t (*hb_paint_custom_palette_color_func_t) (hb_paint_funcs_t *funcs,
    708                                                           void *paint_data,
    709                                                           unsigned int color_index,
    710                                                           hb_color_t *color,
    711                                                           void *user_data);
    712 
    713 
    714 /**
    715 * hb_paint_funcs_set_push_transform_func:
    716 * @funcs: A paint functions struct
    717 * @func: (closure user_data) (destroy destroy) (scope notified): The push-transform callback
    718 * @user_data: Data to pass to @func
    719 * @destroy: (nullable): Function to call when @user_data is no longer needed
    720 *
    721 * Sets the push-transform callback on the paint functions struct.
    722 *
    723 * Since: 7.0.0
    724 */
    725 HB_EXTERN void
    726 hb_paint_funcs_set_push_transform_func (hb_paint_funcs_t               *funcs,
    727                                        hb_paint_push_transform_func_t  func,
    728                                        void                           *user_data,
    729                                        hb_destroy_func_t               destroy);
    730 
    731 /**
    732 * hb_paint_funcs_set_pop_transform_func:
    733 * @funcs: A paint functions struct
    734 * @func: (closure user_data) (destroy destroy) (scope notified): The pop-transform callback
    735 * @user_data: Data to pass to @func
    736 * @destroy: (nullable): Function to call when @user_data is no longer needed
    737 *
    738 * Sets the pop-transform callback on the paint functions struct.
    739 *
    740 * Since: 7.0.0
    741 */
    742 HB_EXTERN void
    743 hb_paint_funcs_set_pop_transform_func (hb_paint_funcs_t              *funcs,
    744                                       hb_paint_pop_transform_func_t  func,
    745                                       void                          *user_data,
    746                                       hb_destroy_func_t              destroy);
    747 
    748 /**
    749 * hb_paint_funcs_set_color_glyph_func:
    750 * @funcs: A paint functions struct
    751 * @func: (closure user_data) (destroy destroy) (scope notified): The color-glyph callback
    752 * @user_data: Data to pass to @func
    753 * @destroy: (nullable): Function to call when @user_data is no longer needed
    754 *
    755 * Sets the color-glyph callback on the paint functions struct.
    756 *
    757 * Since: 8.2.0
    758 */
    759 HB_EXTERN void
    760 hb_paint_funcs_set_color_glyph_func (hb_paint_funcs_t                *funcs,
    761 			     hb_paint_color_glyph_func_t     func,
    762 			     void                            *user_data,
    763 			     hb_destroy_func_t                destroy);
    764 
    765 /**
    766 * hb_paint_funcs_set_push_clip_glyph_func:
    767 * @funcs: A paint functions struct
    768 * @func: (closure user_data) (destroy destroy) (scope notified): The push-clip-glyph callback
    769 * @user_data: Data to pass to @func
    770 * @destroy: (nullable): Function to call when @user_data is no longer needed
    771 *
    772 * Sets the push-clip-glyph callback on the paint functions struct.
    773 *
    774 * Since: 7.0.0
    775 */
    776 HB_EXTERN void
    777 hb_paint_funcs_set_push_clip_glyph_func (hb_paint_funcs_t                *funcs,
    778                                         hb_paint_push_clip_glyph_func_t  func,
    779                                         void                            *user_data,
    780                                         hb_destroy_func_t                destroy);
    781 
    782 /**
    783 * hb_paint_funcs_set_push_clip_rectangle_func:
    784 * @funcs: A paint functions struct
    785 * @func: (closure user_data) (destroy destroy) (scope notified): The push-clip-rectangle callback
    786 * @user_data: Data to pass to @func
    787 * @destroy: (nullable): Function to call when @user_data is no longer needed
    788 *
    789 * Sets the push-clip-rect callback on the paint functions struct.
    790 *
    791 * Since: 7.0.0
    792 */
    793 HB_EXTERN void
    794 hb_paint_funcs_set_push_clip_rectangle_func (hb_paint_funcs_t                    *funcs,
    795                                             hb_paint_push_clip_rectangle_func_t  func,
    796                                             void                                *user_data,
    797                                             hb_destroy_func_t                    destroy);
    798 
    799 /**
    800 * hb_paint_funcs_set_pop_clip_func:
    801 * @funcs: A paint functions struct
    802 * @func: (closure user_data) (destroy destroy) (scope notified): The pop-clip callback
    803 * @user_data: Data to pass to @func
    804 * @destroy: (nullable): Function to call when @user_data is no longer needed
    805 *
    806 * Sets the pop-clip callback on the paint functions struct.
    807 *
    808 * Since: 7.0.0
    809 */
    810 HB_EXTERN void
    811 hb_paint_funcs_set_pop_clip_func (hb_paint_funcs_t         *funcs,
    812                                  hb_paint_pop_clip_func_t  func,
    813                                  void                     *user_data,
    814                                  hb_destroy_func_t         destroy);
    815 
    816 /**
    817 * hb_paint_funcs_set_color_func:
    818 * @funcs: A paint functions struct
    819 * @func: (closure user_data) (destroy destroy) (scope notified): The paint-color callback
    820 * @user_data: Data to pass to @func
    821 * @destroy: (nullable): Function to call when @user_data is no longer needed
    822 *
    823 * Sets the paint-color callback on the paint functions struct.
    824 *
    825 * Since: 7.0.0
    826 */
    827 HB_EXTERN void
    828 hb_paint_funcs_set_color_func (hb_paint_funcs_t      *funcs,
    829                               hb_paint_color_func_t  func,
    830                               void                  *user_data,
    831                               hb_destroy_func_t      destroy);
    832 
    833 /**
    834 * hb_paint_funcs_set_image_func:
    835 * @funcs: A paint functions struct
    836 * @func: (closure user_data) (destroy destroy) (scope notified): The paint-image callback
    837 * @user_data: Data to pass to @func
    838 * @destroy: (nullable): Function to call when @user_data is no longer needed
    839 *
    840 * Sets the paint-image callback on the paint functions struct.
    841 *
    842 * Since: 7.0.0
    843 */
    844 HB_EXTERN void
    845 hb_paint_funcs_set_image_func (hb_paint_funcs_t      *funcs,
    846                               hb_paint_image_func_t  func,
    847                               void                  *user_data,
    848                               hb_destroy_func_t      destroy);
    849 
    850 /**
    851 * hb_paint_funcs_set_linear_gradient_func:
    852 * @funcs: A paint functions struct
    853 * @func: (closure user_data) (destroy destroy) (scope notified): The linear-gradient callback
    854 * @user_data: Data to pass to @func
    855 * @destroy: (nullable): Function to call when @user_data is no longer needed
    856 *
    857 * Sets the linear-gradient callback on the paint functions struct.
    858 *
    859 * Since: 7.0.0
    860 */
    861 HB_EXTERN void
    862 hb_paint_funcs_set_linear_gradient_func (hb_paint_funcs_t                *funcs,
    863                                         hb_paint_linear_gradient_func_t  func,
    864                                         void                            *user_data,
    865                                         hb_destroy_func_t                destroy);
    866 
    867 /**
    868 * hb_paint_funcs_set_radial_gradient_func:
    869 * @funcs: A paint functions struct
    870 * @func: (closure user_data) (destroy destroy) (scope notified): The radial-gradient callback
    871 * @user_data: Data to pass to @func
    872 * @destroy: (nullable): Function to call when @user_data is no longer needed
    873 *
    874 * Sets the radial-gradient callback on the paint functions struct.
    875 *
    876 * Since: 7.0.0
    877 */
    878 HB_EXTERN void
    879 hb_paint_funcs_set_radial_gradient_func (hb_paint_funcs_t                *funcs,
    880                                         hb_paint_radial_gradient_func_t  func,
    881                                         void                            *user_data,
    882                                         hb_destroy_func_t                destroy);
    883 
    884 /**
    885 * hb_paint_funcs_set_sweep_gradient_func:
    886 * @funcs: A paint functions struct
    887 * @func: (closure user_data) (destroy destroy) (scope notified): The sweep-gradient callback
    888 * @user_data: Data to pass to @func
    889 * @destroy: (nullable): Function to call when @user_data is no longer needed
    890 *
    891 * Sets the sweep-gradient callback on the paint functions struct.
    892 *
    893 * Since: 7.0.0
    894 */
    895 HB_EXTERN void
    896 hb_paint_funcs_set_sweep_gradient_func (hb_paint_funcs_t               *funcs,
    897                                        hb_paint_sweep_gradient_func_t  func,
    898                                        void                           *user_data,
    899                                        hb_destroy_func_t               destroy);
    900 
    901 /**
    902 * hb_paint_funcs_set_push_group_func:
    903 * @funcs: A paint functions struct
    904 * @func: (closure user_data) (destroy destroy) (scope notified): The push-group callback
    905 * @user_data: Data to pass to @func
    906 * @destroy: (nullable): Function to call when @user_data is no longer needed
    907 *
    908 * Sets the push-group callback on the paint functions struct.
    909 *
    910 * Since: 7.0.0
    911 */
    912 HB_EXTERN void
    913 hb_paint_funcs_set_push_group_func (hb_paint_funcs_t           *funcs,
    914                                    hb_paint_push_group_func_t  func,
    915                                    void                       *user_data,
    916                                    hb_destroy_func_t           destroy);
    917 
    918 /**
    919 * hb_paint_funcs_set_pop_group_func:
    920 * @funcs: A paint functions struct
    921 * @func: (closure user_data) (destroy destroy) (scope notified): The pop-group callback
    922 * @user_data: Data to pass to @func
    923 * @destroy: (nullable): Function to call when @user_data is no longer needed
    924 *
    925 * Sets the pop-group callback on the paint functions struct.
    926 *
    927 * Since: 7.0.0
    928 */
    929 HB_EXTERN void
    930 hb_paint_funcs_set_pop_group_func (hb_paint_funcs_t          *funcs,
    931                                   hb_paint_pop_group_func_t  func,
    932                                   void                       *user_data,
    933                                   hb_destroy_func_t           destroy);
    934 
    935 /**
    936 * hb_paint_funcs_set_custom_palette_color_func:
    937 * @funcs: A paint functions struct
    938 * @func: (closure user_data) (destroy destroy) (scope notified): The custom-palette-color callback
    939 * @user_data: Data to pass to @func
    940 * @destroy: (nullable): Function to call when @user_data is no longer needed
    941 *
    942 * Sets the custom-palette-color callback on the paint functions struct.
    943 *
    944 * Since: 7.0.0
    945 */
    946 HB_EXTERN void
    947 hb_paint_funcs_set_custom_palette_color_func (hb_paint_funcs_t                     *funcs,
    948                                              hb_paint_custom_palette_color_func_t  func,
    949                                              void                                 *user_data,
    950                                              hb_destroy_func_t                     destroy);
    951 /*
    952 * Manual API
    953 */
    954 
    955 HB_EXTERN void
    956 hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
    957                         float xx, float yx,
    958                         float xy, float yy,
    959                         float dx, float dy);
    960 
    961 HB_EXTERN void
    962 hb_paint_push_font_transform (hb_paint_funcs_t *funcs, void *paint_data,
    963                              const hb_font_t *font);
    964 
    965 HB_EXTERN void
    966 hb_paint_push_inverse_font_transform (hb_paint_funcs_t *funcs, void *paint_data,
    967                                      const hb_font_t *font);
    968 
    969 HB_EXTERN void
    970 hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data);
    971 
    972 HB_EXTERN hb_bool_t
    973 hb_paint_color_glyph (hb_paint_funcs_t *funcs, void *paint_data,
    974                      hb_codepoint_t glyph,
    975                      hb_font_t *font);
    976 
    977 HB_EXTERN void
    978 hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
    979                          hb_codepoint_t glyph,
    980                          hb_font_t *font);
    981 
    982 HB_EXTERN void
    983 hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data,
    984                              float xmin, float ymin,
    985                              float xmax, float ymax);
    986 
    987 HB_EXTERN void
    988 hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data);
    989 
    990 HB_EXTERN void
    991 hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
    992                hb_bool_t is_foreground,
    993                hb_color_t color);
    994 
    995 HB_EXTERN void
    996 hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
    997                hb_blob_t *image,
    998                unsigned int width,
    999                unsigned int height,
   1000                hb_tag_t format,
   1001                float slant,
   1002                hb_glyph_extents_t *extents);
   1003 
   1004 HB_EXTERN void
   1005 hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
   1006                          hb_color_line_t *color_line,
   1007                          float x0, float y0,
   1008                          float x1, float y1,
   1009                          float x2, float y2);
   1010 
   1011 HB_EXTERN void
   1012 hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
   1013                          hb_color_line_t *color_line,
   1014                          float x0, float y0,
   1015                          float r0,
   1016                          float x1, float y1,
   1017                          float r1);
   1018 
   1019 HB_EXTERN void
   1020 hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
   1021                         hb_color_line_t *color_line,
   1022                         float x0, float y0,
   1023                         float start_angle, float end_angle);
   1024 
   1025 HB_EXTERN void
   1026 hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data);
   1027 
   1028 HB_EXTERN void
   1029 hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data,
   1030                    hb_paint_composite_mode_t mode);
   1031 
   1032 HB_EXTERN hb_bool_t
   1033 hb_paint_custom_palette_color (hb_paint_funcs_t *funcs, void *paint_data,
   1034                               unsigned int color_index,
   1035                               hb_color_t *color);
   1036 
   1037 HB_END_DECLS
   1038 
   1039 #endif  /* HB_PAINT_H */