Coverage Report

Created: 2024-01-21 06:55

/src/harfbuzz/src/hb-paint.h
Line
Count
Source (jump to first uncovered line)
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: REPLACEME
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: REPLACEME
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: REPLACEME
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_push_clip_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_push_clip_glyph_func()
146
 *
147
 * A virtual method for the #hb_paint_funcs_t to clip
148
 * subsequent paint calls to the outline of a glyph.
149
 *
150
 * The coordinates of the glyph outline are interpreted according
151
 * to the current transform.
152
 *
153
 * This clip is applied in addition to the current clip,
154
 * and remains in effect until a matching call to
155
 * the #hb_paint_funcs_pop_clip_func_t vfunc.
156
 *
157
 * Since: REPLACEME
158
 */
159
typedef void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs,
160
                                                 void *paint_data,
161
                                                 hb_codepoint_t glyph,
162
                                                 hb_font_t *font,
163
                                                 void *user_data);
164
165
/**
166
 * hb_paint_push_clip_rectangle_func_t:
167
 * @funcs: paint functions object
168
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
169
 * @xmin: min X for the rectangle
170
 * @ymin: min Y for the rectangle
171
 * @xmax: max X for the rectangle
172
 * @ymax: max Y for the rectangle
173
 * @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_rectangle_func()
174
 *
175
 * A virtual method for the #hb_paint_funcs_t to clip
176
 * subsequent paint calls to a rectangle.
177
 *
178
 * The coordinates of the rectangle are interpreted according
179
 * to the current transform.
180
 *
181
 * This clip is applied in addition to the current clip,
182
 * and remains in effect until a matching call to
183
 * the #hb_paint_funcs_pop_clip_func_t vfunc.
184
 *
185
 * Since: REPLACEME
186
 */
187
typedef void (*hb_paint_push_clip_rectangle_func_t) (hb_paint_funcs_t *funcs,
188
                                                     void *paint_data,
189
                                                     float xmin, float ymin,
190
                                                     float xmax, float ymax,
191
                                                     void *user_data);
192
193
/**
194
 * hb_paint_pop_clip_func_t:
195
 * @funcs: paint functions object
196
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
197
 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_clip_func()
198
 *
199
 * A virtual method for the #hb_paint_funcs_t to undo
200
 * the effect of a prior call to the #hb_paint_funcs_push_clip_glyph_func_t
201
 * or #hb_paint_funcs_push_clip_rectangle_func_t vfuncs.
202
 *
203
 * Since: REPLACEME
204
 */
205
typedef void (*hb_paint_pop_clip_func_t) (hb_paint_funcs_t *funcs,
206
                                          void *paint_data,
207
                                          void *user_data);
208
209
/**
210
 * hb_paint_color_func_t:
211
 * @funcs: paint functions object
212
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
213
 * @is_foreground: whether the color is the foreground
214
 * @color: The color to use, unpremultiplied
215
 * @user_data: User data pointer passed to hb_paint_funcs_set_color_func()
216
 *
217
 * A virtual method for the #hb_paint_funcs_t to paint a
218
 * color everywhere within the current clip.
219
 *
220
 * Since: REPLACEME
221
 */
222
typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
223
                                       void *paint_data,
224
                                       hb_bool_t is_foreground,
225
                                       hb_color_t color,
226
                                       void *user_data);
227
228
/**
229
 * HB_PAINT_IMAGE_FORMAT_PNG:
230
 *
231
 * Tag identifying PNG images in #hb_paint_image_func_t callbacks.
232
 *
233
 * Since: REPLACEME
234
 */
235
0
#define HB_PAINT_IMAGE_FORMAT_PNG HB_TAG('p','n','g',' ')
236
237
/**
238
 * HB_PAINT_IMAGE_FORMAT_SVG:
239
 *
240
 * Tag identifying SVG images in #hb_paint_image_func_t callbacks.
241
 *
242
 * Since: REPLACEME
243
 */
244
0
#define HB_PAINT_IMAGE_FORMAT_SVG HB_TAG('s','v','g',' ')
245
246
/**
247
 * HB_PAINT_IMAGE_FORMAT_BGRA:
248
 *
249
 * Tag identifying raw pixel-data images in #hb_paint_image_func_t callbacks.
250
 * The data is in BGRA pre-multiplied sRGBA color-space format.
251
 *
252
 * Since: REPLACEME
253
 */
254
#define HB_PAINT_IMAGE_FORMAT_BGRA HB_TAG('B','G','R','A')
255
256
/**
257
 * hb_paint_image_func_t:
258
 * @funcs: paint functions object
259
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
260
 * @image: the image data
261
 * @width: width of the raster image in pixels, or 0
262
 * @height: height of the raster image in pixels, or 0
263
 * @format: the image format as a tag
264
 * @slant: the synthetic slant ratio to be applied to the image during rendering
265
 * @extents: (nullable): glyph extents for desired rendering
266
 * @user_data: User data pointer passed to hb_paint_funcs_set_image_func()
267
 *
268
 * A virtual method for the #hb_paint_funcs_t to paint a glyph image.
269
 *
270
 * This method is called for glyphs with image blobs in the CBDT,
271
 * sbix or SVG tables. The @format identifies the kind of data that
272
 * is contained in @image. Possible values include #HB_PAINT_IMAGE_FORMAT_PNG,
273
 * #HB_PAINT_IMAGE_FORMAT_SVG and #HB_PAINT_IMAGE_FORMAT_BGRA.
274
 *
275
 * The image dimensions and glyph extents are provided if available,
276
 * and should be used to size and position the image.
277
 *
278
 * Return value: Whether the operation was successful.
279
 *
280
 * Since: REPLACEME
281
 */
282
typedef hb_bool_t (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,
283
              void *paint_data,
284
              hb_blob_t *image,
285
              unsigned int width,
286
              unsigned int height,
287
              hb_tag_t format,
288
              float slant,
289
              hb_glyph_extents_t *extents,
290
              void *user_data);
291
292
/**
293
 * hb_color_stop_t:
294
 * @offset: the offset of the color stop
295
 * @is_foreground: whether the color is the foreground
296
 * @color: the color, unpremultiplied
297
 *
298
 * Information about a color stop on a color line.
299
 *
300
 * Color lines typically have offsets ranging between 0 and 1,
301
 * but that is not required.
302
 *
303
 * Note: despite @color being unpremultiplied here, interpolation in
304
 * gradients shall happen in premultiplied space. See the OpenType spec
305
 * [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
306
 * section for details.
307
 *
308
 * Since: REPLACEME
309
 */
310
typedef struct {
311
  float offset;
312
  hb_bool_t is_foreground;
313
  hb_color_t color;
314
} hb_color_stop_t;
315
316
/**
317
 * hb_paint_extend_t:
318
 * @HB_PAINT_EXTEND_PAD: Outside the defined interval,
319
 *   the color of the closest color stop is used.
320
 * @HB_PAINT_EXTEND_REPEAT: The color line is repeated over
321
 *   repeated multiples of the defined interval
322
 * @HB_PAINT_EXTEND_REFLECT: The color line is repeated over
323
 *      repeated intervals, as for the repeat mode.
324
 *      However, in each repeated interval, the ordering of
325
 *      color stops is the reverse of the adjacent interval.
326
 *
327
 * The values of this enumeration determine how color values
328
 * outside the minimum and maximum defined offset on a #hb_color_line_t
329
 * are determined.
330
 *
331
 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
332
 * section for details.
333
 *
334
 * Since: REPLACEME
335
 */
336
typedef enum {
337
  HB_PAINT_EXTEND_PAD,
338
  HB_PAINT_EXTEND_REPEAT,
339
  HB_PAINT_EXTEND_REFLECT
340
} hb_paint_extend_t;
341
342
typedef struct hb_color_line_t hb_color_line_t;
343
344
/**
345
 * hb_color_line_get_color_stops_func_t:
346
 * @color_line: a #hb_color_line_t object
347
 * @color_line_data: the data accompanying @color_line
348
 * @start: the index of the first color stop to return
349
 * @count: (inout) (optional): Input = the maximum number of feature tags to return;
350
 *     Output = the actual number of feature tags returned (may be zero)
351
 * @color_stops: (out) (array length=count) (optional): Array of #hb_color_stop_t to populate
352
 * @user_data: the data accompanying this method
353
 *
354
 * A virtual method for the #hb_color_line_t to fetch color stops.
355
 *
356
 * Return value: the total number of color stops in @color_line
357
 *
358
 * Since: REPLACEME
359
 */
360
typedef unsigned int (*hb_color_line_get_color_stops_func_t) (hb_color_line_t *color_line,
361
                    void *color_line_data,
362
                    unsigned int start,
363
                    unsigned int *count,
364
                    hb_color_stop_t *color_stops,
365
                    void *user_data);
366
367
/**
368
 * hb_color_line_get_extend_func_t:
369
 * @color_line: a #hb_color_line_t object
370
 * @color_line_data: the data accompanying @color_line
371
 * @user_data: the data accompanying this method
372
 *
373
 * A virtual method for the @hb_color_line_t to fetches the extend mode.
374
 *
375
 * Return value: the extend mode of @color_line
376
 *
377
 * Since: REPLACEME
378
 */
379
typedef hb_paint_extend_t (*hb_color_line_get_extend_func_t) (hb_color_line_t *color_line,
380
                    void *color_line_data,
381
                    void *user_data);
382
383
/**
384
 * hb_color_line_t:
385
 *
386
 * A struct containing color information for a gradient.
387
 *
388
 * Since: REPLACEME
389
 */
390
struct hb_color_line_t {
391
  void *data;
392
393
  hb_color_line_get_color_stops_func_t get_color_stops;
394
  void *get_color_stops_user_data;
395
396
  hb_color_line_get_extend_func_t get_extend;
397
  void *get_extend_user_data;
398
399
  void *reserved0;
400
  void *reserved1;
401
  void *reserved2;
402
  void *reserved3;
403
  void *reserved5;
404
  void *reserved6;
405
  void *reserved7;
406
  void *reserved8;
407
};
408
409
HB_EXTERN unsigned int
410
hb_color_line_get_color_stops (hb_color_line_t *color_line,
411
                               unsigned int start,
412
                               unsigned int *count,
413
                               hb_color_stop_t *color_stops);
414
415
HB_EXTERN hb_paint_extend_t
416
hb_color_line_get_extend (hb_color_line_t *color_line);
417
418
/**
419
 * hb_paint_linear_gradient_func_t:
420
 * @funcs: paint functions object
421
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
422
 * @color_line: Color information for the gradient
423
 * @x0: X coordinate of the first point
424
 * @y0: Y coordinate of the first point
425
 * @x1: X coordinate of the second point
426
 * @y1: Y coordinate of the second point
427
 * @x2: X coordinate of the third point
428
 * @y2: Y coordinate of the third point
429
 * @user_data: User data pointer passed to hb_paint_funcs_set_linear_gradient_func()
430
 *
431
 * A virtual method for the #hb_paint_funcs_t to paint a linear
432
 * gradient everywhere within the current clip.
433
 *
434
 * The @color_line object contains information about the colors of the gradients.
435
 * It is only valid for the duration of the callback, you cannot keep it around.
436
 *
437
 * The coordinates of the points are interpreted according
438
 * to the current transform.
439
 *
440
 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
441
 * section for details on how the points define the direction
442
 * of the gradient, and how to interpret the @color_line.
443
 *
444
 * Since: REPLACEME
445
 */
446
typedef void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,
447
                                                 void *paint_data,
448
                                                 hb_color_line_t *color_line,
449
                                                 float x0, float y0,
450
                                                 float x1, float y1,
451
                                                 float x2, float y2,
452
                                                 void *user_data);
453
454
/**
455
 * hb_paint_radial_gradient_func_t:
456
 * @funcs: paint functions object
457
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
458
 * @color_line: Color information for the gradient
459
 * @x0: X coordinate of the first circle's center
460
 * @y0: Y coordinate of the first circle's center
461
 * @r0: radius of the first circle
462
 * @x1: X coordinate of the second circle's center
463
 * @y1: Y coordinate of the second circle's center
464
 * @r1: radius of the second circle
465
 * @user_data: User data pointer passed to hb_paint_funcs_set_radial_gradient_func()
466
 *
467
 * A virtual method for the #hb_paint_funcs_t to paint a radial
468
 * gradient everywhere within the current clip.
469
 *
470
 * The @color_line object contains information about the colors of the gradients.
471
 * It is only valid for the duration of the callback, you cannot keep it around.
472
 *
473
 * The coordinates of the points are interpreted according
474
 * to the current transform.
475
 *
476
 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
477
 * section for details on how the points define the direction
478
 * of the gradient, and how to interpret the @color_line.
479
 *
480
 * Since: REPLACEME
481
 */
482
typedef void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,
483
                                                 void *paint_data,
484
                                                 hb_color_line_t *color_line,
485
                                                 float x0, float y0, float r0,
486
                                                 float x1, float y1, float r1,
487
                                                 void *user_data);
488
489
/**
490
 * hb_paint_sweep_gradient_func_t:
491
 * @funcs: paint functions object
492
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
493
 * @color_line: Color information for the gradient
494
 * @x0: X coordinate of the circle's center
495
 * @y0: Y coordinate of the circle's center
496
 * @start_angle: the start angle, in radians
497
 * @end_angle: the end angle, in radians
498
 * @user_data: User data pointer passed to hb_paint_funcs_set_sweep_gradient_func()
499
 *
500
 * A virtual method for the #hb_paint_funcs_t to paint a sweep
501
 * gradient everywhere within the current clip.
502
 *
503
 * The @color_line object contains information about the colors of the gradients.
504
 * It is only valid for the duration of the callback, you cannot keep it around.
505
 *
506
 * The coordinates of the points are interpreted according
507
 * to the current transform.
508
 *
509
 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
510
 * section for details on how the points define the direction
511
 * of the gradient, and how to interpret the @color_line.
512
 *
513
 * Since: REPLACEME
514
 */
515
typedef void (*hb_paint_sweep_gradient_func_t)  (hb_paint_funcs_t *funcs,
516
                                                 void *paint_data,
517
                                                 hb_color_line_t *color_line,
518
                                                 float x0, float y0,
519
                                                 float start_angle,
520
                                                 float end_angle,
521
                                                 void *user_data);
522
523
/**
524
 * hb_paint_composite_mode_t:
525
 * @HB_PAINT_COMPOSITE_MODE_CLEAR: clear destination layer (bounded)
526
 * @HB_PAINT_COMPOSITE_MODE_SRC: replace destination layer (bounded)
527
 * @HB_PAINT_COMPOSITE_MODE_SRC_OVER: draw source layer on top of destination layer
528
 * (bounded)
529
 * @HB_PAINT_COMPOSITE_MODE_SRC_IN: draw source where there was destination content
530
 * (unbounded)
531
 * @HB_PAINT_COMPOSITE_MODE_SRC_OUT: draw source where there was no destination
532
 * content (unbounded)
533
 * @HB_PAINT_COMPOSITE_MODE_SRC_ATOP: draw source on top of destination content and
534
 * only there
535
 * @HB_PAINT_COMPOSITE_MODE_DEST: ignore the source
536
 * @HB_PAINT_COMPOSITE_MODE_DEST_OVER: draw destination on top of source
537
 * @HB_PAINT_COMPOSITE_MODE_DEST_IN: leave destination only where there was
538
 * source content (unbounded)
539
 * @HB_PAINT_COMPOSITE_MODE_DEST_OUT: leave destination only where there was no
540
 * source content
541
 * @HB_PAINT_COMPOSITE_MODE_DEST_ATOP: leave destination on top of source content
542
 * and only there (unbounded)
543
 * @HB_PAINT_COMPOSITE_MODE_XOR: source and destination are shown where there is only
544
 * one of them
545
 * @HB_PAINT_COMPOSITE_MODE_PLUS: source and destination layers are accumulated
546
 * @HB_PAINT_COMPOSITE_MODE_MULTIPLY: source and destination layers are multiplied.
547
 * This causes the result to be at least as dark as the darker inputs.
548
 * @HB_PAINT_COMPOSITE_MODE_SCREEN: source and destination are complemented and
549
 * multiplied. This causes the result to be at least as light as the lighter
550
 * inputs.
551
 * @HB_PAINT_COMPOSITE_MODE_OVERLAY: multiplies or screens, depending on the
552
 * lightness of the destination color.
553
 * @HB_PAINT_COMPOSITE_MODE_DARKEN: replaces the destination with the source if it
554
 * is darker, otherwise keeps the source.
555
 * @HB_PAINT_COMPOSITE_MODE_LIGHTEN: replaces the destination with the source if it
556
 * is lighter, otherwise keeps the source.
557
 * @HB_PAINT_COMPOSITE_MODE_COLOR_DODGE: brightens the destination color to reflect
558
 * the source color.
559
 * @HB_PAINT_COMPOSITE_MODE_COLOR_BURN: darkens the destination color to reflect
560
 * the source color.
561
 * @HB_PAINT_COMPOSITE_MODE_HARD_LIGHT: Multiplies or screens, dependent on source
562
 * color.
563
 * @HB_PAINT_COMPOSITE_MODE_SOFT_LIGHT: Darkens or lightens, dependent on source
564
 * color.
565
 * @HB_PAINT_COMPOSITE_MODE_DIFFERENCE: Takes the difference of the source and
566
 * destination color.
567
 * @HB_PAINT_COMPOSITE_MODE_EXCLUSION: Produces an effect similar to difference, but
568
 * with lower contrast.
569
 * @HB_PAINT_COMPOSITE_MODE_HSL_HUE: Creates a color with the hue of the source
570
 * and the saturation and luminosity of the target.
571
 * @HB_PAINT_COMPOSITE_MODE_HSL_SATURATION: Creates a color with the saturation
572
 * of the source and the hue and luminosity of the target. Painting with
573
 * this mode onto a gray area produces no change.
574
 * @HB_PAINT_COMPOSITE_MODE_HSL_COLOR: Creates a color with the hue and saturation
575
 * of the source and the luminosity of the target. This preserves the gray
576
 * levels of the target and is useful for coloring monochrome images or
577
 * tinting color images.
578
 * @HB_PAINT_COMPOSITE_MODE_HSL_LUMINOSITY: Creates a color with the luminosity of
579
 * the source and the hue and saturation of the target. This produces an
580
 * inverse effect to @HB_PAINT_COMPOSITE_MODE_HSL_COLOR.
581
 *
582
 * The values of this enumeration describe the compositing modes
583
 * that can be used when combining temporary redirected drawing
584
 * with the backdrop.
585
 *
586
 * See the OpenType spec [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr)
587
 * section for details.
588
 *
589
 * Since: REPLACEME
590
 */
591
typedef enum {
592
  HB_PAINT_COMPOSITE_MODE_CLEAR,
593
  HB_PAINT_COMPOSITE_MODE_SRC,
594
  HB_PAINT_COMPOSITE_MODE_DEST,
595
  HB_PAINT_COMPOSITE_MODE_SRC_OVER,
596
  HB_PAINT_COMPOSITE_MODE_DEST_OVER,
597
  HB_PAINT_COMPOSITE_MODE_SRC_IN,
598
  HB_PAINT_COMPOSITE_MODE_DEST_IN,
599
  HB_PAINT_COMPOSITE_MODE_SRC_OUT,
600
  HB_PAINT_COMPOSITE_MODE_DEST_OUT,
601
  HB_PAINT_COMPOSITE_MODE_SRC_ATOP,
602
  HB_PAINT_COMPOSITE_MODE_DEST_ATOP,
603
  HB_PAINT_COMPOSITE_MODE_XOR,
604
  HB_PAINT_COMPOSITE_MODE_PLUS,
605
  HB_PAINT_COMPOSITE_MODE_SCREEN,
606
  HB_PAINT_COMPOSITE_MODE_OVERLAY,
607
  HB_PAINT_COMPOSITE_MODE_DARKEN,
608
  HB_PAINT_COMPOSITE_MODE_LIGHTEN,
609
  HB_PAINT_COMPOSITE_MODE_COLOR_DODGE,
610
  HB_PAINT_COMPOSITE_MODE_COLOR_BURN,
611
  HB_PAINT_COMPOSITE_MODE_HARD_LIGHT,
612
  HB_PAINT_COMPOSITE_MODE_SOFT_LIGHT,
613
  HB_PAINT_COMPOSITE_MODE_DIFFERENCE,
614
  HB_PAINT_COMPOSITE_MODE_EXCLUSION,
615
  HB_PAINT_COMPOSITE_MODE_MULTIPLY,
616
  HB_PAINT_COMPOSITE_MODE_HSL_HUE,
617
  HB_PAINT_COMPOSITE_MODE_HSL_SATURATION,
618
  HB_PAINT_COMPOSITE_MODE_HSL_COLOR,
619
  HB_PAINT_COMPOSITE_MODE_HSL_LUMINOSITY,
620
} hb_paint_composite_mode_t;
621
622
/**
623
 * hb_paint_push_group_func_t:
624
 * @funcs: paint functions object
625
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
626
 * @user_data: User data pointer passed to hb_paint_funcs_set_push_group_func()
627
 *
628
 * A virtual method for the #hb_paint_funcs_t to use
629
 * an intermediate surface for subsequent paint calls.
630
 *
631
 * The drawing will be redirected to an intermediate surface
632
 * until a matching call to the #hb_paint_funcs_pop_group_func_t
633
 * vfunc.
634
 *
635
 * Since: REPLACEME
636
 */
637
typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
638
                                            void *paint_data,
639
                                            void *user_data);
640
641
/**
642
 * hb_paint_pop_group_func_t:
643
 * @funcs: paint functions object
644
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
645
 * @mode: the compositing mode to use
646
 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_group_func()
647
 *
648
 * A virtual method for the #hb_paint_funcs_t to undo
649
 * the effect of a prior call to the #hb_paint_funcs_push_group_func_t
650
 * vfunc.
651
 *
652
 * This call stops the redirection to the intermediate surface,
653
 * and then composites it on the previous surface, using the
654
 * compositing mode passed to this call.
655
 *
656
 * Since: REPLACEME
657
 */
658
typedef void (*hb_paint_pop_group_func_t) (hb_paint_funcs_t *funcs,
659
                                           void *paint_data,
660
                                           hb_paint_composite_mode_t mode,
661
                                           void *user_data);
662
663
/**
664
 * hb_paint_custom_palette_color_func_t:
665
 * @funcs: paint functions object
666
 * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
667
 * @color_index: the color index
668
 * @color: (out): fetched color
669
 * @user_data: User data pointer passed to hb_paint_funcs_set_pop_group_func()
670
 *
671
 * A virtual method for the #hb_paint_funcs_t to fetch a color from the custom
672
 * color palette.
673
 *
674
 * Custom palette colors override the colors from the fonts selected color
675
 * palette. It is not necessary to override all palette entries; for entries
676
 * that should be taken from the font palette, return `false`.
677
 *
678
 * This function might get called multiple times, but the custom palette is
679
 * expected to remain unchanged for duration of a hb_font_paint_glyph() call.
680
 *
681
 * Return value: `true` if found, `false` otherwise
682
 *
683
 * Since: REPLACEME
684
 */
685
typedef hb_bool_t (*hb_paint_custom_palette_color_func_t) (hb_paint_funcs_t *funcs,
686
                                                           void *paint_data,
687
                                                           unsigned int color_index,
688
                                                           hb_color_t *color,
689
                                                           void *user_data);
690
691
692
/**
693
 * hb_paint_funcs_set_push_transform_func:
694
 * @funcs: A paint functions struct
695
 * @func: (closure user_data) (destroy destroy) (scope notified): The push-transform callback
696
 * @user_data: Data to pass to @func
697
 * @destroy: (nullable): Function to call when @user_data is no longer needed
698
 *
699
 * Sets the push-transform callback on the paint functions struct.
700
 *
701
 * Since: REPLACEME
702
 */
703
HB_EXTERN void
704
hb_paint_funcs_set_push_transform_func (hb_paint_funcs_t               *funcs,
705
                                        hb_paint_push_transform_func_t  func,
706
                                        void                           *user_data,
707
                                        hb_destroy_func_t               destroy);
708
709
/**
710
 * hb_paint_funcs_set_pop_transform_func:
711
 * @funcs: A paint functions struct
712
 * @func: (closure user_data) (destroy destroy) (scope notified): The pop-transform callback
713
 * @user_data: Data to pass to @func
714
 * @destroy: (nullable): Function to call when @user_data is no longer needed
715
 *
716
 * Sets the pop-transform callback on the paint functions struct.
717
 *
718
 * Since: REPLACEME
719
 */
720
HB_EXTERN void
721
hb_paint_funcs_set_pop_transform_func (hb_paint_funcs_t              *funcs,
722
                                       hb_paint_pop_transform_func_t  func,
723
                                       void                          *user_data,
724
                                       hb_destroy_func_t              destroy);
725
726
/**
727
 * hb_paint_funcs_set_push_clip_glyph_func:
728
 * @funcs: A paint functions struct
729
 * @func: (closure user_data) (destroy destroy) (scope notified): The push-clip-glyph callback
730
 * @user_data: Data to pass to @func
731
 * @destroy: (nullable): Function to call when @user_data is no longer needed
732
 *
733
 * Sets the push-clip-glyph callback on the paint functions struct.
734
 *
735
 * Since: REPLACEME
736
 */
737
HB_EXTERN void
738
hb_paint_funcs_set_push_clip_glyph_func (hb_paint_funcs_t                *funcs,
739
                                         hb_paint_push_clip_glyph_func_t  func,
740
                                         void                            *user_data,
741
                                         hb_destroy_func_t                destroy);
742
743
/**
744
 * hb_paint_funcs_set_push_clip_rectangle_func:
745
 * @funcs: A paint functions struct
746
 * @func: (closure user_data) (destroy destroy) (scope notified): The push-clip-rectangle callback
747
 * @user_data: Data to pass to @func
748
 * @destroy: (nullable): Function to call when @user_data is no longer needed
749
 *
750
 * Sets the push-clip-rect callback on the paint functions struct.
751
 *
752
 * Since: REPLACEME
753
 */
754
HB_EXTERN void
755
hb_paint_funcs_set_push_clip_rectangle_func (hb_paint_funcs_t                    *funcs,
756
                                             hb_paint_push_clip_rectangle_func_t  func,
757
                                             void                                *user_data,
758
                                             hb_destroy_func_t                    destroy);
759
760
/**
761
 * hb_paint_funcs_set_pop_clip_func:
762
 * @funcs: A paint functions struct
763
 * @func: (closure user_data) (destroy destroy) (scope notified): The pop-clip callback
764
 * @user_data: Data to pass to @func
765
 * @destroy: (nullable): Function to call when @user_data is no longer needed
766
 *
767
 * Sets the pop-clip callback on the paint functions struct.
768
 *
769
 * Since: REPLACEME
770
 */
771
HB_EXTERN void
772
hb_paint_funcs_set_pop_clip_func (hb_paint_funcs_t         *funcs,
773
                                  hb_paint_pop_clip_func_t  func,
774
                                  void                     *user_data,
775
                                  hb_destroy_func_t         destroy);
776
777
/**
778
 * hb_paint_funcs_set_color_func:
779
 * @funcs: A paint functions struct
780
 * @func: (closure user_data) (destroy destroy) (scope notified): The paint-color callback
781
 * @user_data: Data to pass to @func
782
 * @destroy: (nullable): Function to call when @user_data is no longer needed
783
 *
784
 * Sets the paint-color callback on the paint functions struct.
785
 *
786
 * Since: REPLACEME
787
 */
788
HB_EXTERN void
789
hb_paint_funcs_set_color_func (hb_paint_funcs_t      *funcs,
790
                               hb_paint_color_func_t  func,
791
                               void                  *user_data,
792
                               hb_destroy_func_t      destroy);
793
794
/**
795
 * hb_paint_funcs_set_image_func:
796
 * @funcs: A paint functions struct
797
 * @func: (closure user_data) (destroy destroy) (scope notified): The paint-image callback
798
 * @user_data: Data to pass to @func
799
 * @destroy: (nullable): Function to call when @user_data is no longer needed
800
 *
801
 * Sets the paint-image callback on the paint functions struct.
802
 *
803
 * Since: REPLACEME
804
 */
805
HB_EXTERN void
806
hb_paint_funcs_set_image_func (hb_paint_funcs_t      *funcs,
807
                               hb_paint_image_func_t  func,
808
                               void                  *user_data,
809
                               hb_destroy_func_t      destroy);
810
811
/**
812
 * hb_paint_funcs_set_linear_gradient_func:
813
 * @funcs: A paint functions struct
814
 * @func: (closure user_data) (destroy destroy) (scope notified): The linear-gradient callback
815
 * @user_data: Data to pass to @func
816
 * @destroy: (nullable): Function to call when @user_data is no longer needed
817
 *
818
 * Sets the linear-gradient callback on the paint functions struct.
819
 *
820
 * Since: REPLACEME
821
 */
822
HB_EXTERN void
823
hb_paint_funcs_set_linear_gradient_func (hb_paint_funcs_t                *funcs,
824
                                         hb_paint_linear_gradient_func_t  func,
825
                                         void                            *user_data,
826
                                         hb_destroy_func_t                destroy);
827
828
/**
829
 * hb_paint_funcs_set_radial_gradient_func:
830
 * @funcs: A paint functions struct
831
 * @func: (closure user_data) (destroy destroy) (scope notified): The radial-gradient callback
832
 * @user_data: Data to pass to @func
833
 * @destroy: (nullable): Function to call when @user_data is no longer needed
834
 *
835
 * Sets the radial-gradient callback on the paint functions struct.
836
 *
837
 * Since: REPLACEME
838
 */
839
HB_EXTERN void
840
hb_paint_funcs_set_radial_gradient_func (hb_paint_funcs_t                *funcs,
841
                                         hb_paint_radial_gradient_func_t  func,
842
                                         void                            *user_data,
843
                                         hb_destroy_func_t                destroy);
844
845
/**
846
 * hb_paint_funcs_set_sweep_gradient_func:
847
 * @funcs: A paint functions struct
848
 * @func: (closure user_data) (destroy destroy) (scope notified): The sweep-gradient callback
849
 * @user_data: Data to pass to @func
850
 * @destroy: (nullable): Function to call when @user_data is no longer needed
851
 *
852
 * Sets the sweep-gradient callback on the paint functions struct.
853
 *
854
 * Since: REPLACEME
855
 */
856
HB_EXTERN void
857
hb_paint_funcs_set_sweep_gradient_func (hb_paint_funcs_t               *funcs,
858
                                        hb_paint_sweep_gradient_func_t  func,
859
                                        void                           *user_data,
860
                                        hb_destroy_func_t               destroy);
861
862
/**
863
 * hb_paint_funcs_set_push_group_func:
864
 * @funcs: A paint functions struct
865
 * @func: (closure user_data) (destroy destroy) (scope notified): The push-group callback
866
 * @user_data: Data to pass to @func
867
 * @destroy: (nullable): Function to call when @user_data is no longer needed
868
 *
869
 * Sets the push-group callback on the paint functions struct.
870
 *
871
 * Since: REPLACEME
872
 */
873
HB_EXTERN void
874
hb_paint_funcs_set_push_group_func (hb_paint_funcs_t           *funcs,
875
                                    hb_paint_push_group_func_t  func,
876
                                    void                       *user_data,
877
                                    hb_destroy_func_t           destroy);
878
879
/**
880
 * hb_paint_funcs_set_pop_group_func:
881
 * @funcs: A paint functions struct
882
 * @func: (closure user_data) (destroy destroy) (scope notified): The pop-group callback
883
 * @user_data: Data to pass to @func
884
 * @destroy: (nullable): Function to call when @user_data is no longer needed
885
 *
886
 * Sets the pop-group callback on the paint functions struct.
887
 *
888
 * Since: REPLACEME
889
 */
890
HB_EXTERN void
891
hb_paint_funcs_set_pop_group_func (hb_paint_funcs_t          *funcs,
892
                                   hb_paint_pop_group_func_t  func,
893
                                   void                       *user_data,
894
                                   hb_destroy_func_t           destroy);
895
896
/**
897
 * hb_paint_funcs_set_custom_palette_color_func:
898
 * @funcs: A paint functions struct
899
 * @func: (closure user_data) (destroy destroy) (scope notified): The custom-palette-color callback
900
 * @user_data: Data to pass to @func
901
 * @destroy: (nullable): Function to call when @user_data is no longer needed
902
 *
903
 * Sets the custom-palette-color callback on the paint functions struct.
904
 *
905
 * Since: REPLACEME
906
 */
907
HB_EXTERN void
908
hb_paint_funcs_set_custom_palette_color_func (hb_paint_funcs_t                     *funcs,
909
                                              hb_paint_custom_palette_color_func_t  func,
910
                                              void                                 *user_data,
911
                                              hb_destroy_func_t                     destroy);
912
/*
913
 * Manual API
914
 */
915
916
HB_EXTERN void
917
hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
918
                         float xx, float yx,
919
                         float xy, float yy,
920
                         float dx, float dy);
921
922
HB_EXTERN void
923
hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data);
924
925
HB_EXTERN void
926
hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
927
                          hb_codepoint_t glyph,
928
                          hb_font_t *font);
929
930
HB_EXTERN void
931
hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data,
932
                              float xmin, float ymin,
933
                              float xmax, float ymax);
934
935
HB_EXTERN void
936
hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data);
937
938
HB_EXTERN void
939
hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
940
                hb_bool_t is_foreground,
941
                hb_color_t color);
942
943
HB_EXTERN void
944
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
945
                hb_blob_t *image,
946
                unsigned int width,
947
                unsigned int height,
948
                hb_tag_t format,
949
                float slant,
950
                hb_glyph_extents_t *extents);
951
952
HB_EXTERN void
953
hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
954
                          hb_color_line_t *color_line,
955
                          float x0, float y0,
956
                          float x1, float y1,
957
                          float x2, float y2);
958
959
HB_EXTERN void
960
hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
961
                          hb_color_line_t *color_line,
962
                          float x0, float y0,
963
                          float r0,
964
                          float x1, float y1,
965
                          float r1);
966
967
HB_EXTERN void
968
hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
969
                         hb_color_line_t *color_line,
970
                         float x0, float y0,
971
                         float start_angle, float end_angle);
972
973
HB_EXTERN void
974
hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data);
975
976
HB_EXTERN void
977
hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data,
978
                    hb_paint_composite_mode_t mode);
979
980
HB_EXTERN hb_bool_t
981
hb_paint_custom_palette_color (hb_paint_funcs_t *funcs, void *paint_data,
982
                               unsigned int color_index,
983
                               hb_color_t *color);
984
985
HB_END_DECLS
986
987
#endif  /* HB_PAINT_H */