| Top |
| typedef | hb_paint_funcs_t |
| #define | HB_PAINT_IMAGE_FORMAT_PNG |
| #define | HB_PAINT_IMAGE_FORMAT_SVG |
| #define | HB_PAINT_IMAGE_FORMAT_BGRA |
| typedef | hb_color_line_t |
| hb_color_stop_t | |
| enum | hb_paint_extend_t |
| enum | hb_paint_composite_mode_t |
Functions for painting glyphs.
The main purpose of these functions is to paint (extract) color glyph layers from the COLRv1 table, but the API works for drawing ordinary outlines and images as well.
The hb_paint_funcs_t struct can be used with hb_font_paint_glyph().
hb_paint_funcs_t *
hb_paint_funcs_create (void);
Creates a new hb_paint_funcs_t structure of paint functions.
The initial reference count of 1 should be released with hb_paint_funcs_destroy()
when you are done using the hb_paint_funcs_t. This function never returns
NULL. If memory cannot be allocated, a special singleton hb_paint_funcs_t
object will be returned.
Returns value: (transfer full): the paint-functions structure
Since: 7.0.0
hb_paint_funcs_t *
hb_paint_funcs_get_empty (void);
Fetches the singleton empty paint-functions structure.
Since: 7.0.0
hb_paint_funcs_t *
hb_paint_funcs_reference (hb_paint_funcs_t *funcs);
Increases the reference count on a paint-functions structure.
This prevents funcs
from being destroyed until a matching
call to hb_paint_funcs_destroy() is made.
[skip]
Since: 7.0.0
void
hb_paint_funcs_destroy (hb_paint_funcs_t *funcs);
Decreases the reference count on a paint-functions structure.
When the reference count reaches zero, the structure is destroyed, freeing all memory.
[skip]
Since: 7.0.0
hb_bool_t hb_paint_funcs_set_user_data (hb_paint_funcs_t *funcs,hb_user_data_key_t *key,void *data,hb_destroy_func_t destroy,hb_bool_t replace);
Attaches a user-data key/data pair to the specified paint-functions structure.
[skip]
funcs |
The paint-functions structure |
|
key |
The user-data key |
|
data |
A pointer to the user data |
|
destroy |
A callback to call when |
[nullable] |
replace |
Whether to replace an existing data with the same key |
Since: 7.0.0
void * hb_paint_funcs_get_user_data (const hb_paint_funcs_t *funcs,hb_user_data_key_t *key);
Fetches the user-data associated with the specified key, attached to the specified paint-functions structure.
[skip]
Since: 7.0.0
void
hb_paint_funcs_make_immutable (hb_paint_funcs_t *funcs);
Makes a paint-functions structure immutable.
After this call, all attempts to set one of the callbacks
on funcs
will fail.
Since: 7.0.0
hb_bool_t
hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs);
Tests whether a paint-functions structure is immutable.
Since: 7.0.0
void (*hb_paint_push_transform_func_t) (hb_paint_funcs_t *funcs,void *paint_data,float xx,float yx,float xy,float yy,float dx,float dy,void *user_data);
A virtual method for the hb_paint_funcs_t to apply a transform to subsequent paint calls.
This transform is applied after the current transform, and remains in effect until a matching call to the hb_paint_funcs_pop_transform_func_t vfunc.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
xx |
xx component of the transform matrix |
|
yx |
yx component of the transform matrix |
|
xy |
xy component of the transform matrix |
|
yy |
yy component of the transform matrix |
|
dx |
dx component of the transform matrix |
|
dy |
dy component of the transform matrix |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_push_transform_func (hb_paint_funcs_t *funcs,hb_paint_push_transform_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-transform callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-transform callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,void *paint_data,void *user_data);
A virtual method for the hb_paint_funcs_t to undo the effect of a prior call to the hb_paint_funcs_push_transform_func_t vfunc.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_pop_transform_func (hb_paint_funcs_t *funcs,hb_paint_pop_transform_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the pop-transform callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The pop-transform callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
hb_bool_t (*hb_paint_color_glyph_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_codepoint_t glyph,hb_font_t *font,void *user_data);
A virtual method for the hb_paint_funcs_t to render a color glyph by glyph index.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
glyph |
the glyph ID |
|
font |
the font |
|
user_data |
User data pointer passed to |
Since: 8.2.0
void hb_paint_funcs_set_color_glyph_func (hb_paint_funcs_t *funcs,hb_paint_color_glyph_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the color-glyph callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The color-glyph callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 8.2.0
void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_codepoint_t glyph,hb_font_t *font,void *user_data);
A virtual method for the hb_paint_funcs_t to clip subsequent paint calls to the outline of a glyph.
The coordinates of the glyph outline are expected in the
current font
scale (ie. the results of calling
hb_font_draw_glyph() with font
). The outline is
transformed by the current transform.
This clip is applied in addition to the current clip, and remains in effect until a matching call to the hb_paint_funcs_pop_clip_func_t vfunc.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
glyph |
the glyph ID |
|
font |
the font |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_push_clip_glyph_func (hb_paint_funcs_t *funcs,hb_paint_push_clip_glyph_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-clip-glyph callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-clip-glyph callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_push_clip_rectangle_func_t) (hb_paint_funcs_t *funcs,void *paint_data,float xmin,float ymin,float xmax,float ymax,void *user_data);
A virtual method for the hb_paint_funcs_t to clip subsequent paint calls to a rectangle.
The coordinates of the rectangle are interpreted according to the current transform.
This clip is applied in addition to the current clip, and remains in effect until a matching call to the hb_paint_funcs_pop_clip_func_t vfunc.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
xmin |
min X for the rectangle |
|
ymin |
min Y for the rectangle |
|
xmax |
max X for the rectangle |
|
ymax |
max Y for the rectangle |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_push_clip_rectangle_func (hb_paint_funcs_t *funcs,hb_paint_push_clip_rectangle_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-clip-rect callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-clip-rectangle callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
hb_draw_funcs_t * (*hb_paint_push_clip_path_start_func_t) (hb_paint_funcs_t *funcs,void *paint_data,void **draw_data,void *user_data);
A virtual method for the hb_paint_funcs_t to begin clipping
to an arbitrary path. The backend returns an
hb_draw_funcs_t it owns (the caller must not free it)
that the caller feeds the clip outline to via hb_draw_*()
calls, plus a draw_data
value to pass alongside those
calls. Both are only valid until the matching
hb_paint_push_clip_path_end_func_t call; no other paint
calls should be made in between. The clip remains
in effect until a later hb_paint_pop_clip_func_t call.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
draw_data |
location to store the draw data the caller should pass alongside the returned draw funcs. |
[out] |
user_data |
User data pointer passed to |
draw funcs that accumulate
the clip path, or NULL if arbitrary-path clipping is not
supported.
[transfer none]
Since: 14.2.0
void hb_paint_funcs_set_push_clip_path_start_func (hb_paint_funcs_t *funcs,hb_paint_push_clip_path_start_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-clip-path-start callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-clip-path-start callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 14.2.0
void (*hb_paint_push_clip_path_end_func_t) (hb_paint_funcs_t *funcs,void *paint_data,void *user_data);
A virtual method for the hb_paint_funcs_t to close the clip path started by the hb_paint_push_clip_path_start_func_t vfunc. The emitted path is now active as a clip; subsequent paint ops are masked by it until a matching hb_paint_pop_clip_func_t call.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
user_data |
User data pointer passed to |
Since: 14.2.0
void hb_paint_funcs_set_push_clip_path_end_func (hb_paint_funcs_t *funcs,hb_paint_push_clip_path_end_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-clip-path-end callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-clip-path-end callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 14.2.0
void (*hb_paint_pop_clip_func_t) (hb_paint_funcs_t *funcs,void *paint_data,void *user_data);
A virtual method for the hb_paint_funcs_t to undo the effect of a prior call to the hb_paint_funcs_push_clip_glyph_func_t, hb_paint_funcs_push_clip_rectangle_func_t, or hb_paint_funcs_push_clip_path_end_func_t vfuncs.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_pop_clip_func (hb_paint_funcs_t *funcs,hb_paint_pop_clip_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the pop-clip callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The pop-clip callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_bool_t is_foreground,hb_color_t color,void *user_data);
A virtual method for the hb_paint_funcs_t to paint a color everywhere within the current clip.
When is_foreground
is true, this color originates from the
foreground-color sentinel in the font's color data. The
color
parameter still carries a fully resolved RGBA value
(with any paint-tree alpha already applied), so backends
that do not need to distinguish the foreground can simply
use color
directly.
Backends that defer foreground resolution (e.g. to honor a
CSS currentColor or a runtime uniform) should substitute
their own foreground RGB when is_foreground
is true, but
must combine the alpha from color
with their foreground
alpha, since it encodes additional modulation from the
paint tree. For this mode to work correctly, the caller
should pass a fully-opaque foreground color to
hb_font_paint_glyph(), so that the alpha in color
reflects only the paint-tree contribution.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
is_foreground |
whether the color is the foreground |
|
color |
The color to use, unpremultiplied |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_color_func (hb_paint_funcs_t *funcs,hb_paint_color_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the paint-color callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The paint-color callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
hb_bool_t (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_blob_t *image,unsigned int width,unsigned int height,hb_tag_t format,float slant,hb_glyph_extents_t *extents,void *user_data);
A virtual method for the hb_paint_funcs_t to paint a glyph image.
This method is called for glyphs with image blobs in the CBDT,
sbix or SVG tables. The format
identifies the kind of data that
is contained in image
. Possible values include HB_PAINT_IMAGE_FORMAT_PNG,
HB_PAINT_IMAGE_FORMAT_SVG and HB_PAINT_IMAGE_FORMAT_BGRA.
The image dimensions and glyph extents are provided if available, and should be used to size and position the image.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
image |
the image data |
|
width |
width of the raster image in pixels, or 0 |
|
height |
height of the raster image in pixels, or 0 |
|
format |
the image format as a tag |
|
slant |
Deprecated. Always set to 0.0. |
|
extents |
glyph extents for desired rendering. |
[nullable] |
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_image_func (hb_paint_funcs_t *funcs,hb_paint_image_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the paint-image callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The paint-image callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
unsigned int (*hb_color_line_get_color_stops_func_t) (hb_color_line_t *color_line,void *color_line_data,unsigned int start,unsigned int *count,hb_color_stop_t *color_stops,void *user_data);
A virtual method for the hb_color_line_t to fetch color stops.
color_line |
a hb_color_line_t object |
|
color_line_data |
the data accompanying |
|
start |
the index of the first color stop to return |
|
count |
Input = the maximum number of feature tags to return; Output = the actual number of feature tags returned (may be zero). |
[inout][optional] |
color_stops |
Array of hb_color_stop_t to populate. |
[out][array length=count][optional] |
user_data |
the data accompanying this method |
Since: 7.0.0
unsigned int hb_color_line_get_color_stops (hb_color_line_t *color_line,unsigned int start,unsigned int *count,hb_color_stop_t *color_stops);
Fetches a list of color stops from the given color line object.
Note that due to variations being applied, the returned color stops may be out of order. It is the callers responsibility to ensure that color stops are sorted by their offset before they are used.
color_line |
a hb_color_line_t object |
|
start |
the index of the first color stop to return |
|
count |
Input = the maximum number of feature tags to return; Output = the actual number of feature tags returned (may be zero). |
[inout][optional] |
color_stops |
Array of hb_color_stop_t to populate. |
[out][array length=count][optional] |
Since: 7.0.0
hb_paint_extend_t (*hb_color_line_get_extend_func_t) (hb_color_line_t *color_line,void *color_line_data,void *user_data);
A virtual method for the hb_color_line_t
to fetches the extend mode.
color_line |
a hb_color_line_t object |
|
color_line_data |
the data accompanying |
|
user_data |
the data accompanying this method |
Since: 7.0.0
hb_paint_extend_t
hb_color_line_get_extend (hb_color_line_t *color_line);
Fetches the extend mode of the color line object.
Since: 7.0.0
void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_color_line_t *color_line,float x0,float y0,float x1,float y1,float x2,float y2,void *user_data);
A virtual method for the hb_paint_funcs_t to paint a linear gradient everywhere within the current clip.
The color_line
object contains information about the colors of the gradients.
It is only valid for the duration of the callback, you cannot keep it around.
The coordinates of the points are interpreted according to the current transform.
See the OpenType spec COLR
section for details on how the points define the direction
of the gradient, and how to interpret the color_line
.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
color_line |
Color information for the gradient |
|
x0 |
X coordinate of the first point |
|
y0 |
Y coordinate of the first point |
|
x1 |
X coordinate of the second point |
|
y1 |
Y coordinate of the second point |
|
x2 |
X coordinate of the third point |
|
y2 |
Y coordinate of the third point |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_linear_gradient_func (hb_paint_funcs_t *funcs,hb_paint_linear_gradient_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the linear-gradient callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The linear-gradient callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_color_line_t *color_line,float x0,float y0,float r0,float x1,float y1,float r1,void *user_data);
A virtual method for the hb_paint_funcs_t to paint a radial gradient everywhere within the current clip.
The color_line
object contains information about the colors of the gradients.
It is only valid for the duration of the callback, you cannot keep it around.
The coordinates of the points are interpreted according to the current transform.
See the OpenType spec COLR
section for details on how the points define the direction
of the gradient, and how to interpret the color_line
.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
color_line |
Color information for the gradient |
|
x0 |
X coordinate of the first circle's center |
|
y0 |
Y coordinate of the first circle's center |
|
r0 |
radius of the first circle |
|
x1 |
X coordinate of the second circle's center |
|
y1 |
Y coordinate of the second circle's center |
|
r1 |
radius of the second circle |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_radial_gradient_func (hb_paint_funcs_t *funcs,hb_paint_radial_gradient_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the radial-gradient callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The radial-gradient callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_sweep_gradient_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_color_line_t *color_line,float x0,float y0,float start_angle,float end_angle,void *user_data);
A virtual method for the hb_paint_funcs_t to paint a sweep gradient everywhere within the current clip.
The color_line
object contains information about the colors of the gradients.
It is only valid for the duration of the callback, you cannot keep it around.
The coordinates of the points are interpreted according to the current transform.
See the OpenType spec COLR
section for details on how the points define the direction
of the gradient, and how to interpret the color_line
.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
color_line |
Color information for the gradient |
|
x0 |
X coordinate of the circle's center |
|
y0 |
Y coordinate of the circle's center |
|
start_angle |
the start angle, in radians |
|
end_angle |
the end angle, in radians |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_sweep_gradient_func (hb_paint_funcs_t *funcs,hb_paint_sweep_gradient_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the sweep-gradient callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The sweep-gradient callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,void *paint_data,void *user_data);
A virtual method for the hb_paint_funcs_t to use an intermediate surface for subsequent paint calls.
The drawing will be redirected to an intermediate surface until a matching call to the hb_paint_funcs_pop_group_func_t vfunc.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_push_group_func (hb_paint_funcs_t *funcs,hb_paint_push_group_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-group callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-group callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
void (*hb_paint_push_group_for_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_paint_composite_mode_t mode,void *user_data);
A virtual method for the hb_paint_funcs_t to use an intermediate surface for subsequent paint calls, with the compositing mode known in advance.
This is like hb_paint_push_group_func_t, but the compositing mode is provided at push time. By default this calls hb_paint_push_group_func_t.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
mode |
the compositing mode that will be used when the group is popped |
|
user_data |
User data pointer passed to |
Since: 14.2.0
void hb_paint_funcs_set_push_group_for_func (hb_paint_funcs_t *funcs,hb_paint_push_group_for_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the push-group-for callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The push-group-for callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 14.2.0
void (*hb_paint_pop_group_func_t) (hb_paint_funcs_t *funcs,void *paint_data,hb_paint_composite_mode_t mode,void *user_data);
A virtual method for the hb_paint_funcs_t to undo the effect of a prior call to the hb_paint_funcs_push_group_func_t vfunc.
This call stops the redirection to the intermediate surface, and then composites it on the previous surface, using the compositing mode passed to this call.
funcs |
paint functions object |
|
paint_data |
The data accompanying the paint functions in |
|
mode |
the compositing mode to use |
|
user_data |
User data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_pop_group_func (hb_paint_funcs_t *funcs,hb_paint_pop_group_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the pop-group callback on the paint functions struct.
funcs |
A paint functions struct |
|
func |
The pop-group callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
Data to pass to |
|
destroy |
Function to call when |
[nullable] |
Since: 7.0.0
hb_bool_t (*hb_paint_custom_palette_color_func_t) (hb_paint_funcs_t *funcs,void *paint_data,unsigned int color_index,hb_color_t *color,void *user_data);
A virtual method for hb_paint_funcs_t to fetch a custom palette override
color for color_index
.
Custom palette colors override colors from the font's selected color palette.
It is not necessary to override all palette entries; return false for
entries that should be taken from the font palette.
This function might be called multiple times, but the custom palette is
expected to remain unchanged for the duration of one
hb_font_paint_glyph() call.
funcs |
paint functions object. |
|
paint_data |
data accompanying the paint functions in |
|
color_index |
color index to fetch. |
|
color |
fetched color. |
[out] |
user_data |
user data pointer passed to |
Since: 7.0.0
void hb_paint_funcs_set_custom_palette_color_func (hb_paint_funcs_t *funcs,hb_paint_custom_palette_color_func_t func,void *user_data,hb_destroy_func_t destroy);
Sets the custom-palette-color callback on funcs
.
funcs |
a paint functions struct. |
|
func |
custom-palette-color callback. |
[closure user_data][destroy destroy][scope notified] |
user_data |
data to pass to |
|
destroy |
function to call when |
[nullable] |
Since: 7.0.0
void hb_paint_push_transform (hb_paint_funcs_t *funcs,void *paint_data,float xx,float yx,float xy,float yy,float dx,float dy);
Perform a "push-transform" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
xx |
xx component of the transform matrix |
|
yx |
yx component of the transform matrix |
|
xy |
xy component of the transform matrix |
|
yy |
yy component of the transform matrix |
|
dx |
dx component of the transform matrix |
|
dy |
dy component of the transform matrix |
Since: 7.0.0
void hb_paint_push_font_transform (hb_paint_funcs_t *funcs,void *paint_data,const hb_font_t *font);
Push the transform reflecting the font's scale and slant settings onto the paint functions.
Since: 11.0.0
void hb_paint_push_inverse_font_transform (hb_paint_funcs_t *funcs,void *paint_data,const hb_font_t *font);
Push the inverse of the transform reflecting the font's scale and slant settings onto the paint functions.
Since: 11.0.0
void hb_paint_pop_transform (hb_paint_funcs_t *funcs,void *paint_data);
Perform a "pop-transform" paint operation.
Since: 7.0.0
hb_bool_t hb_paint_color_glyph (hb_paint_funcs_t *funcs,void *paint_data,hb_codepoint_t glyph,hb_font_t *font);
Perform a "color-glyph" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
glyph |
the glyph ID |
|
font |
the font |
Since: 8.2.0
void hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs,void *paint_data,hb_codepoint_t glyph,hb_font_t *font);
Perform a "push-clip-glyph" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
glyph |
the glyph ID |
|
font |
the font |
Since: 7.0.0
void hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs,void *paint_data,float xmin,float ymin,float xmax,float ymax);
Perform a "push-clip-rect" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
xmin |
min X for the rectangle |
|
ymin |
min Y for the rectangle |
|
xmax |
max X for the rectangle |
|
ymax |
max Y for the rectangle |
Since: 7.0.0
hb_draw_funcs_t * hb_paint_push_clip_path_start (hb_paint_funcs_t *funcs,void *paint_data,void **draw_data);
Begin clipping to an arbitrary path. Returns an
hb_draw_funcs_t owned by the backend (the caller must not
free it) that the caller uses to emit the clip outline via
hb_draw_*() calls, using the returned draw_data
as the
draw data. The returned draw funcs and draw data are only
valid until the matching hb_paint_push_clip_path_end() call;
no other paint calls should be made between start and end
except hb_draw_*() on the returned funcs. Finish the path
with hb_paint_push_clip_path_end(); pop the clip later
with hb_paint_pop_clip().
Usage:
hb_draw_funcs_t *df = hb_paint_push_clip_path_start (pf, pd, &dd); hb_draw_move_to (df, dd, NULL, ...); hb_draw_line_to (df, dd, NULL, ...); ... hb_draw_close_path (df, dd, NULL); hb_paint_push_clip_path_end (pf, pd); /* paint ops here are clipped to the emitted path */ hb_paint_pop_clip (pf, pd);
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
draw_data |
location to receive the draw data the caller should pass alongside the returned draw funcs. |
[out][nullable] |
draw funcs that accumulate
the clip path, or NULL if the backend does not implement
arbitrary-path clipping.
[transfer none]
Since: 14.2.0
void hb_paint_push_clip_path_end (hb_paint_funcs_t *funcs,void *paint_data);
Signal that the arbitrary-clip path started by
hb_paint_push_clip_path_start() is fully drawn. The
accumulated path now acts as a clip on the paint context
until a matching hb_paint_pop_clip() call.
Since: 14.2.0
void hb_paint_pop_clip (hb_paint_funcs_t *funcs,void *paint_data);
Perform a "pop-clip" paint operation.
Since: 7.0.0
void hb_paint_color (hb_paint_funcs_t *funcs,void *paint_data,hb_bool_t is_foreground,hb_color_t color);
Perform a "color" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
is_foreground |
whether the color is the foreground |
|
color |
The color to use |
Since: 7.0.0
void hb_paint_image (hb_paint_funcs_t *funcs,void *paint_data,hb_blob_t *image,unsigned int width,unsigned int height,hb_tag_t format,float slant,hb_glyph_extents_t *extents);
Perform a "image" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
image |
image data |
|
width |
width of the raster image in pixels, or 0 |
|
height |
height of the raster image in pixels, or 0 |
|
format |
the image format as a tag |
|
slant |
Deprecated. set to 0.0 |
|
extents |
the extents of the glyph. |
[nullable] |
Since: 7.0.0
void hb_paint_linear_gradient (hb_paint_funcs_t *funcs,void *paint_data,hb_color_line_t *color_line,float x0,float y0,float x1,float y1,float x2,float y2);
Perform a "linear-gradient" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
color_line |
Color information for the gradient |
|
x0 |
X coordinate of the first point |
|
y0 |
Y coordinate of the first point |
|
x1 |
X coordinate of the second point |
|
y1 |
Y coordinate of the second point |
|
x2 |
X coordinate of the third point |
|
y2 |
Y coordinate of the third point |
Since: 7.0.0
void hb_paint_radial_gradient (hb_paint_funcs_t *funcs,void *paint_data,hb_color_line_t *color_line,float x0,float y0,float r0,float x1,float y1,float r1);
Perform a "radial-gradient" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
color_line |
Color information for the gradient |
|
x0 |
X coordinate of the first circle's center |
|
y0 |
Y coordinate of the first circle's center |
|
r0 |
radius of the first circle |
|
x1 |
X coordinate of the second circle's center |
|
y1 |
Y coordinate of the second circle's center |
|
r1 |
radius of the second circle |
Since: 7.0.0
void hb_paint_sweep_gradient (hb_paint_funcs_t *funcs,void *paint_data,hb_color_line_t *color_line,float x0,float y0,float start_angle,float end_angle);
Perform a "sweep-gradient" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
color_line |
Color information for the gradient |
|
x0 |
X coordinate of the circle's center |
|
y0 |
Y coordinate of the circle's center |
|
start_angle |
the start angle |
|
end_angle |
the end angle |
Since: 7.0.0
void hb_paint_push_group (hb_paint_funcs_t *funcs,void *paint_data);
Perform a "push-group" paint operation.
Since: 7.0.0
void hb_paint_push_group_for (hb_paint_funcs_t *funcs,void *paint_data,hb_paint_composite_mode_t mode);
Perform a "push-group" paint operation, with the compositing
mode known in advance. By default, this calls
hb_paint_push_group().
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
mode |
the compositing mode that will be used when the group is popped |
Since: 14.2.0
void hb_paint_pop_group (hb_paint_funcs_t *funcs,void *paint_data,hb_paint_composite_mode_t mode);
Perform a "pop-group" paint operation.
funcs |
paint functions |
|
paint_data |
associated data passed by the caller |
|
mode |
the compositing mode to use |
Since: 7.0.0
hb_bool_t hb_paint_custom_palette_color (hb_paint_funcs_t *funcs,void *paint_data,unsigned int color_index,hb_color_t *color);
Gets the custom palette override color for color_index
.
funcs |
paint functions. |
|
paint_data |
associated data passed by the caller. |
|
color_index |
color index to fetch. |
|
color |
fetched color. |
[out] |
Since: 7.0.0
void hb_paint_reduce_linear_anchors (float x0,float y0,float x1,float y1,float x2,float y2,float *xx0,float *yy0,float *xx1,float *yy1);
Reduces a COLRv1 linear gradient's 3-anchor spec (P0=color stop 0, P1=color stop 1, P2=rotation reference) to the 2-point axis (P0, P1') used by SVG / cairo / most software renderers. P1' is the foot of P1 on the line through P0 perpendicular to (P2 - P0); the resulting axis is the gradient's actual direction (perpendicular to the rotation line). Degenerate (P0 == P2) passes through unchanged.
x0 |
x coordinate of P0 (color stop 0). |
|
y0 |
y coordinate of P0 (color stop 0). |
|
x1 |
x coordinate of P1 (color stop 1). |
|
y1 |
y coordinate of P1 (color stop 1). |
|
x2 |
x coordinate of P2 (rotation reference). |
|
y2 |
y coordinate of P2 (rotation reference). |
|
xx0 |
x coordinate of the resulting axis start. |
[out] |
yy0 |
y coordinate of the resulting axis start. |
[out] |
xx1 |
x coordinate of the resulting axis end. |
[out] |
yy1 |
y coordinate of the resulting axis end. |
[out] |
Since: 14.2.0
void hb_paint_normalize_color_line (hb_color_stop_t *stops,unsigned int len,float *min,float *max);
Sorts stops
by offset and rescales offsets into [0, 1] in
place. Writes the original (min, max) to min
/ max
so the
caller can shift the gradient geometry (axis endpoints for
linear, centers+radii for radial, start+end angles for sweep)
to keep the rendered gradient visually unchanged after the
rescale. Empty input is safe: both out-parameters set to 0.
stops |
color stops. |
[array length=len][inout] |
len |
number of stops. |
|
min |
original minimum offset. |
[out] |
max |
original maximum offset. |
[out] |
Since: 14.2.0
void (*hb_paint_sweep_gradient_tile_func_t) (float a0,hb_color_t c0,float a1,hb_color_t c1,void *user_data);
Callback invoked once per (a0, a1) sector of a sweep
gradient tiling. See hb_paint_sweep_gradient_tiles().
a0 |
segment start angle, in radians. |
|
c0 |
segment start color. |
|
a1 |
segment end angle, in radians. |
|
c1 |
segment end color. |
|
user_data |
user data passed to |
Since: 14.2.0
void hb_paint_sweep_gradient_tiles (hb_color_stop_t *stops,unsigned int n_stops,hb_paint_extend_t extend,float start_angle,float end_angle,hb_paint_sweep_gradient_tile_func_t emit_patch,void *user_data);
Iterates the full 0..2π sweep produced by a color-stop list,
invoking emit_patch
once per (start, end) angular segment.
Handles HB_PAINT_EXTEND_PAD, HB_PAINT_EXTEND_REPEAT, and
HB_PAINT_EXTEND_REFLECT. Stops must be pre-sorted by
offset; use hb_paint_normalize_color_line() first if they
aren't.
stops |
color stops (sorted, offsets in [0,1]). |
[array length=n_stops][inout] |
n_stops |
number of stops. |
|
extend |
extend mode. |
|
start_angle |
sweep start angle, in radians. |
|
end_angle |
sweep end angle, in radians. |
|
emit_patch |
callback invoked once per tile. |
[scope call] |
user_data |
data passed to |
Since: 14.2.0
typedef struct hb_paint_funcs_t hb_paint_funcs_t;
Glyph paint callbacks.
The callbacks assume that the caller maintains a stack of current transforms, clips and intermediate surfaces, as evidenced by the pairs of push/pop callbacks. The push/pop calls will be properly nested, so it is fine to store the different kinds of object on a single stack.
Not all callbacks are required for all kinds of glyphs. For rendering COLRv0 or non-color outline glyphs, the gradient callbacks are not needed, and the composite callback only needs to handle simple alpha compositing (HB_PAINT_COMPOSITE_MODE_SRC_OVER).
The paint-image callback is only needed for glyphs with image blobs in the CBDT, sbix or SVG tables.
The custom-palette-color callback is only necessary if you want to override colors from the font palette with custom colors.
Since: 7.0.0
#define HB_PAINT_IMAGE_FORMAT_PNG HB_TAG('p','n','g',' ')
Tag identifying PNG images in hb_paint_image_func_t callbacks.
Since: 7.0.0
#define HB_PAINT_IMAGE_FORMAT_SVG HB_TAG('s','v','g',' ')
Tag identifying SVG images in hb_paint_image_func_t callbacks.
Since: 7.0.0
#define HB_PAINT_IMAGE_FORMAT_BGRA HB_TAG('B','G','R','A')
Tag identifying raw pixel-data images in hb_paint_image_func_t callbacks. The data is in BGRA pre-multiplied sRGBA color-space format.
Since: 7.0.0
typedef struct hb_color_line_t hb_color_line_t;
A struct containing color information for a gradient.
Since: 7.0.0
typedef struct {
float offset;
hb_bool_t is_foreground;
hb_color_t color;
} hb_color_stop_t;
Information about a color stop on a color line.
Color lines typically have offsets ranging between 0 and 1, but that is not required.
The is_foreground
and color
fields have the same semantics
as in hb_paint_color_func_t.
Note: despite color
being unpremultiplied here, interpolation in
gradients shall happen in premultiplied space. See the OpenType spec
COLR
section for details.
the offset of the color stop |
||
hb_bool_t |
whether the color is the foreground |
|
hb_color_t |
the color, unpremultiplied |
Since: 7.0.0
The values of this enumeration determine how color values outside the minimum and maximum defined offset on a hb_color_line_t are determined.
See the OpenType spec COLR section for details.
|
Outside the defined interval, the color of the closest color stop is used. |
||
|
The color line is repeated over repeated multiples of the defined interval |
||
|
The color line is repeated over repeated intervals, as for the repeat mode. However, in each repeated interval, the ordering of color stops is the reverse of the adjacent interval. |
Since: 7.0.0
The values of this enumeration describe the compositing modes that can be used when combining temporary redirected drawing with the backdrop.
See the OpenType spec COLR section for details.
|
clear destination layer (bounded) |
||
|
replace destination layer (bounded) |
||
|
ignore the source |
||
|
draw source layer on top of destination layer (bounded) |
||
|
draw destination on top of source |
||
|
draw source where there was destination content (unbounded) |
||
|
leave destination only where there was source content (unbounded) |
||
|
draw source where there was no destination content (unbounded) |
||
|
leave destination only where there was no source content |
||
|
draw source on top of destination content and only there |
||
|
leave destination on top of source content and only there (unbounded) |
||
|
source and destination are shown where there is only one of them |
||
|
source and destination layers are accumulated |
||
|
source and destination are complemented and multiplied. This causes the result to be at least as light as the lighter inputs. |
||
|
multiplies or screens, depending on the lightness of the destination color. |
||
|
replaces the destination with the source if it is darker, otherwise keeps the source. |
||
|
replaces the destination with the source if it is lighter, otherwise keeps the source. |
||
|
brightens the destination color to reflect the source color. |
||
|
darkens the destination color to reflect the source color. |
||
|
Multiplies or screens, dependent on source color. |
||
|
Darkens or lightens, dependent on source color. |
||
|
Takes the difference of the source and destination color. |
||
|
Produces an effect similar to difference, but with lower contrast. |
||
|
source and destination layers are multiplied. This causes the result to be at least as dark as the darker inputs. |
||
|
Creates a color with the hue of the source and the saturation and luminosity of the target. |
||
|
Creates a color with the saturation of the source and the hue and luminosity of the target. Painting with this mode onto a gray area produces no change. |
||
|
Creates a color with the hue and saturation of the source and the luminosity of the target. This preserves the gray levels of the target and is useful for coloring monochrome images or tinting color images. |
||
|
Creates a color with the luminosity of
the source and the hue and saturation of the target. This produces an
inverse effect to |
Since: 7.0.0