[paint] Pass hb_paint_context_t along

Replace the font argument with a hb_paint_context_t
that carries the font, the palette index and the
foreground color.

The hb_font_paint_glyph() api now takes the palette
index and the foreground color as extra arguments.

Update all callers and regenerate test results.
This commit is contained in:
Matthias Clasen 2022-12-21 14:04:32 -05:00 committed by Behdad Esfahbod
parent 6c71c530ca
commit 9be01b6bff
31 changed files with 384 additions and 316 deletions

View File

@ -333,15 +333,21 @@ struct glyf_accelerator_t
return glyph_for_gid (gid).get_extents_without_var_scaled (font, *this, extents); return glyph_for_gid (gid).get_extents_without_var_scaled (font, *this, extents);
} }
bool paint_glyph (hb_font_t *font, hb_codepoint_t gid, hb_paint_funcs_t *funcs, void *data) const bool paint_glyph (hb_font_t *font, hb_codepoint_t gid, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const
{ {
funcs->push_root_transform (data, font); hb_paint_context_t ctx;
funcs->push_clip_glyph (data, gid, font); ctx.font = font;
funcs->color (data, 0xffff, 1., font); ctx.palette = 0;
funcs->pop_clip (data, font); ctx.foreground = foreground;
funcs->pop_root_transform (data, font); funcs->push_root_transform (data, &ctx);
funcs->push_clip_glyph (data, gid, &ctx);
funcs->color (data, 0xffff, 1., &ctx);
funcs->pop_clip (data, &ctx);
funcs->pop_root_transform (data, &ctx);
return false; return false;
} }

View File

@ -519,6 +519,8 @@ hb_font_paint_glyph_nil (hb_font_t *font HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED, hb_codepoint_t glyph HB_UNUSED,
hb_paint_funcs_t *paint_funcs HB_UNUSED, hb_paint_funcs_t *paint_funcs HB_UNUSED,
void *paint_data HB_UNUSED, void *paint_data HB_UNUSED,
unsigned int palette HB_UNUSED,
hb_color_t foreground HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
} }
@ -655,8 +657,16 @@ hb_font_paint_glyph_default (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_paint_funcs_t *paint_funcs, hb_paint_funcs_t *paint_funcs,
void *paint_data, void *paint_data,
unsigned int palette,
hb_color_t foreground,
void *user_data) void *user_data)
{ {
hb_paint_context_t ctx;
ctx.font = font;
ctx.palette = palette;
ctx.foreground = foreground;
paint_funcs->push_transform (paint_data, paint_funcs->push_transform (paint_data,
font->parent->x_scale ? (float) font->x_scale / (float) font->parent->x_scale : 0.f, font->parent->x_scale ? (float) font->x_scale / (float) font->parent->x_scale : 0.f,
font->parent->y_scale ? (font->slant - font->parent->slant) * font->parent->y_scale ? (font->slant - font->parent->slant) *
@ -665,11 +675,11 @@ hb_font_paint_glyph_default (hb_font_t *font,
font->parent->y_scale ? (float) font->y_scale / (float) font->parent->y_scale : 0.f, font->parent->y_scale ? (float) font->y_scale / (float) font->parent->y_scale : 0.f,
0.f, 0.f,
0.f, 0.f,
font); &ctx);
font->parent->paint_glyph (glyph, paint_funcs, paint_data); font->parent->paint_glyph (glyph, paint_funcs, paint_data, palette, foreground);
paint_funcs->pop_transform (paint_data, font); paint_funcs->pop_transform (paint_data, &ctx);
} }
DEFINE_NULL_INSTANCE (hb_font_funcs_t) = DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
@ -1427,6 +1437,8 @@ hb_font_draw_glyph (hb_font_t *font,
* @glyph: The glyph ID * @glyph: The glyph ID
* @pfuncs: #hb_paint_funcs_t to paint with * @pfuncs: #hb_paint_funcs_t to paint with
* @paint_data: User data to pass to paint callbacks * @paint_data: User data to pass to paint callbacks
* @palette: The palette index to use
* @foreground: The foreground color
* *
* Paints the glyph. * Paints the glyph.
* *
@ -1442,9 +1454,11 @@ hb_font_draw_glyph (hb_font_t *font,
void void
hb_font_paint_glyph (hb_font_t *font, hb_font_paint_glyph (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_paint_funcs_t *pfuncs, void *paint_data) hb_paint_funcs_t *pfuncs, void *paint_data,
unsigned int palette,
hb_color_t foreground)
{ {
font->paint_glyph (glyph, pfuncs, paint_data); font->paint_glyph (glyph, pfuncs, paint_data, palette, foreground);
} }
/* A bit higher-level, and with fallback */ /* A bit higher-level, and with fallback */

View File

@ -529,6 +529,8 @@ typedef void (*hb_font_draw_glyph_func_t) (hb_font_t *font, void *font_data,
* @glyph: The glyph ID to query * @glyph: The glyph ID to query
* @paint_funcs: The paint functions to use * @paint_funcs: The paint functions to use
* @paint_data: The data accompanying the paint functions * @paint_data: The data accompanying the paint functions
* @palette: The color palette to use
* @foreground: The foreground color
* @user_data: User data pointer passed by the caller * @user_data: User data pointer passed by the caller
* *
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
@ -538,6 +540,8 @@ typedef void (*hb_font_draw_glyph_func_t) (hb_font_t *font, void *font_data,
typedef void (*hb_font_paint_glyph_func_t) (hb_font_t *font, void *font_data, typedef void (*hb_font_paint_glyph_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_paint_funcs_t *paint_funcs, void *paint_data, hb_paint_funcs_t *paint_funcs, void *paint_data,
unsigned int palette,
hb_color_t foreground,
void *user_data); void *user_data);
/* func setters */ /* func setters */
@ -941,8 +945,9 @@ hb_font_draw_glyph (hb_font_t *font,
HB_EXTERN void HB_EXTERN void
hb_font_paint_glyph (hb_font_t *font, hb_font_paint_glyph (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_paint_funcs_t *pfuncs, void *paint_data); hb_paint_funcs_t *pfuncs, void *paint_data,
unsigned int palette,
hb_color_t foreground);
/* high-level funcs, with fallback */ /* high-level funcs, with fallback */

View File

@ -403,11 +403,14 @@ struct hb_font_t
} }
void paint_glyph (hb_codepoint_t glyph, void paint_glyph (hb_codepoint_t glyph,
hb_paint_funcs_t *paint_funcs, void *paint_data) hb_paint_funcs_t *paint_funcs, void *paint_data,
unsigned int palette,
hb_color_t foreground)
{ {
klass->get.f.paint_glyph (this, user_data, klass->get.f.paint_glyph (this, user_data,
glyph, glyph,
paint_funcs, paint_data, paint_funcs, paint_data,
palette, foreground,
!klass->user_data ? nullptr : klass->user_data->paint_glyph); !klass->user_data ? nullptr : klass->user_data->paint_glyph);
} }

View File

@ -553,15 +553,20 @@ bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoin
return true; return true;
} }
bool OT::cff1::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const bool OT::cff1::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const
{ {
funcs->push_root_transform (data, font); hb_paint_context_t ctx;
funcs->push_clip_glyph (data, glyph, font); ctx.font = font;
funcs->color (data, 0xffff, 1., font); ctx.palette = 0;
funcs->pop_clip (data, font); ctx.foreground = foreground;
funcs->push_root_transform (data, &ctx);
funcs->pop_root_transform (data, font); funcs->push_clip_glyph (data, glyph, &ctx);
funcs->color (data, 0xffff, 1., &ctx);
funcs->pop_clip (data, &ctx);
funcs->pop_root_transform (data, &ctx);
return false; return false;
} }

View File

@ -1427,7 +1427,7 @@ struct cff1
} }
HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const; HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const;
HB_INTERNAL bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const; HB_INTERNAL bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const;
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const; HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session) const; HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session) const;

View File

@ -143,15 +143,21 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
return true; return true;
} }
bool OT::cff2::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const bool OT::cff2::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const
{ {
funcs->push_root_transform (data, font); hb_paint_context_t ctx;
funcs->push_clip_glyph (data, glyph, font); ctx.font = font;
funcs->color (data, 0xffff, 1., font); ctx.palette = 0;
funcs->pop_clip (data, font); ctx.foreground = foreground;
funcs->pop_root_transform (data, font); funcs->push_root_transform (data, &ctx);
funcs->push_clip_glyph (data, glyph, &ctx);
funcs->color (data, 0xffff, 1., &ctx);
funcs->pop_clip (data, &ctx);
funcs->pop_root_transform (data, &ctx);
return false; return false;
} }

View File

@ -517,7 +517,7 @@ struct cff2
HB_INTERNAL bool get_extents (hb_font_t *font, HB_INTERNAL bool get_extents (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents) const; hb_glyph_extents_t *extents) const;
HB_INTERNAL bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const; HB_INTERNAL bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const;
HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session) const; HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session) const;
}; };

View File

@ -939,15 +939,21 @@ struct CBDT
bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const
{ {
hb_paint_context_t ctx;
hb_glyph_extents_t extents; hb_glyph_extents_t extents;
hb_blob_t *blob = reference_png (font, glyph); hb_blob_t *blob = reference_png (font, glyph);
if (unlikely (blob == hb_blob_get_empty ())) if (unlikely (blob == hb_blob_get_empty ()))
return false; return false;
if (unlikely (!hb_font_get_glyph_extents (font, glyph, &extents))) if (unlikely (!hb_font_get_glyph_extents (font, glyph, &extents)))
return false; return false;
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents, font); ctx.font = font;
ctx.palette = 0;
ctx.foreground = HB_COLOR (0, 0, 0, 255);
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents, &ctx);
hb_blob_destroy (blob); hb_blob_destroy (blob);
return true; return true;

View File

@ -8,9 +8,9 @@ void PaintColrLayers::paint_glyph (hb_ot_paint_context_t *c) const
for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++) for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++)
{ {
const Paint &paint = paint_offset_lists.get_paint (i); const Paint &paint = paint_offset_lists.get_paint (i);
c->funcs->push_group (c->data, c->font); c->funcs->push_group (c->data, &c->ctx);
c->recurse (paint); c->recurse (paint);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER, c->font); c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER, &c->ctx);
} }
} }

View File

@ -75,7 +75,7 @@ public:
const void *base; const void *base;
hb_paint_funcs_t *funcs; hb_paint_funcs_t *funcs;
void *data; void *data;
hb_font_t *font; hb_paint_context_t ctx;
VarStoreInstancer &instancer; VarStoreInstancer &instancer;
int depth_left = HB_COLRV1_MAX_NESTING_LEVEL; int depth_left = HB_COLRV1_MAX_NESTING_LEVEL;
@ -83,13 +83,16 @@ public:
hb_paint_funcs_t *funcs_, hb_paint_funcs_t *funcs_,
void *data_, void *data_,
hb_font_t *font_, hb_font_t *font_,
unsigned int palette,
hb_color_t foreground,
VarStoreInstancer &instancer_) : VarStoreInstancer &instancer_) :
base (base_), base (base_),
funcs (funcs_), funcs (funcs_),
data (data_), data (data_),
font (font_),
instancer (instancer_) instancer (instancer_)
{} { ctx.font = font_;
ctx.palette = palette;
ctx.foreground = foreground; }
inline void recurse (const Paint &paint); inline void recurse (const Paint &paint);
}; };
@ -486,7 +489,7 @@ struct Affine2x3
yy.to_float (c->instancer (varIdxBase, 3)), yy.to_float (c->instancer (varIdxBase, 3)),
dx.to_float (c->instancer (varIdxBase, 4)), dx.to_float (c->instancer (varIdxBase, 4)),
dy.to_float (c->instancer (varIdxBase, 5)), dy.to_float (c->instancer (varIdxBase, 5)),
c->font); &c->ctx);
} }
F16DOT16 xx; F16DOT16 xx;
@ -554,7 +557,7 @@ struct PaintSolid
c->funcs->color (c->data, c->funcs->color (c->data,
paletteIndex, paletteIndex,
alpha.to_float (c->instancer (varIdxBase, 0)), alpha.to_float (c->instancer (varIdxBase, 0)),
c->font); &c->ctx);
} }
HBUINT8 format; /* format = 2(noVar) or 3(Var)*/ HBUINT8 format; /* format = 2(noVar) or 3(Var)*/
@ -596,7 +599,7 @@ struct PaintLinearGradient
y1 + c->instancer (varIdxBase, 3), y1 + c->instancer (varIdxBase, 3),
x2 + c->instancer (varIdxBase, 4), x2 + c->instancer (varIdxBase, 4),
y2 + c->instancer (varIdxBase, 5), y2 + c->instancer (varIdxBase, 5),
c->font); &c->ctx);
} }
HBUINT8 format; /* format = 4(noVar) or 5 (Var) */ HBUINT8 format; /* format = 4(noVar) or 5 (Var) */
@ -644,7 +647,7 @@ struct PaintRadialGradient
x1 + c->instancer (varIdxBase, 3), x1 + c->instancer (varIdxBase, 3),
y1 + c->instancer (varIdxBase, 4), y1 + c->instancer (varIdxBase, 4),
radius1 + c->instancer (varIdxBase, 5), radius1 + c->instancer (varIdxBase, 5),
c->font); &c->ctx);
} }
HBUINT8 format; /* format = 6(noVar) or 7 (Var) */ HBUINT8 format; /* format = 6(noVar) or 7 (Var) */
@ -690,7 +693,7 @@ struct PaintSweepGradient
centerY + c->instancer (varIdxBase, 1), centerY + c->instancer (varIdxBase, 1),
(startAngle.to_float (c->instancer (varIdxBase, 2)) + 1) * (float) M_PI, (startAngle.to_float (c->instancer (varIdxBase, 2)) + 1) * (float) M_PI,
(endAngle.to_float (c->instancer (varIdxBase, 3)) + 1) * (float) M_PI, (endAngle.to_float (c->instancer (varIdxBase, 3)) + 1) * (float) M_PI,
c->font); &c->ctx);
} }
HBUINT8 format; /* format = 8(noVar) or 9 (Var) */ HBUINT8 format; /* format = 8(noVar) or 9 (Var) */
@ -730,11 +733,11 @@ struct PaintGlyph
void paint_glyph (hb_ot_paint_context_t *c) const void paint_glyph (hb_ot_paint_context_t *c) const
{ {
c->funcs->push_inverse_root_transform (c->data, c->font); c->funcs->push_inverse_root_transform (c->data, &c->ctx);
c->funcs->push_clip_glyph (c->data, gid, c->font); c->funcs->push_clip_glyph (c->data, gid, &c->ctx);
c->recurse (this+paint); c->recurse (this+paint);
c->funcs->pop_clip (c->data, c->font); c->funcs->pop_clip (c->data, &c->ctx);
c->funcs->pop_inverse_root_transform (c->data, c->font); c->funcs->pop_inverse_root_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 10 */ HBUINT8 format; /* format = 10 */
@ -798,7 +801,7 @@ struct PaintTransform
{ {
(this+transform).paint_glyph (c); (this+transform).paint_glyph (c);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 12(noVar) or 13 (Var) */ HBUINT8 format; /* format = 12(noVar) or 13 (Var) */
@ -833,9 +836,9 @@ struct PaintTranslate
1., 0., 0., 1., 1., 0., 0., 1.,
dx + c->instancer (varIdxBase, 0), dx + c->instancer (varIdxBase, 0),
dy + c->instancer (varIdxBase, 0), dy + c->instancer (varIdxBase, 0),
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 14(noVar) or 15 (Var) */ HBUINT8 format; /* format = 14(noVar) or 15 (Var) */
@ -872,9 +875,9 @@ struct PaintScale
0., 0., 0., 0.,
scaleY.to_float (c->instancer (varIdxBase, 1)), scaleY.to_float (c->instancer (varIdxBase, 1)),
0., 0., 0., 0.,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 16 (noVar) or 17(Var) */ HBUINT8 format; /* format = 16 (noVar) or 17(Var) */
@ -909,19 +912,19 @@ struct PaintScaleAroundCenter
float tCenterX = centerX + c->instancer (varIdxBase, 2); float tCenterX = centerX + c->instancer (varIdxBase, 2);
float tCenterY = centerY + c->instancer (varIdxBase, 3); float tCenterY = centerY + c->instancer (varIdxBase, 3);
c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY,
c->font); &c->ctx);
c->funcs->push_transform (c->data, c->funcs->push_transform (c->data,
scaleX.to_float (c->instancer (varIdxBase, 0)), scaleX.to_float (c->instancer (varIdxBase, 0)),
0., 0., 0., 0.,
scaleY.to_float (c->instancer (varIdxBase, 1)), scaleY.to_float (c->instancer (varIdxBase, 1)),
0., 0., 0., 0.,
c->font); &c->ctx);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 18 (noVar) or 19(Var) */ HBUINT8 format; /* format = 18 (noVar) or 19(Var) */
@ -957,9 +960,9 @@ struct PaintScaleUniform
{ {
float s = scale + c->instancer (varIdxBase, 0); float s = scale + c->instancer (varIdxBase, 0);
c->funcs->push_transform (c->data, s, 0., 0., s, 0., 0., c->funcs->push_transform (c->data, s, 0., 0., s, 0., 0.,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 20 (noVar) or 21(Var) */ HBUINT8 format; /* format = 20 (noVar) or 21(Var) */
@ -994,15 +997,15 @@ struct PaintScaleUniformAroundCenter
float tCenterX = centerX + c->instancer (varIdxBase, 1); float tCenterX = centerX + c->instancer (varIdxBase, 1);
float tCenterY = centerY + c->instancer (varIdxBase, 2); float tCenterY = centerY + c->instancer (varIdxBase, 2);
c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY,
c->font); &c->ctx);
c->funcs->push_transform (c->data, s, 0., 0., s, 0., 0., c->funcs->push_transform (c->data, s, 0., 0., s, 0., 0.,
c->font); &c->ctx);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 22 (noVar) or 23(Var) */ HBUINT8 format; /* format = 22 (noVar) or 23(Var) */
@ -1039,9 +1042,9 @@ struct PaintRotate
float cc = cosf (a * (float) M_PI); float cc = cosf (a * (float) M_PI);
float ss = sinf (a * (float) M_PI); float ss = sinf (a * (float) M_PI);
c->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0., c->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0.,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 24 (noVar) or 25(Var) */ HBUINT8 format; /* format = 24 (noVar) or 25(Var) */
@ -1078,15 +1081,15 @@ struct PaintRotateAroundCenter
float tCenterX = centerX + c->instancer (varIdxBase, 1); float tCenterX = centerX + c->instancer (varIdxBase, 1);
float tCenterY = centerY + c->instancer (varIdxBase, 2); float tCenterY = centerY + c->instancer (varIdxBase, 2);
c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY,
c->font); &c->ctx);
c->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0., c->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0.,
c->font); &c->ctx);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 26 (noVar) or 27(Var) */ HBUINT8 format; /* format = 26 (noVar) or 27(Var) */
@ -1122,9 +1125,9 @@ struct PaintSkew
float x = +tanf (xSkewAngle.to_float(c->instancer (varIdxBase, 0)) * (float) M_PI); float x = +tanf (xSkewAngle.to_float(c->instancer (varIdxBase, 0)) * (float) M_PI);
float y = -tanf (ySkewAngle.to_float(c->instancer (varIdxBase, 1)) * (float) M_PI); float y = -tanf (ySkewAngle.to_float(c->instancer (varIdxBase, 1)) * (float) M_PI);
c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0., c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0.,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 28(noVar) or 29 (Var) */ HBUINT8 format; /* format = 28(noVar) or 29 (Var) */
@ -1161,15 +1164,15 @@ struct PaintSkewAroundCenter
float tCenterX = centerX + c->instancer (varIdxBase, 2); float tCenterX = centerX + c->instancer (varIdxBase, 2);
float tCenterY = centerY + c->instancer (varIdxBase, 3); float tCenterY = centerY + c->instancer (varIdxBase, 3);
c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., +tCenterX, +tCenterY,
c->font); &c->ctx);
c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0., c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0.,
c->font); &c->ctx);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY, c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font); &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
c->funcs->pop_transform (c->data, c->font); c->funcs->pop_transform (c->data, &c->ctx);
} }
HBUINT8 format; /* format = 30(noVar) or 31 (Var) */ HBUINT8 format; /* format = 30(noVar) or 31 (Var) */
@ -1206,12 +1209,12 @@ struct PaintComposite
void paint_glyph (hb_ot_paint_context_t *c) const void paint_glyph (hb_ot_paint_context_t *c) const
{ {
c->funcs->push_group (c->data, c->font); c->funcs->push_group (c->data, &c->ctx);
c->recurse (this+backdrop); c->recurse (this+backdrop);
c->funcs->push_group (c->data, c->font); c->funcs->push_group (c->data, &c->ctx);
c->recurse (this+src); c->recurse (this+src);
c->funcs->pop_group (c->data, (hb_paint_composite_mode_t) (int) mode, c->font); c->funcs->pop_group (c->data, (hb_paint_composite_mode_t) (int) mode, &c->ctx);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER, c->font); c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER, &c->ctx);
} }
HBUINT8 format; /* format = 32 */ HBUINT8 format; /* format = 32 */
@ -1960,23 +1963,23 @@ struct COLR
} }
bool bool
paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, unsigned int palette, hb_color_t foreground) const
{ {
VarStoreInstancer instancer (this+varStore, VarStoreInstancer instancer (this+varStore,
this+varIdxMap, this+varIdxMap,
hb_array (font->coords, font->num_coords)); hb_array (font->coords, font->num_coords));
hb_ot_paint_context_t c (this, funcs, data, font, instancer); hb_ot_paint_context_t c (this, funcs, data, font, palette, foreground, instancer);
const Paint *paint = get_base_glyph_paint (glyph); const Paint *paint = get_base_glyph_paint (glyph);
if (paint) if (paint)
{ {
// COLRv1 glyph // COLRv1 glyph
c.funcs->push_root_transform (c.data, c.font); c.funcs->push_root_transform (c.data, &c.ctx);
c.recurse (*paint); c.recurse (*paint);
c.funcs->pop_root_transform (c.data, c.font); c.funcs->pop_root_transform (c.data, &c.ctx);
return true; return true;
} }
@ -1988,9 +1991,9 @@ struct COLR
for (const auto &r : (this+layersZ).as_array (numLayers) for (const auto &r : (this+layersZ).as_array (numLayers)
.sub_array (record->firstLayerIdx, record->numLayers)) .sub_array (record->firstLayerIdx, record->numLayers))
{ {
c.funcs->push_clip_glyph (c.data, r.glyphId, c.font); c.funcs->push_clip_glyph (c.data, r.glyphId, &c.ctx);
c.funcs->color (c.data, r.colorIdx, 1., c.font); c.funcs->color (c.data, r.colorIdx, 1., &c.ctx);
c.funcs->pop_clip (c.data, c.font); c.funcs->pop_clip (c.data, &c.ctx);
} }
return true; return true;

View File

@ -234,6 +234,7 @@ struct sbix
bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const
{ {
hb_paint_context_t ctx = { font, 0, HB_COLOR (0, 0, 0, 255) };
if (!has_data ()) if (!has_data ())
return false; return false;
@ -248,7 +249,7 @@ struct sbix
if (!hb_font_get_glyph_extents (font, glyph, &extents)) if (!hb_font_get_glyph_extents (font, glyph, &extents))
return false; return false;
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents, font); funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents, &ctx);
hb_blob_destroy (blob); hb_blob_destroy (blob);
return true; return true;

View File

@ -95,6 +95,8 @@ struct SVG
bool paint_glyph (hb_font_t *font HB_UNUSED, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const bool paint_glyph (hb_font_t *font HB_UNUSED, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const
{ {
hb_paint_context_t ctx = { font, 0, HB_COLOR (0, 0, 0, 255) };
if (!has_data ()) if (!has_data ())
return false; return false;
@ -103,7 +105,7 @@ struct SVG
if (blob == hb_blob_get_empty ()) if (blob == hb_blob_get_empty ())
return false; return false;
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_SVG, nullptr, font); funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_SVG, nullptr, &ctx);
hb_blob_destroy (blob); hb_blob_destroy (blob);
return true; return true;

View File

@ -446,20 +446,22 @@ hb_ot_paint_glyph (hb_font_t *font,
void *font_data, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_paint_funcs_t *paint_funcs, void *paint_data, hb_paint_funcs_t *paint_funcs, void *paint_data,
unsigned int palette,
hb_color_t foreground,
void *user_data) void *user_data)
{ {
#ifndef HB_NO_COLOR #ifndef HB_NO_COLOR
if (font->face->table.COLR->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.COLR->paint_glyph (font, glyph, paint_funcs, paint_data, palette, foreground)) return;
if (font->face->table.SVG->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.SVG->paint_glyph (font, glyph, paint_funcs, paint_data)) return;
#ifndef HB_NO_OT_FONT_BITMAP #ifndef HB_NO_OT_FONT_BITMAP
if (font->face->table.CBDT->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.CBDT->paint_glyph (font, glyph, paint_funcs, paint_data)) return;
if (font->face->table.sbix->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.sbix->paint_glyph (font, glyph, paint_funcs, paint_data)) return;
#endif #endif
#endif #endif
if (font->face->table.glyf->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.glyf->paint_glyph (font, glyph, paint_funcs, paint_data, foreground)) return;
#ifndef HB_NO_CFF #ifndef HB_NO_CFF
if (font->face->table.cff1->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.cff1->paint_glyph (font, glyph, paint_funcs, paint_data, foreground)) return;
if (font->face->table.cff2->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.cff2->paint_glyph (font, glyph, paint_funcs, paint_data, foreground)) return;
#endif #endif
} }
#endif #endif

View File

@ -47,36 +47,36 @@ hb_paint_push_transform_nil (hb_paint_funcs_t *funcs, void *paint_data,
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_pop_transform_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_transform_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_push_clip_glyph_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_clip_glyph_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_push_clip_rectangle_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_clip_rectangle_nil (hb_paint_funcs_t *funcs, void *paint_data,
float xmin, float ymin, float xmax, float ymax, float xmin, float ymin, float xmax, float ymax,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_pop_clip_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_clip_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_color_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_color_nil (hb_paint_funcs_t *funcs, void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
@ -84,7 +84,7 @@ hb_paint_image_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_blob_t *image, hb_blob_t *image,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
@ -93,7 +93,7 @@ hb_paint_linear_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
@ -101,7 +101,7 @@ hb_paint_radial_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1, float x1, float y1, float r1,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
@ -110,18 +110,18 @@ hb_paint_sweep_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0, float x0, float y0,
float start_angle, float start_angle,
float end_angle, float end_angle,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_push_group_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_group_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static void static void
hb_paint_pop_group_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_group_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) {} void *user_data) {}
static bool static bool
@ -394,7 +394,7 @@ hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs)
* @yy: yy component of the transform matrix * @yy: yy component of the transform matrix
* @dx: dx component of the transform matrix * @dx: dx component of the transform matrix
* @dy: dy component of the transform matrix * @dy: dy component of the transform matrix
* @font: the font * @ctx: the paint context
* *
* Perform a "push-transform" paint operation. * Perform a "push-transform" paint operation.
* *
@ -405,16 +405,16 @@ hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->push_transform (paint_data, xx, yx, xy, yy, dx, dy, font); funcs->push_transform (paint_data, xx, yx, xy, yy, dx, dy, ctx);
} }
/** /**
* hb_paint_pop_transform: * hb_paint_pop_transform:
* @funcs: paint functions * @funcs: paint functions
* @paint_data: associated data passed by the caller * @paint_data: associated data passed by the caller
* @font: the font * @ctx: the paint context
* *
* Perform a "pop-transform" paint operation. * Perform a "pop-transform" paint operation.
* *
@ -422,9 +422,9 @@ hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
*/ */
void void
hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->pop_transform (paint_data, font); funcs->pop_transform (paint_data, ctx);
} }
/** /**
@ -432,7 +432,7 @@ hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data,
* @funcs: paint functions * @funcs: paint functions
* @paint_data: associated data passed by the caller * @paint_data: associated data passed by the caller
* @glyph: the glyph ID * @glyph: the glyph ID
* @font: the font * @ctx: the paint context
* *
* Perform a "push-clip-glyph" paint operation. * Perform a "push-clip-glyph" paint operation.
* *
@ -441,9 +441,9 @@ hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data,
void void
hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->push_clip_glyph (paint_data, glyph, font); funcs->push_clip_glyph (paint_data, glyph, ctx);
} }
/** /**
@ -454,7 +454,7 @@ hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
* @ymin: min Y for the rectangle * @ymin: min Y for the rectangle
* @xmax: max X for the rectangle * @xmax: max X for the rectangle
* @ymax: max Y for the rectangle * @ymax: max Y for the rectangle
* @font: the font * @ctx: the paint context
* *
* Perform a "push-clip-rect" paint operation. * Perform a "push-clip-rect" paint operation.
* *
@ -463,16 +463,16 @@ hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
void void
hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data,
float xmin, float ymin, float xmax, float ymax, float xmin, float ymin, float xmax, float ymax,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->push_clip_rectangle (paint_data, xmin, ymin, xmax, ymax, font); funcs->push_clip_rectangle (paint_data, xmin, ymin, xmax, ymax, ctx);
} }
/** /**
* hb_paint_pop_clip: * hb_paint_pop_clip:
* @funcs: paint functions * @funcs: paint functions
* @paint_data: associated data passed by the caller * @paint_data: associated data passed by the caller
* @font: the font * @ctx: the paint context
* *
* Perform a "pop-clip" paint operation. * Perform a "pop-clip" paint operation.
* *
@ -480,18 +480,18 @@ hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data,
*/ */
void void
hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->pop_clip (paint_data, font); funcs->pop_clip (paint_data, ctx);
} }
/** /**
* hb_paint_color: * hb_paint_color:
* @funcs: paint functions * @funcs: paint functions
* @paint_data: associated data passed by the caller * @paint_data: associated data passed by the caller
* @color_index: Index of a color in the fonts selected color palette * @color_index: Index of a color in the color palette
* @alpha: Alpha to apply in addition * @alpha: Alpha to apply in addition
* @font: the font * @ctx: the paint context
* *
* Perform a "color" paint operation. * Perform a "color" paint operation.
* *
@ -501,9 +501,9 @@ void
hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->color (paint_data, color_index, alpha, font); funcs->color (paint_data, color_index, alpha, ctx);
} }
/** /**
@ -513,7 +513,7 @@ hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
* @image: image data * @image: image data
* @format: tag describing the image data format * @format: tag describing the image data format
* @extents: (nullable): the extents of the glyph * @extents: (nullable): the extents of the glyph
* @font: the font * @ctx: the paint context
* *
* Perform a "image" paint operation. * Perform a "image" paint operation.
* *
@ -524,9 +524,9 @@ hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
hb_blob_t *image, hb_blob_t *image,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->image (paint_data, image, format, extents, font); funcs->image (paint_data, image, format, extents, ctx);
} }
/** /**
@ -540,7 +540,7 @@ hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
* @y1: Y coordinate of the second point * @y1: Y coordinate of the second point
* @x2: X coordinate of the third point * @x2: X coordinate of the third point
* @y2: Y coordinate of the third point * @y2: Y coordinate of the third point
* @font: the font * @ctx: the paint context
* *
* Perform a "linear-gradient" paint operation. * Perform a "linear-gradient" paint operation.
* *
@ -552,9 +552,9 @@ hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->linear_gradient (paint_data, color_line, x0, y0, x1, y1, x2, y2, font); funcs->linear_gradient (paint_data, color_line, x0, y0, x1, y1, x2, y2, ctx);
} }
/** /**
@ -568,7 +568,7 @@ hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
* @x1: X coordinate of the second circle's center * @x1: X coordinate of the second circle's center
* @y1: Y coordinate of the second circle's center * @y1: Y coordinate of the second circle's center
* @r1: radius of the second circle * @r1: radius of the second circle
* @font: the font * @ctx: the paint context
* *
* Perform a "radial-gradient" paint operation. * Perform a "radial-gradient" paint operation.
* *
@ -579,9 +579,9 @@ hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1, float x1, float y1, float r1,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->radial_gradient (paint_data, color_line, x0, y0, r0, y1, x1, r1, font); funcs->radial_gradient (paint_data, color_line, x0, y0, r0, y1, x1, r1, ctx);
} }
/** /**
@ -593,7 +593,7 @@ hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
* @y0: Y coordinate of the circle's center * @y0: Y coordinate of the circle's center
* @start_angle: the start angle * @start_angle: the start angle
* @end_angle: the end angle * @end_angle: the end angle
* @font: the font * @ctx: the paint context
* *
* Perform a "sweep-gradient" paint operation. * Perform a "sweep-gradient" paint operation.
* *
@ -604,16 +604,16 @@ hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float start_angle, float end_angle, float start_angle, float end_angle,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->sweep_gradient (paint_data, color_line, x0, y0, start_angle, end_angle, font); funcs->sweep_gradient (paint_data, color_line, x0, y0, start_angle, end_angle, ctx);
} }
/** /**
* hb_paint_push_group: * hb_paint_push_group:
* @funcs: paint functions * @funcs: paint functions
* @paint_data: associated data passed by the caller * @paint_data: associated data passed by the caller
* @font: the font * @ctx: the paint context
* *
* Perform a "push-group" paint operation. * Perform a "push-group" paint operation.
* *
@ -621,9 +621,9 @@ hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
*/ */
void void
hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->push_group (paint_data, font); funcs->push_group (paint_data, ctx);
} }
/** /**
@ -631,7 +631,7 @@ hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data,
* @funcs: paint functions * @funcs: paint functions
* @paint_data: associated data passed by the caller * @paint_data: associated data passed by the caller
* @mode: the compositing mode to use * @mode: the compositing mode to use
* @font: the font * @ctx: the paint context
* *
* Perform a "pop-group" paint operation. * Perform a "pop-group" paint operation.
* *
@ -640,9 +640,9 @@ hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data,
void void
hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
funcs->pop_group (paint_data, mode, font); funcs->pop_group (paint_data, mode, ctx);
} }
#endif #endif

View File

@ -91,6 +91,29 @@ hb_paint_funcs_make_immutable (hb_paint_funcs_t *funcs);
HB_EXTERN hb_bool_t HB_EXTERN hb_bool_t
hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs); hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs);
/**
* hb_paint_context_t:
* @font: the font that is painted with
* @palette: the palette index
* @foreground: the foreground color
*
* Context information that is passed to paint functions.
*/
typedef struct hb_paint_context_t {
hb_font_t *font;
unsigned int palette;
hb_color_t foreground;
/*< private >*/
hb_var_num_t reserved1;
hb_var_num_t reserved2;
hb_var_num_t reserved3;
hb_var_num_t reserved4;
hb_var_num_t reserved5;
hb_var_num_t reserved6;
hb_var_num_t reserved7;
} hb_paint_context_t;
/** /**
* hb_paint_push_transform_func_t: * hb_paint_push_transform_func_t:
* @funcs: paint functions object * @funcs: paint functions object
@ -101,7 +124,7 @@ hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs);
* @yy: yy component of the transform matrix * @yy: yy component of the transform matrix
* @dx: dx component of the transform matrix * @dx: dx component of the transform matrix
* @dy: dy component of the transform matrix * @dy: dy component of the transform matrix
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_push_transform_func() * @user_data: User data pointer passed to hb_paint_funcs_set_push_transform_func()
* *
* A virtual method for the #hb_paint_funcs_t to apply * A virtual method for the #hb_paint_funcs_t to apply
@ -118,14 +141,14 @@ typedef void (*hb_paint_push_transform_func_t) (hb_paint_funcs_t *funcs,
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
* hb_paint_pop_transform_func_t: * hb_paint_pop_transform_func_t:
* @funcs: paint functions object * @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph() * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_pop_transform_func() * @user_data: User data pointer passed to hb_paint_funcs_set_pop_transform_func()
* *
* A virtual method for the #hb_paint_funcs_t to undo * A virtual method for the #hb_paint_funcs_t to undo
@ -136,7 +159,7 @@ typedef void (*hb_paint_push_transform_func_t) (hb_paint_funcs_t *funcs,
*/ */
typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs, typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -144,7 +167,7 @@ typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,
* @funcs: paint functions object * @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph() * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @glyph: the glyph ID * @glyph: the glyph ID
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_glyph_func() * @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_glyph_func()
* *
* A virtual method for the #hb_paint_funcs_t to clip * A virtual method for the #hb_paint_funcs_t to clip
@ -162,7 +185,7 @@ typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,
typedef void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs, typedef void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -173,7 +196,7 @@ typedef void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs,
* @ymin: min Y for the rectangle * @ymin: min Y for the rectangle
* @xmax: max X for the rectangle * @xmax: max X for the rectangle
* @ymax: max Y for the rectangle * @ymax: max Y for the rectangle
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_rectangle_func() * @user_data: User data pointer passed to hb_paint_funcs_set_push_clip_rectangle_func()
* *
* A virtual method for the #hb_paint_funcs_t to clip * A virtual method for the #hb_paint_funcs_t to clip
@ -192,14 +215,14 @@ typedef void (*hb_paint_push_clip_rectangle_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
float xmin, float ymin, float xmin, float ymin,
float xmax, float ymax, float xmax, float ymax,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
* hb_paint_pop_clip_func_t: * hb_paint_pop_clip_func_t:
* @funcs: paint functions object * @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph() * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_pop_clip_func() * @user_data: User data pointer passed to hb_paint_funcs_set_pop_clip_func()
* *
* A virtual method for the #hb_paint_funcs_t to undo * A virtual method for the #hb_paint_funcs_t to undo
@ -210,7 +233,7 @@ typedef void (*hb_paint_push_clip_rectangle_func_t) (hb_paint_funcs_t *funcs,
*/ */
typedef void (*hb_paint_pop_clip_func_t) (hb_paint_funcs_t *funcs, typedef void (*hb_paint_pop_clip_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -219,7 +242,7 @@ typedef void (*hb_paint_pop_clip_func_t) (hb_paint_funcs_t *funcs,
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph() * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @color_index: Index of a color in the fonts selected color palette * @color_index: Index of a color in the fonts selected color palette
* @alpha: alpha to apply in addition * @alpha: alpha to apply in addition
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_color_func() * @user_data: User data pointer passed to hb_paint_funcs_set_color_func()
* *
* A virtual method for the #hb_paint_funcs_t to paint a * A virtual method for the #hb_paint_funcs_t to paint a
@ -238,7 +261,7 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -262,7 +285,7 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
* @image: the image data * @image: the image data
* @format: the image format as a tag * @format: the image format as a tag
* @extents: (nullable): glyph extents * @extents: (nullable): glyph extents
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_image_func() * @user_data: User data pointer passed to hb_paint_funcs_set_image_func()
* *
* A virtual method for the #hb_paint_funcs_t to paint the * A virtual method for the #hb_paint_funcs_t to paint the
@ -283,7 +306,7 @@ typedef void (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,
hb_blob_t *image, hb_blob_t *image,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -357,7 +380,7 @@ hb_color_line_get_extend (hb_color_line_t *color_line);
* @y1: Y coordinate of the second point * @y1: Y coordinate of the second point
* @x2: X coordinate of the third point * @x2: X coordinate of the third point
* @y2: Y coordinate of the third point * @y2: Y coordinate of the third point
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_linear_gradient_func() * @user_data: User data pointer passed to hb_paint_funcs_set_linear_gradient_func()
* *
* A virtual method for the #hb_paint_funcs_t to paint a linear * A virtual method for the #hb_paint_funcs_t to paint a linear
@ -378,7 +401,7 @@ typedef void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -392,7 +415,7 @@ typedef void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,
* @x1: X coordinate of the second circle's center * @x1: X coordinate of the second circle's center
* @y1: Y coordinate of the second circle's center * @y1: Y coordinate of the second circle's center
* @r1: radius of the second circle * @r1: radius of the second circle
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_radial_gradient_func() * @user_data: User data pointer passed to hb_paint_funcs_set_radial_gradient_func()
* *
* A virtual method for the #hb_paint_funcs_t to paint a radial * A virtual method for the #hb_paint_funcs_t to paint a radial
@ -412,7 +435,7 @@ typedef void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1, float x1, float y1, float r1,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -424,7 +447,7 @@ typedef void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,
* @y0: Y coordinate of the circle's center * @y0: Y coordinate of the circle's center
* @start_angle: the start angle, in radians * @start_angle: the start angle, in radians
* @end_angle: the end angle, in radians * @end_angle: the end angle, in radians
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_sweep_gradient_func() * @user_data: User data pointer passed to hb_paint_funcs_set_sweep_gradient_func()
* *
* A virtual method for the #hb_paint_funcs_t to paint a sweep * A virtual method for the #hb_paint_funcs_t to paint a sweep
@ -445,7 +468,7 @@ typedef void (*hb_paint_sweep_gradient_func_t) (hb_paint_funcs_t *funcs,
float x0, float y0, float x0, float y0,
float start_angle, float start_angle,
float end_angle, float end_angle,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -493,7 +516,7 @@ typedef enum {
* hb_paint_push_group_func_t: * hb_paint_push_group_func_t:
* @funcs: paint functions object * @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph() * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_push_group_func() * @user_data: User data pointer passed to hb_paint_funcs_set_push_group_func()
* *
* A virtual method for the #hb_paint_funcs_t to use * A virtual method for the #hb_paint_funcs_t to use
@ -507,7 +530,7 @@ typedef enum {
*/ */
typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs, typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -515,7 +538,7 @@ typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
* @funcs: paint functions object * @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph() * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @mode: the compositing mode to use * @mode: the compositing mode to use
* @font: the font that is being painted * @ctx: the paint context
* @user_data: User data pointer passed to hb_paint_funcs_set_pop_group_func() * @user_data: User data pointer passed to hb_paint_funcs_set_pop_group_func()
* *
* A virtual method for the #hb_paint_funcs_t to undo * A virtual method for the #hb_paint_funcs_t to undo
@ -531,7 +554,7 @@ typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
typedef void (*hb_paint_pop_group_func_t) (hb_paint_funcs_t *funcs, typedef void (*hb_paint_pop_group_func_t) (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data); void *user_data);
/** /**
@ -743,39 +766,39 @@ hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data,
float xmin, float ymin, float xmin, float ymin,
float xmax, float ymax, float xmax, float ymax,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
hb_blob_t *image, hb_blob_t *image,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
@ -783,7 +806,7 @@ hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
@ -792,23 +815,23 @@ hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
float r0, float r0,
float x1, float y1, float x1, float y1,
float r1, float r1,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float start_angle, float end_angle, float start_angle, float end_angle,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_EXTERN void HB_EXTERN void
hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data, hb_paint_pop_group (hb_paint_funcs_t *funcs, void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font); const hb_paint_context_t *ctx);
HB_END_DECLS HB_END_DECLS

View File

@ -70,126 +70,128 @@ struct hb_paint_funcs_t
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.push_transform (this, paint_data, { func.push_transform (this, paint_data,
xx, yx, xy, yy, dx, dy, xx, yx, xy, yy, dx, dy,
font, ctx,
!user_data ? nullptr : user_data->push_transform); } !user_data ? nullptr : user_data->push_transform); }
void pop_transform (void *paint_data, void pop_transform (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.pop_transform (this, paint_data, font, { func.pop_transform (this, paint_data, ctx,
!user_data ? nullptr : user_data->pop_transform); } !user_data ? nullptr : user_data->pop_transform); }
void push_clip_glyph (void *paint_data, void push_clip_glyph (void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.push_clip_glyph (this, paint_data, { func.push_clip_glyph (this, paint_data,
glyph, glyph,
font, ctx,
!user_data ? nullptr : user_data->push_clip_glyph); } !user_data ? nullptr : user_data->push_clip_glyph); }
void push_clip_rectangle (void *paint_data, void push_clip_rectangle (void *paint_data,
float xmin, float ymin, float xmax, float ymax, float xmin, float ymin, float xmax, float ymax,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.push_clip_rectangle (this, paint_data, { func.push_clip_rectangle (this, paint_data,
xmin, ymin, xmax, ymax, xmin, ymin, xmax, ymax,
font, ctx,
!user_data ? nullptr : user_data->push_clip_rectangle); } !user_data ? nullptr : user_data->push_clip_rectangle); }
void pop_clip (void *paint_data, void pop_clip (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.pop_clip (this, paint_data, font, { func.pop_clip (this, paint_data, ctx,
!user_data ? nullptr : user_data->pop_clip); } !user_data ? nullptr : user_data->pop_clip); }
void color (void *paint_data, void color (void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.color (this, paint_data, { func.color (this, paint_data,
color_index, alpha, color_index, alpha,
font, ctx,
!user_data ? nullptr : user_data->color); } !user_data ? nullptr : user_data->color); }
void image (void *paint_data, void image (void *paint_data,
hb_blob_t *image, hb_blob_t *image,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.image (this, paint_data, { func.image (this, paint_data,
image, format, extents, image, format, extents,
font, ctx,
!user_data ? nullptr : user_data->image); } !user_data ? nullptr : user_data->image); }
void linear_gradient (void *paint_data, void linear_gradient (void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.linear_gradient (this, paint_data, { func.linear_gradient (this, paint_data,
color_line, x0, y0, x1, y1, x2, y2, color_line, x0, y0, x1, y1, x2, y2,
font, ctx,
!user_data ? nullptr : user_data->linear_gradient); } !user_data ? nullptr : user_data->linear_gradient); }
void radial_gradient (void *paint_data, void radial_gradient (void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1, float x1, float y1, float r1,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.radial_gradient (this, paint_data, { func.radial_gradient (this, paint_data,
color_line, x0, y0, r0, x1, y1, r1, color_line, x0, y0, r0, x1, y1, r1,
font, ctx,
!user_data ? nullptr : user_data->radial_gradient); } !user_data ? nullptr : user_data->radial_gradient); }
void sweep_gradient (void *paint_data, void sweep_gradient (void *paint_data,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float start_angle, float start_angle,
float end_angle, float end_angle,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.sweep_gradient (this, paint_data, { func.sweep_gradient (this, paint_data,
color_line, x0, y0, start_angle, end_angle, color_line, x0, y0, start_angle, end_angle,
font, ctx,
!user_data ? nullptr : user_data->sweep_gradient); } !user_data ? nullptr : user_data->sweep_gradient); }
void push_group (void *paint_data, void push_group (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.push_group (this, paint_data, font, { func.push_group (this, paint_data, ctx,
!user_data ? nullptr : user_data->push_group); } !user_data ? nullptr : user_data->push_group); }
void pop_group (void *paint_data, void pop_group (void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font) const hb_paint_context_t *ctx)
{ func.pop_group (this, paint_data, { func.pop_group (this, paint_data,
mode, mode,
font, ctx,
!user_data ? nullptr : user_data->pop_group); } !user_data ? nullptr : user_data->pop_group); }
void push_root_transform (void *paint_data, void push_root_transform (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
hb_font_t *font = ctx->font;
int xscale = font->x_scale, yscale = font->y_scale; int xscale = font->x_scale, yscale = font->y_scale;
float upem = font->face->get_upem (); float upem = font->face->get_upem ();
float slant = font->slant_xy; float slant = font->slant_xy;
func.push_transform (this, paint_data, func.push_transform (this, paint_data,
xscale/upem, 0, slant * yscale/upem, yscale/upem, 0, 0, xscale/upem, 0, slant * yscale/upem, yscale/upem, 0, 0,
font, ctx,
!user_data ? nullptr : user_data->push_transform); !user_data ? nullptr : user_data->push_transform);
} }
void pop_root_transform (void *paint_data, void pop_root_transform (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
func.pop_transform (this, paint_data, font, func.pop_transform (this, paint_data, ctx,
!user_data ? nullptr : user_data->pop_transform); !user_data ? nullptr : user_data->pop_transform);
} }
void push_inverse_root_transform (void *paint_data, void push_inverse_root_transform (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
hb_font_t *font = ctx->font;
int xscale = font->x_scale, yscale = font->y_scale; int xscale = font->x_scale, yscale = font->y_scale;
float upem = font->face->get_upem (); float upem = font->face->get_upem ();
float slant = font->slant_xy; float slant = font->slant_xy;
func.push_transform (this, paint_data, func.push_transform (this, paint_data,
upem/xscale, 0, -slant * upem/xscale, upem/yscale, 0, 0, upem/xscale, 0, -slant * upem/xscale, upem/yscale, 0, 0,
font, ctx,
!user_data ? nullptr : user_data->push_transform); !user_data ? nullptr : user_data->push_transform);
} }
void pop_inverse_root_transform (void *paint_data, void pop_inverse_root_transform (void *paint_data,
hb_font_t *font) const hb_paint_context_t *ctx)
{ {
func.pop_transform (this, paint_data, font, func.pop_transform (this, paint_data, ctx,
!user_data ? nullptr : user_data->pop_transform); !user_data ? nullptr : user_data->pop_transform);
} }
}; };

View File

@ -1,6 +1,6 @@
start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000 start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 13 start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000 start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient radial gradient
@ -16,7 +16,7 @@ start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 14 start clip glyph 14
linear gradient linear gradient
p0 231.000000 -27.000000 p0 231.000000 -27.000000
@ -29,21 +29,21 @@ start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 15 start clip glyph 15
solid 9 1.000000 solid 9 1.000000
end clip end clip
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 16 start clip glyph 16
solid 0 1.000000 solid 0 1.000000
end clip end clip
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 21 start clip glyph 21
solid 9 1.000000 solid 9 1.000000
end clip end clip
@ -51,7 +51,7 @@ start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
pop group mode 3 pop group mode 3
push group push group
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 16 start clip glyph 16
linear gradient linear gradient
p0 669.000000 776.000000 p0 669.000000 776.000000
@ -64,7 +64,7 @@ start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 18 start clip glyph 18
solid 2 0.200012 solid 2 0.200012
end clip end clip
@ -72,7 +72,7 @@ start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
pop group mode 3 pop group mode 3
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 19 start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000 start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient radial gradient
@ -88,7 +88,7 @@ start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
start clip glyph 20 start clip glyph 20
solid 9 1.000000 solid 9 1.000000
end clip end clip

View File

@ -1,6 +1,6 @@
start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000 start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 13 start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000 start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient radial gradient
@ -16,7 +16,7 @@ start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 14 start clip glyph 14
linear gradient linear gradient
p0 231.000000 -27.000000 p0 231.000000 -27.000000
@ -29,21 +29,21 @@ start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 15 start clip glyph 15
solid 9 1.000000 solid 9 1.000000
end clip end clip
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 16 start clip glyph 16
solid 0 1.000000 solid 0 1.000000
end clip end clip
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 21 start clip glyph 21
solid 9 1.000000 solid 9 1.000000
end clip end clip
@ -51,7 +51,7 @@ start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
pop group mode 3 pop group mode 3
push group push group
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 16 start clip glyph 16
linear gradient linear gradient
p0 669.000000 776.000000 p0 669.000000 776.000000
@ -64,7 +64,7 @@ start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 18 start clip glyph 18
solid 2 0.200012 solid 2 0.200012
end clip end clip
@ -72,7 +72,7 @@ start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
pop group mode 3 pop group mode 3
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 19 start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000 start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient radial gradient
@ -88,7 +88,7 @@ start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
end transform end transform
pop group mode 3 pop group mode 3
push group push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000 start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
start clip glyph 20 start clip glyph 20
solid 9 1.000000 solid 9 1.000000
end clip end clip

View File

@ -1,5 +1,5 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 174 start clip glyph 174
sweep gradient sweep gradient
center 500.000000 600.000000 center 500.000000 600.000000

View File

@ -1,6 +1,6 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 3 start clip glyph 3
solid 4 0.500000 solid 4 0.500000
end clip end clip
@ -9,7 +9,7 @@ start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 1000.000000 1000.000000 start transform 0.000000 0.000000 0.000000 0.000000 1000.000000 1000.000000
start transform 1.000000 -0.363874 -0.176283 1.000000 0.000000 0.000000 start transform 1.000000 -0.363874 -0.176283 1.000000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 -1000.000000 -1000.000000 start transform 0.000000 0.000000 0.000000 0.000000 -1000.000000 -1000.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 3 start clip glyph 3
solid 1 0.700012 solid 1 0.700012
end clip end clip

View File

@ -1,13 +1,13 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 3 start clip glyph 3
solid 4 0.500000 solid 4 0.500000
end clip end clip
end transform end transform
push group push group
start transform 1.000000 0.000000 0.000000 1.000000 200.000000 200.000000 start transform 1.000000 0.000000 0.000000 1.000000 200.000000 200.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 3 start clip glyph 3
solid 1 0.700012 solid 1 0.700012
end clip end clip

View File

@ -1,6 +1,6 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 3 start clip glyph 3
solid 10 1.000000 solid 10 1.000000
end clip end clip
@ -11,7 +11,7 @@ start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 333.000000 667.000000 start transform 0.000000 0.000000 0.000000 0.000000 333.000000 667.000000
start transform 8192.000000 0.000000 0.000000 8192.000000 0.000000 0.000000 start transform 8192.000000 0.000000 0.000000 8192.000000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 -333.000000 -667.000000 start transform 0.000000 0.000000 0.000000 0.000000 -333.000000 -667.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 2 start clip glyph 2
solid 12 1.000000 solid 12 1.000000
end clip end clip
@ -23,7 +23,7 @@ start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 667.000000 333.000000 start transform 0.000000 0.000000 0.000000 0.000000 667.000000 333.000000
start transform 8192.000000 0.000000 0.000000 8192.000000 0.000000 0.000000 start transform 8192.000000 0.000000 0.000000 8192.000000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 -667.000000 -333.000000 start transform 0.000000 0.000000 0.000000 0.000000 -667.000000 -333.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 2 start clip glyph 2
solid 11 1.000000 solid 11 1.000000
end clip end clip

View File

@ -1,5 +1,5 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 165 start clip glyph 165
linear gradient linear gradient
p0 100.000000 950.000000 p0 100.000000 950.000000

View File

@ -1,7 +1,7 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group push group
start transform 1.000000 0.000000 0.000000 1.000000 150.000000 0.000000 start transform 1.000000 0.000000 0.000000 1.000000 150.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 174 start clip glyph 174
solid 3 1.000000 solid 3 1.000000
end clip end clip
@ -10,7 +10,7 @@ start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
pop group mode 3 pop group mode 3
push group push group
start transform 1.000000 0.000000 0.000000 1.000000 -150.000000 0.000000 start transform 1.000000 0.000000 0.000000 1.000000 -150.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 174 start clip glyph 174
linear gradient linear gradient
p0 500.000000 250.000000 p0 500.000000 250.000000

View File

@ -1,5 +1,5 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 6 start clip glyph 6
linear gradient linear gradient
p0 100.000000 250.000000 p0 100.000000 250.000000

View File

@ -1,5 +1,5 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000 start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000 start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
start clip glyph 2 start clip glyph 2
radial gradient radial gradient
p0 166.000000 768.000000 radius 0.000000 p0 166.000000 768.000000 radius 0.000000

View File

@ -484,7 +484,7 @@ push_transform (hb_paint_funcs_t *funcs,
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -496,7 +496,7 @@ push_transform (hb_paint_funcs_t *funcs,
static void static void
pop_transform (hb_paint_funcs_t *funcs, pop_transform (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -509,7 +509,7 @@ static void
push_clip_glyph (hb_paint_funcs_t *funcs, push_clip_glyph (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -522,7 +522,7 @@ static void
push_clip_rectangle (hb_paint_funcs_t *funcs, push_clip_rectangle (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
float xmin, float ymin, float xmax, float ymax, float xmin, float ymin, float xmax, float ymax,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -534,7 +534,7 @@ push_clip_rectangle (hb_paint_funcs_t *funcs,
static void static void
pop_clip (hb_paint_funcs_t *funcs, pop_clip (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -548,7 +548,7 @@ paint_color (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -562,7 +562,7 @@ paint_image (hb_paint_funcs_t *funcs,
hb_blob_t *blob, hb_blob_t *blob,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -598,7 +598,7 @@ paint_linear_gradient (hb_paint_funcs_t *funcs,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -619,7 +619,7 @@ paint_radial_gradient (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1, float x1, float y1, float r1,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -640,7 +640,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
float cx, float cy, float cx, float cy,
float start_angle, float start_angle,
float end_angle, float end_angle,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -657,7 +657,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
static void static void
push_group (hb_paint_funcs_t *funcs, push_group (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -669,7 +669,7 @@ static void
pop_group (hb_paint_funcs_t *funcs, pop_group (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
paint_data_t *data = user_data; paint_data_t *data = user_data;
@ -736,7 +736,7 @@ test_hb_ot_color_colr_v1 (gconstpointer d)
data.string = g_string_new (""); data.string = g_string_new ("");
data.level = 0; data.level = 0;
hb_font_paint_glyph (font, test->glyph, funcs, &data); hb_font_paint_glyph (font, test->glyph, funcs, &data, 0, HB_COLOR (0, 0, 0, 255));
/* Run /* Run
* *

View File

@ -70,35 +70,26 @@ cairo_extend (hb_paint_extend_t extend)
return CAIRO_EXTEND_PAD; return CAIRO_EXTEND_PAD;
} }
hb_bool_t void
hb_cairo_get_font_color (hb_font_t *font, hb_cairo_get_font_color (const hb_paint_context_t *ctx,
unsigned int palette_index,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
float *r, float *g, float *b, float *a) float *r, float *g, float *b, float *a)
{ {
hb_color_t color = ctx->foreground;
if (color_index != 0xffff) if (color_index != 0xffff)
{ {
hb_color_t color;
unsigned int clen = 1; unsigned int clen = 1;
hb_face_t *face = hb_font_get_face (font); hb_face_t *face = hb_font_get_face (ctx->font);
hb_ot_color_palette_get_colors (face, ctx->palette, color_index, &clen, &color);
}
if (hb_ot_color_palette_get_colors (face, palette_index, color_index, &clen, &color))
{
*r = hb_color_get_red (color) / 255.f; *r = hb_color_get_red (color) / 255.f;
*g = hb_color_get_green (color) / 255.f; *g = hb_color_get_green (color) / 255.f;
*b = hb_color_get_blue (color) / 255.f; *b = hb_color_get_blue (color) / 255.f;
*a = (hb_color_get_alpha (color) / 255.f) * alpha; *a = (hb_color_get_alpha (color) / 255.f) * alpha;
return TRUE;
}
}
/* foreground color */
*r = *g = *b = 0;
*a = alpha;
return FALSE;
} }
typedef struct typedef struct
@ -129,7 +120,7 @@ read_blob (void *closure,
void void
hb_cairo_paint_glyph_image (cairo_t *cr, hb_cairo_paint_glyph_image (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_blob_t *blob, hb_blob_t *blob,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents) hb_glyph_extents_t *extents)
@ -237,7 +228,7 @@ normalize_color_line (hb_color_stop_t *stops,
void void
hb_cairo_paint_linear_gradient (cairo_t *cr, hb_cairo_paint_linear_gradient (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
@ -269,7 +260,7 @@ hb_cairo_paint_linear_gradient (cairo_t *cr,
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
{ {
float r, g, b, a; float r, g, b, a;
hb_cairo_get_font_color (font, 0, stops[i].color_index, stops[i].alpha, &r, &g, &b, &a); hb_cairo_get_font_color (ctx, stops[i].color_index, stops[i].alpha, &r, &g, &b, &a);
cairo_pattern_add_color_stop_rgba (pattern, stops[i].offset, r, g, b, a); cairo_pattern_add_color_stop_rgba (pattern, stops[i].offset, r, g, b, a);
} }
@ -284,7 +275,7 @@ hb_cairo_paint_linear_gradient (cairo_t *cr,
void void
hb_cairo_paint_radial_gradient (cairo_t *cr, hb_cairo_paint_radial_gradient (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1) float x1, float y1, float r1)
@ -317,7 +308,7 @@ hb_cairo_paint_radial_gradient (cairo_t *cr,
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
{ {
float r, g, b, a; float r, g, b, a;
hb_cairo_get_font_color (font, 0, stops[i].color_index, stops[i].alpha, &r, &g, &b, &a); hb_cairo_get_font_color (ctx, stops[i].color_index, stops[i].alpha, &r, &g, &b, &a);
cairo_pattern_add_color_stop_rgba (pattern, stops[i].offset, r, g, b, a); cairo_pattern_add_color_stop_rgba (pattern, stops[i].offset, r, g, b, a);
} }
@ -472,7 +463,7 @@ add_sweep_gradient_patches1 (float cx, float cy, float radius,
} }
static void static void
add_sweep_gradient_patches (hb_font_t *font, add_sweep_gradient_patches (const hb_paint_context_t *ctx,
hb_color_stop_t *stops, hb_color_stop_t *stops,
unsigned int n_stops, unsigned int n_stops,
cairo_extend_t extend, cairo_extend_t extend,
@ -495,7 +486,7 @@ add_sweep_gradient_patches (hb_font_t *font,
color_t c; color_t c;
if (start_angle > 0) if (start_angle > 0)
{ {
hb_cairo_get_font_color (font, 0, stops[0].color_index, stops[0].alpha, &c.r, &c.g, &c.b, &c.a); hb_cairo_get_font_color (ctx, stops[0].color_index, stops[0].alpha, &c.r, &c.g, &c.b, &c.a);
add_sweep_gradient_patches1 (cx, cy, radius, add_sweep_gradient_patches1 (cx, cy, radius,
0., &c, 0., &c,
start_angle, &c, start_angle, &c,
@ -503,7 +494,7 @@ add_sweep_gradient_patches (hb_font_t *font,
} }
if (end_angle < 2 * M_PI) if (end_angle < 2 * M_PI)
{ {
hb_cairo_get_font_color (font, 0, stops[n_stops-1].color_index, stops[n_stops-1].alpha, &c.r, &c.g, &c.b, &c.a); hb_cairo_get_font_color (ctx, stops[n_stops-1].color_index, stops[n_stops-1].alpha, &c.r, &c.g, &c.b, &c.a);
add_sweep_gradient_patches1 (cx, cy, radius, add_sweep_gradient_patches1 (cx, cy, radius,
end_angle, &c, end_angle, &c,
2 * M_PI, &c, 2 * M_PI, &c,
@ -539,7 +530,7 @@ add_sweep_gradient_patches (hb_font_t *font,
for (unsigned i = 0; i < n_stops; i++) for (unsigned i = 0; i < n_stops; i++)
{ {
angles[i] = start_angle + stops[i].offset * (end_angle - start_angle); angles[i] = start_angle + stops[i].offset * (end_angle - start_angle);
hb_cairo_get_font_color (font, 0, stops[i].color_index, stops[i].alpha, &colors[i].r, &colors[i].g, &colors[i].b, &colors[i].a); hb_cairo_get_font_color (ctx, stops[i].color_index, stops[i].alpha, &colors[i].r, &colors[i].g, &colors[i].b, &colors[i].a);
} }
if (extend == CAIRO_EXTEND_PAD) if (extend == CAIRO_EXTEND_PAD)
@ -717,7 +708,7 @@ done:
void void
hb_cairo_paint_sweep_gradient (cairo_t *cr, hb_cairo_paint_sweep_gradient (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float cx, float cy, float cx, float cy,
float start_angle, float start_angle,
@ -746,7 +737,7 @@ hb_cairo_paint_sweep_gradient (cairo_t *cr,
extend = cairo_extend (hb_color_line_get_extend (color_line)); extend = cairo_extend (hb_color_line_get_extend (color_line));
pattern = cairo_pattern_create_mesh (); pattern = cairo_pattern_create_mesh ();
add_sweep_gradient_patches (font, stops, len, extend, cx, cy, add_sweep_gradient_patches (ctx, stops, len, extend, cx, cy,
radius, start_angle, end_angle, pattern); radius, start_angle, end_angle, pattern);
cairo_set_source (cr, pattern); cairo_set_source (cr, pattern);

View File

@ -70,33 +70,32 @@ hb_paint_composite_mode_to_cairo (hb_paint_composite_mode_t mode)
return CAIRO_OPERATOR_SOURCE; return CAIRO_OPERATOR_SOURCE;
} }
hb_bool_t hb_cairo_get_font_color (hb_font_t *font, void hb_cairo_get_font_color (const hb_paint_context_t *ctx,
unsigned int palette_index,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
float *r, float *g, float *b, float *a); float *r, float *g, float *b, float *a);
void hb_cairo_paint_glyph_image (cairo_t *cr, void hb_cairo_paint_glyph_image (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_blob_t *blob, hb_blob_t *blob,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents); hb_glyph_extents_t *extents);
void hb_cairo_paint_linear_gradient (cairo_t *cr, void hb_cairo_paint_linear_gradient (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2); float x2, float y2);
void hb_cairo_paint_radial_gradient (cairo_t *cr, void hb_cairo_paint_radial_gradient (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1); float x1, float y1, float r1);
void hb_cairo_paint_sweep_gradient (cairo_t *cr, void hb_cairo_paint_sweep_gradient (cairo_t *cr,
hb_font_t *font, const hb_paint_context_t *ctx,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float start_angle, float end_angle); float start_angle, float end_angle);

View File

@ -111,7 +111,7 @@ push_transform (hb_paint_funcs_t *funcs,
float xx, float yx, float xx, float yx,
float xy, float yy, float xy, float yy,
float dx, float dy, float dx, float dy,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
@ -127,7 +127,7 @@ push_transform (hb_paint_funcs_t *funcs,
static void static void
pop_transform (hb_paint_funcs_t *funcs, pop_transform (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
@ -139,14 +139,14 @@ static void
push_clip_glyph (hb_paint_funcs_t *funcs, push_clip_glyph (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
cairo_save (cr); cairo_save (cr);
cairo_new_path (cr); cairo_new_path (cr);
hb_font_draw_glyph (font, glyph, get_cairo_draw_funcs (), cr); hb_font_draw_glyph (ctx->font, glyph, get_cairo_draw_funcs (), cr);
cairo_close_path (cr); cairo_close_path (cr);
cairo_clip (cr); cairo_clip (cr);
} }
@ -155,7 +155,7 @@ static void
push_clip_rectangle (hb_paint_funcs_t *funcs, push_clip_rectangle (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
float xmin, float ymin, float xmax, float ymax, float xmin, float ymin, float xmax, float ymax,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
@ -170,7 +170,7 @@ push_clip_rectangle (hb_paint_funcs_t *funcs,
static void static void
pop_clip (hb_paint_funcs_t *funcs, pop_clip (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
@ -181,7 +181,7 @@ pop_clip (hb_paint_funcs_t *funcs,
static void static void
push_group (hb_paint_funcs_t *funcs, push_group (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
@ -194,7 +194,7 @@ static void
pop_group (hb_paint_funcs_t *funcs, pop_group (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
hb_paint_composite_mode_t mode, hb_paint_composite_mode_t mode,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
@ -211,13 +211,13 @@ paint_color (hb_paint_funcs_t *funcs,
void *paint_data, void *paint_data,
unsigned int color_index, unsigned int color_index,
float alpha, float alpha,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
float r, g, b, a; float r, g, b, a;
hb_cairo_get_font_color (font, 0, color_index, alpha, &r, &g, &b, &a); hb_cairo_get_font_color (ctx, color_index, alpha, &r, &g, &b, &a);
cairo_set_source_rgba (cr, (double)r, (double)g, (double)b, (double)a); cairo_set_source_rgba (cr, (double)r, (double)g, (double)b, (double)a);
cairo_paint (cr); cairo_paint (cr);
} }
@ -228,12 +228,12 @@ paint_image (hb_paint_funcs_t *funcs,
hb_blob_t *blob, hb_blob_t *blob,
hb_tag_t format, hb_tag_t format,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_glyph_image (cr, font, blob, format, extents); hb_cairo_paint_glyph_image (cr, ctx, blob, format, extents);
} }
static void static void
@ -243,12 +243,12 @@ paint_linear_gradient (hb_paint_funcs_t *funcs,
float x0, float y0, float x0, float y0,
float x1, float y1, float x1, float y1,
float x2, float y2, float x2, float y2,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_linear_gradient (cr, font, color_line, x0, y0, x1, y1, x2, y2); hb_cairo_paint_linear_gradient (cr, ctx, color_line, x0, y0, x1, y1, x2, y2);
} }
static void static void
@ -257,12 +257,12 @@ paint_radial_gradient (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float r0, float x0, float y0, float r0,
float x1, float y1, float r1, float x1, float y1, float r1,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_radial_gradient (cr, font, color_line, x0, y0, r0, x1, y1, r1); hb_cairo_paint_radial_gradient (cr, ctx, color_line, x0, y0, r0, x1, y1, r1);
} }
static void static void
@ -271,12 +271,12 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line, hb_color_line_t *color_line,
float x0, float y0, float x0, float y0,
float start_angle, float end_angle, float start_angle, float end_angle,
hb_font_t *font, const hb_paint_context_t *ctx,
void *user_data) void *user_data)
{ {
cairo_t *cr = (cairo_t *)paint_data; cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_sweep_gradient (cr, font, color_line, x0, y0, start_angle, end_angle); hb_cairo_paint_sweep_gradient (cr, ctx, color_line, x0, y0, start_angle, end_angle);
} }
static hb_paint_funcs_t * static hb_paint_funcs_t *
@ -355,7 +355,7 @@ render_color_glyph (cairo_scaled_font_t *scaled_font,
hb_font_get_scale (font, &x_scale, &y_scale); hb_font_get_scale (font, &x_scale, &y_scale);
cairo_scale (cr, +1./x_scale, -1./y_scale); cairo_scale (cr, +1./x_scale, -1./y_scale);
hb_font_paint_glyph (font, glyph, get_cairo_paint_funcs (), cr); hb_font_paint_glyph (font, glyph, get_cairo_paint_funcs (), cr, 0, HB_COLOR (0, 0, 0, 255));
hb_glyph_extents_t hb_extents; hb_glyph_extents_t hb_extents;
hb_font_get_glyph_extents (font, glyph, &hb_extents); hb_font_get_glyph_extents (font, glyph, &hb_extents);