[paint] Pass font to all callbacks

This will lead to easier implementations.

At the same time, we change the push_clip_glyph
callback to use the font as-is, no unscaling needed.

Update all callers and expected test results.
This commit is contained in:
Matthias Clasen authored and Behdad Esfahbod committed 2022-12-23 13:37:59 -07:00
1 parent 32ce29f99e
commit 97224f3b63
33 files changed
+639 -457

No files matched your search

+4 -4
View File
@@ -337,11 +337,11 @@ struct glyf_accelerator_t
{
funcs->push_root_transform (data, font);
funcs->push_clip_glyph (data, gid);
funcs->color (data, 0xffff, 1.);
funcs->pop_clip (data);
funcs->push_clip_glyph (data, gid, font);
funcs->color (data, 0xffff, 1., font);
funcs->pop_clip (data, font);
funcs->pop_root_transform (data);
funcs->pop_root_transform (data, font);
return false;
}
+3 -2
View File
@@ -664,11 +664,12 @@ hb_font_paint_glyph_default (hb_font_t *font,
0.f,
font->parent->y_scale ? (float) font->y_scale / (float) font->parent->y_scale : 0.f,
0.f,
0.f);
0.f,
font);
font->parent->paint_glyph (glyph, paint_funcs, paint_data);
paint_funcs->pop_transform (paint_data);
paint_funcs->pop_transform (paint_data, font);
}
DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
+4 -4
View File
@@ -557,11 +557,11 @@ bool OT::cff1::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph
{
funcs->push_root_transform (data, font);
funcs->push_clip_glyph (data, glyph);
funcs->color (data, 0xffff, 1.);
funcs->pop_clip (data);
funcs->push_clip_glyph (data, glyph, font);
funcs->color (data, 0xffff, 1., font);
funcs->pop_clip (data, font);
funcs->pop_root_transform (data);
funcs->pop_root_transform (data, font);
return false;
}
+4 -4
View File
@@ -147,11 +147,11 @@ bool OT::cff2::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph
{
funcs->push_root_transform (data, font);
funcs->push_clip_glyph (data, glyph);
funcs->color (data, 0xffff, 1.);
funcs->pop_clip (data);
funcs->push_clip_glyph (data, glyph, font);
funcs->color (data, 0xffff, 1., font);
funcs->pop_clip (data, font);
funcs->pop_root_transform (data);
funcs->pop_root_transform (data, font);
return false;
}
+1 -1
View File
@@ -947,7 +947,7 @@ struct CBDT
if (unlikely (!hb_font_get_glyph_extents (font, glyph, &extents)))
return false;
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents);
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents, font);
hb_blob_destroy (blob);
return true;
+2 -2
View File
@@ -8,9 +8,9 @@ void PaintColrLayers::paint_glyph (hb_paint_context_t *c) const
for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++)
{
const Paint &paint = paint_offset_lists.get_paint (i);
c->funcs->push_group (c->data);
c->funcs->push_group (c->data, c->font);
c->recurse (paint);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER, c->font);
}
}
+80 -57
View File
@@ -75,16 +75,19 @@ public:
const void *base;
hb_paint_funcs_t *funcs;
void *data;
hb_font_t *font;
VarStoreInstancer &instancer;
int depth_left = HB_COLRV1_MAX_NESTING_LEVEL;
hb_paint_context_t (const void *base_,
hb_paint_funcs_t *funcs_,
void *data_,
hb_font_t *font_,
VarStoreInstancer &instancer_) :
base (base_),
funcs (funcs_),
data (data_),
font (font_),
instancer (instancer_)
{}
@@ -482,7 +485,8 @@ struct Affine2x3
xy.to_float (c->instancer (varIdxBase, 2)),
yy.to_float (c->instancer (varIdxBase, 3)),
dx.to_float (c->instancer (varIdxBase, 4)),
dy.to_float (c->instancer (varIdxBase, 5)));
dy.to_float (c->instancer (varIdxBase, 5)),
c->font);
}
F16DOT16 xx;
@@ -548,8 +552,9 @@ struct PaintSolid
void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const
{
c->funcs->color (c->data,
paletteIndex,
alpha.to_float (c->instancer (varIdxBase, 0)));
paletteIndex,
alpha.to_float (c->instancer (varIdxBase, 0)),
c->font);
}
HBUINT8 format; /* format = 2(noVar) or 3(Var)*/
@@ -590,7 +595,8 @@ struct PaintLinearGradient
x1 + c->instancer (varIdxBase, 2),
y1 + c->instancer (varIdxBase, 3),
x2 + c->instancer (varIdxBase, 4),
y2 + c->instancer (varIdxBase, 5));
y2 + c->instancer (varIdxBase, 5),
c->font);
}
HBUINT8 format; /* format = 4(noVar) or 5 (Var) */
@@ -637,7 +643,8 @@ struct PaintRadialGradient
radius0 + c->instancer (varIdxBase, 2),
x1 + c->instancer (varIdxBase, 3),
y1 + c->instancer (varIdxBase, 4),
radius1 + c->instancer (varIdxBase, 5));
radius1 + c->instancer (varIdxBase, 5),
c->font);
}
HBUINT8 format; /* format = 6(noVar) or 7 (Var) */
@@ -682,7 +689,8 @@ struct PaintSweepGradient
centerX + c->instancer (varIdxBase, 0),
centerY + c->instancer (varIdxBase, 1),
(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);
}
HBUINT8 format; /* format = 8(noVar) or 9 (Var) */
@@ -722,9 +730,11 @@ struct PaintGlyph
void paint_glyph (hb_paint_context_t *c) const
{
c->funcs->push_clip_glyph (c->data, gid);
c->funcs->push_inverse_root_transform (c->data, c->font);
c->funcs->push_clip_glyph (c->data, gid, c->font);
c->recurse (this+paint);
c->funcs->pop_clip (c->data);
c->funcs->pop_clip (c->data, c->font);
c->funcs->pop_inverse_root_transform (c->data, c->font);
}
HBUINT8 format; /* format = 10 */
@@ -788,7 +798,7 @@ struct PaintTransform
{
(this+transform).paint_glyph (c);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 12(noVar) or 13 (Var) */
@@ -822,9 +832,10 @@ struct PaintTranslate
c->funcs->push_transform (c->data,
1., 0., 0., 1.,
dx + c->instancer (varIdxBase, 0),
dy + c->instancer (varIdxBase, 0));
dy + c->instancer (varIdxBase, 0),
c->font);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 14(noVar) or 15 (Var) */
@@ -860,9 +871,10 @@ struct PaintScale
scaleX.to_float (c->instancer (varIdxBase, 0)),
0., 0.,
scaleY.to_float (c->instancer (varIdxBase, 1)),
0., 0.);
0., 0.,
c->font);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 16 (noVar) or 17(Var) */
@@ -896,17 +908,20 @@ struct PaintScaleAroundCenter
{
float tCenterX = centerX + c->instancer (varIdxBase, 2);
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->funcs->push_transform (c->data,
scaleX.to_float (c->instancer (varIdxBase, 0)),
0., 0.,
scaleY.to_float (c->instancer (varIdxBase, 1)),
0., 0.);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY);
0., 0.,
c->font);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 18 (noVar) or 19(Var) */
@@ -941,9 +956,10 @@ struct PaintScaleUniform
void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const
{
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->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 20 (noVar) or 21(Var) */
@@ -977,13 +993,16 @@ struct PaintScaleUniformAroundCenter
float s = scale + c->instancer (varIdxBase, 0);
float tCenterX = centerX + c->instancer (varIdxBase, 1);
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, s, 0., 0., s, 0., 0.);
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->funcs->push_transform (c->data, s, 0., 0., s, 0., 0.,
c->font);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 22 (noVar) or 23(Var) */
@@ -1019,9 +1038,10 @@ struct PaintRotate
float a = angle.to_float (c->instancer (varIdxBase, 0));
float cc = cosf (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->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 24 (noVar) or 25(Var) */
@@ -1057,13 +1077,16 @@ struct PaintRotateAroundCenter
float ss = sinf (a * (float) M_PI);
float tCenterX = centerX + c->instancer (varIdxBase, 1);
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, cc, ss, -ss, cc, 0., 0.);
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->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0.,
c->font);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 26 (noVar) or 27(Var) */
@@ -1098,9 +1121,10 @@ struct PaintSkew
{
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);
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->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 28(noVar) or 29 (Var) */
@@ -1136,13 +1160,16 @@ struct PaintSkewAroundCenter
float y = -tanf (ySkewAngle.to_float(c->instancer (varIdxBase, 1)) * (float) M_PI);
float tCenterX = centerX + c->instancer (varIdxBase, 2);
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, 1., y, x, 1., 0., 0.);
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->funcs->push_transform (c->data, 1., y, x, 1., 0., 0.,
c->font);
c->funcs->push_transform (c->data, 0., 0., 0., 0., -tCenterX, -tCenterY,
c->font);
c->recurse (this+src);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
c->funcs->pop_transform (c->data, c->font);
}
HBUINT8 format; /* format = 30(noVar) or 31 (Var) */
@@ -1179,12 +1206,12 @@ struct PaintComposite
void paint_glyph (hb_paint_context_t *c) const
{
c->funcs->push_group (c->data);
c->funcs->push_group (c->data, c->font);
c->recurse (this+backdrop);
c->funcs->push_group (c->data);
c->funcs->push_group (c->data, c->font);
c->recurse (this+src);
c->funcs->pop_group (c->data, (hb_paint_composite_mode_t) (int) mode);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
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_SRC_OVER, c->font);
}
HBUINT8 format; /* format = 32 */
@@ -1939,17 +1966,17 @@ struct COLR
this+varIdxMap,
hb_array (font->coords, font->num_coords));
hb_paint_context_t c (this, funcs, data, instancer);
hb_paint_context_t c (this, funcs, data, font, instancer);
const Paint *paint = get_base_glyph_paint (glyph);
if (paint)
{
// COLRv1 glyph
c.funcs->push_root_transform (data, font);
c.funcs->push_root_transform (c.data, c.font);
c.recurse (*paint);
c.funcs->pop_root_transform (c.data);
c.funcs->pop_root_transform (c.data, c.font);
return true;
}
@@ -1958,18 +1985,14 @@ struct COLR
if (record && ((hb_codepoint_t) record->glyphId == glyph))
{
// COLRv0 glyph
funcs->push_root_transform (data, font);
for (const auto &r : (this+layersZ).as_array (numLayers)
.sub_array (record->firstLayerIdx, record->numLayers))
{
c.funcs->push_clip_glyph (c.data, r.glyphId);
c.funcs->color (c.data, r.colorIdx, 1.);
c.funcs->pop_clip (c.data);
c.funcs->push_clip_glyph (c.data, r.glyphId, c.font);
c.funcs->color (c.data, r.colorIdx, 1., c.font);
c.funcs->pop_clip (c.data, c.font);
}
c.funcs->pop_root_transform (c.data);
return true;
}
+1 -1
View File
@@ -248,7 +248,7 @@ struct sbix
if (!hb_font_get_glyph_extents (font, glyph, &extents))
return false;
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents);
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents, font);
hb_blob_destroy (blob);
return true;
+1 -1
View File
@@ -103,7 +103,7 @@ struct SVG
if (blob == hb_blob_get_empty ())
return false;
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_SVG, nullptr);
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_SVG, nullptr, font);
hb_blob_destroy (blob);
return true;
+60 -24
View File
@@ -47,30 +47,36 @@ hb_paint_push_transform_nil (hb_paint_funcs_t *funcs, void *paint_data,
float xx, float yx,
float xy, float yy,
float dx, float dy,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_pop_transform_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_push_clip_glyph_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_codepoint_t glyph,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_push_clip_rectangle_nil (hb_paint_funcs_t *funcs, void *paint_data,
float xmin, float ymin, float xmax, float ymax,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_pop_clip_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_color_nil (hb_paint_funcs_t *funcs, void *paint_data,
unsigned int color_index,
float alpha,
hb_font_t *font,
void *user_data) {}
static void
@@ -78,6 +84,7 @@ hb_paint_image_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_blob_t *image,
hb_tag_t format,
hb_glyph_extents_t *extents,
hb_font_t *font,
void *user_data) {}
static void
@@ -86,6 +93,7 @@ hb_paint_linear_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0,
float x1, float y1,
float x2, float y2,
hb_font_t *font,
void *user_data) {}
static void
@@ -93,6 +101,7 @@ hb_paint_radial_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line,
float x0, float y0, float r0,
float x1, float y1, float r1,
hb_font_t *font,
void *user_data) {}
static void
@@ -101,15 +110,18 @@ hb_paint_sweep_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0,
float start_angle,
float end_angle,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_push_group_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_font_t *font,
void *user_data) {}
static void
hb_paint_pop_group_nil (hb_paint_funcs_t *funcs, void *paint_data,
hb_paint_composite_mode_t mode,
hb_font_t *font,
void *user_data) {}
static bool
@@ -382,6 +394,7 @@ hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs)
* @yy: yy component of the transform matrix
* @dx: dx component of the transform matrix
* @dy: dy component of the transform matrix
* @font: the font
*
* Perform a "push-transform" paint operation.
*
@@ -391,24 +404,27 @@ void
hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
float xx, float yx,
float xy, float yy,
float dx, float dy)
float dx, float dy,
hb_font_t *font)
{
funcs->push_transform (paint_data, xx, yx, xy, yy, dx, dy);
funcs->push_transform (paint_data, xx, yx, xy, yy, dx, dy, font);
}
/**
* hb_paint_pop_transform:
* @funcs: paint functions
* @paint_data: associated data passed by the caller
* @font: the font
*
* Perform a "pop-transform" paint operation.
*
* Since: REPLACEME
*/
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)
{
funcs->pop_transform (paint_data);
funcs->pop_transform (paint_data, font);
}
/**
@@ -416,6 +432,7 @@ hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data)
* @funcs: paint functions
* @paint_data: associated data passed by the caller
* @glyph: the glyph ID
* @font: the font
*
* Perform a "push-clip-glyph" paint operation.
*
@@ -423,9 +440,10 @@ hb_paint_pop_transform (hb_paint_funcs_t *funcs, void *paint_data)
*/
void
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)
{
funcs->push_clip_glyph (paint_data, glyph);
funcs->push_clip_glyph (paint_data, glyph, font);
}
/**
@@ -436,6 +454,7 @@ hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
* @ymin: min Y for the rectangle
* @xmax: max X for the rectangle
* @ymax: max Y for the rectangle
* @font: the font
*
* Perform a "push-clip-rect" paint operation.
*
@@ -443,24 +462,27 @@ hb_paint_push_clip_glyph (hb_paint_funcs_t *funcs, void *paint_data,
*/
void
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)
{
funcs->push_clip_rectangle (paint_data, xmin, ymin, xmax, ymax);
funcs->push_clip_rectangle (paint_data, xmin, ymin, xmax, ymax, font);
}
/**
* hb_paint_pop_clip:
* @funcs: paint functions
* @paint_data: associated data passed by the caller
* @font: the font
*
* Perform a "pop-clip" paint operation.
*
* Since: REPLACEME
*/
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)
{
funcs->pop_clip (paint_data);
funcs->pop_clip (paint_data, font);
}
/**
@@ -469,6 +491,7 @@ hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data)
* @paint_data: associated data passed by the caller
* @color_index: Index of a color in the fonts selected color palette
* @alpha: Alpha to apply in addition
* @font: the font
*
* Perform a "color" paint operation.
*
@@ -477,9 +500,10 @@ hb_paint_pop_clip (hb_paint_funcs_t *funcs, void *paint_data)
void
hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
unsigned int color_index,
float alpha)
float alpha,
hb_font_t *font)
{
funcs->color (paint_data, color_index, alpha);
funcs->color (paint_data, color_index, alpha, font);
}
/**
@@ -489,6 +513,7 @@ hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
* @image: image data
* @format: tag describing the image data format
* @extents: (nullable): the extents of the glyph
* @font: the font
*
* Perform a "image" paint operation.
*
@@ -498,9 +523,10 @@ void
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
hb_blob_t *image,
hb_tag_t format,
hb_glyph_extents_t *extents)
hb_glyph_extents_t *extents,
hb_font_t *font)
{
funcs->image (paint_data, image, format, extents);
funcs->image (paint_data, image, format, extents, font);
}
/**
@@ -514,6 +540,7 @@ hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
* @y1: Y coordinate of the second point
* @x2: X coordinate of the third point
* @y2: Y coordinate of the third point
* @font: the font
*
* Perform a "linear-gradient" paint operation.
*
@@ -524,9 +551,10 @@ hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float x1, float y1,
float x2, float y2)
float x2, float y2,
hb_font_t *font)
{
funcs->linear_gradient (paint_data, color_line, x0, y0, x1, y1, x2, y2);
funcs->linear_gradient (paint_data, color_line, x0, y0, x1, y1, x2, y2, font);
}
/**
@@ -540,6 +568,7 @@ hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
* @x1: X coordinate of the second circle's center
* @y1: Y coordinate of the second circle's center
* @r1: radius of the second circle
* @font: the font
*
* Perform a "radial-gradient" paint operation.
*
@@ -549,9 +578,10 @@ void
hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line,
float x0, float y0, float r0,
float x1, float y1, float r1)
float x1, float y1, float r1,
hb_font_t *font)
{
funcs->radial_gradient (paint_data, color_line, x0, y0, r0, y1, x1, r1);
funcs->radial_gradient (paint_data, color_line, x0, y0, r0, y1, x1, r1, font);
}
/**
@@ -563,6 +593,7 @@ hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
* @y0: Y coordinate of the circle's center
* @start_angle: the start angle
* @end_angle: the end angle
* @font: the font
*
* Perform a "sweep-gradient" paint operation.
*
@@ -572,24 +603,27 @@ void
hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float start_angle, float end_angle)
float start_angle, float end_angle,
hb_font_t *font)
{
funcs->sweep_gradient (paint_data, color_line, x0, y0, start_angle, end_angle);
funcs->sweep_gradient (paint_data, color_line, x0, y0, start_angle, end_angle, font);
}
/**
* hb_paint_push_group:
* @funcs: paint functions
* @paint_data: associated data passed by the caller
* @font: the font
*
* Perform a "push-group" paint operation.
*
* Since: REPLACEME
*/
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)
{
funcs->push_group (paint_data);
funcs->push_group (paint_data, font);
}
/**
@@ -597,6 +631,7 @@ hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data)
* @funcs: paint functions
* @paint_data: associated data passed by the caller
* @mode: the compositing mode to use
* @font: the font
*
* Perform a "pop-group" paint operation.
*
@@ -604,9 +639,10 @@ hb_paint_push_group (hb_paint_funcs_t *funcs, void *paint_data)
*/
void
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)
{
funcs->pop_group (paint_data, mode);
funcs->pop_group (paint_data, mode, font);
}
#endif
+48 -17
View File
@@ -101,6 +101,7 @@ hb_paint_funcs_is_immutable (hb_paint_funcs_t *funcs);
* @yy: yy component of the transform matrix
* @dx: dx component of the transform matrix
* @dy: dy component of the transform matrix
* @font: the font that is being painted
* @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
@@ -117,12 +118,14 @@ typedef void (*hb_paint_push_transform_func_t) (hb_paint_funcs_t *funcs,
float xx, float yx,
float xy, float yy,
float dx, float dy,
hb_font_t *font,
void *user_data);
/**
* hb_paint_pop_transform_func_t:
* @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @font: the font that is being painted
* @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
@@ -133,6 +136,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,
void *paint_data,
hb_font_t *font,
void *user_data);
/**
@@ -140,6 +144,7 @@ typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,
* @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @glyph: the glyph ID
* @font: the font that is being painted
* @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
@@ -148,11 +153,6 @@ typedef void (*hb_paint_pop_transform_func_t) (hb_paint_funcs_t *funcs,
* The coordinates of the glyph outline are interpreted according
* to the current transform.
*
* Note that hb_font_paint_glyph() applies the scale and slant of
* the font as a transform, so you need to pass an unscaled, unslanted
* copy of the font to hb_font_get_glyph_shape() when obtaining outlines,
* to avoid double scaling.
*
* This clip is applied in addition to the current clip,
* and remains in effect until a matching call to
* the #hb_paint_funcs_pop_clip_func_t vfunc.
@@ -162,6 +162,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,
void *paint_data,
hb_codepoint_t glyph,
hb_font_t *font,
void *user_data);
/**
@@ -172,6 +173,7 @@ typedef void (*hb_paint_push_clip_glyph_func_t) (hb_paint_funcs_t *funcs,
* @ymin: min Y for the rectangle
* @xmax: max X for the rectangle
* @ymax: max Y for the rectangle
* @font: the font that is being painted
* @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
@@ -190,12 +192,14 @@ typedef void (*hb_paint_push_clip_rectangle_func_t) (hb_paint_funcs_t *funcs,
void *paint_data,
float xmin, float ymin,
float xmax, float ymax,
hb_font_t *font,
void *user_data);
/**
* hb_paint_pop_clip_func_t:
* @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @font: the font that is being painted
* @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
@@ -206,6 +210,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,
void *paint_data,
hb_font_t *font,
void *user_data);
/**
@@ -214,6 +219,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()
* @color_index: Index of a color in the fonts selected color palette
* @alpha: alpha to apply in addition
* @font: the font that is being painted
* @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
@@ -232,6 +238,7 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
void *paint_data,
unsigned int color_index,
float alpha,
hb_font_t *font,
void *user_data);
/**
@@ -255,6 +262,7 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
* @image: the image data
* @format: the image format as a tag
* @extents: (nullable): glyph extents
* @font: the font that is being painted
* @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
@@ -275,6 +283,7 @@ typedef void (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,
hb_blob_t *image,
hb_tag_t format,
hb_glyph_extents_t *extents,
hb_font_t *font,
void *user_data);
/**
@@ -348,6 +357,7 @@ hb_color_line_get_extend (hb_color_line_t *color_line);
* @y1: Y coordinate of the second point
* @x2: X coordinate of the third point
* @y2: Y coordinate of the third point
* @font: the font that is being painted
* @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
@@ -368,6 +378,7 @@ typedef void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,
float x0, float y0,
float x1, float y1,
float x2, float y2,
hb_font_t *font,
void *user_data);
/**
@@ -381,6 +392,7 @@ typedef void (*hb_paint_linear_gradient_func_t) (hb_paint_funcs_t *funcs,
* @x1: X coordinate of the second circle's center
* @y1: Y coordinate of the second circle's center
* @r1: radius of the second circle
* @font: the font that is being painted
* @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
@@ -400,6 +412,7 @@ typedef void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line,
float x0, float y0, float r0,
float x1, float y1, float r1,
hb_font_t *font,
void *user_data);
/**
@@ -411,6 +424,7 @@ typedef void (*hb_paint_radial_gradient_func_t) (hb_paint_funcs_t *funcs,
* @y0: Y coordinate of the circle's center
* @start_angle: the start angle, in radians
* @end_angle: the end angle, in radians
* @font: the font that is being painted
* @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
@@ -431,6 +445,7 @@ typedef void (*hb_paint_sweep_gradient_func_t) (hb_paint_funcs_t *funcs,
float x0, float y0,
float start_angle,
float end_angle,
hb_font_t *font,
void *user_data);
/**
@@ -478,6 +493,7 @@ typedef enum {
* hb_paint_push_group_func_t:
* @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @font: the font that is being painted
* @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
@@ -491,6 +507,7 @@ typedef enum {
*/
typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data);
/**
@@ -498,6 +515,7 @@ typedef void (*hb_paint_push_group_func_t) (hb_paint_funcs_t *funcs,
* @funcs: paint functions object
* @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
* @mode: the compositing mode to use
* @font: the font that is being painted
* @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
@@ -513,6 +531,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,
void *paint_data,
hb_paint_composite_mode_t mode,
hb_font_t *font,
void *user_data);
/**
@@ -723,40 +742,48 @@ HB_EXTERN void
hb_paint_push_transform (hb_paint_funcs_t *funcs, void *paint_data,
float xx, float yx,
float xy, float yy,
float dx, float dy);
float dx, float dy,
hb_font_t *font);
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);
HB_EXTERN void
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);
HB_EXTERN void
hb_paint_push_clip_rectangle (hb_paint_funcs_t *funcs, void *paint_data,
float xmin, float ymin,
float xmax, float ymax);
float xmax, float ymax,
hb_font_t *font);
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);
HB_EXTERN void
hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
unsigned int color_index,
float alpha);
float alpha,
hb_font_t *font);
HB_EXTERN void
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
hb_blob_t *image,
hb_tag_t format,
hb_glyph_extents_t *extents);
hb_glyph_extents_t *extents,
hb_font_t *font);
HB_EXTERN void
hb_paint_linear_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float x1, float y1,
float x2, float y2);
float x2, float y2,
hb_font_t *font);
HB_EXTERN void
hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
@@ -764,20 +791,24 @@ hb_paint_radial_gradient (hb_paint_funcs_t *funcs, void *paint_data,
float x0, float y0,
float r0,
float x1, float y1,
float r1);
float r1,
hb_font_t *font);
HB_EXTERN void
hb_paint_sweep_gradient (hb_paint_funcs_t *funcs, void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float start_angle, float end_angle);
float start_angle, float end_angle,
hb_font_t *font);
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);
HB_EXTERN void
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);
HB_END_DECLS
+61 -18
View File
@@ -69,69 +69,90 @@ struct hb_paint_funcs_t
void push_transform (void *paint_data,
float xx, float yx,
float xy, float yy,
float dx, float dy)
float dx, float dy,
hb_font_t *font)
{ func.push_transform (this, paint_data,
xx, yx, xy, yy, dx, dy,
font,
!user_data ? nullptr : user_data->push_transform); }
void pop_transform (void *paint_data)
{ func.pop_transform (this, paint_data,
void pop_transform (void *paint_data,
hb_font_t *font)
{ func.pop_transform (this, paint_data, font,
!user_data ? nullptr : user_data->pop_transform); }
void push_clip_glyph (void *paint_data,
hb_codepoint_t glyph)
hb_codepoint_t glyph,
hb_font_t *font)
{ func.push_clip_glyph (this, paint_data,
glyph,
font,
!user_data ? nullptr : user_data->push_clip_glyph); }
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)
{ func.push_clip_rectangle (this, paint_data,
xmin, ymin, xmax, ymax,
font,
!user_data ? nullptr : user_data->push_clip_rectangle); }
void pop_clip (void *paint_data)
{ func.pop_clip (this, paint_data,
void pop_clip (void *paint_data,
hb_font_t *font)
{ func.pop_clip (this, paint_data, font,
!user_data ? nullptr : user_data->pop_clip); }
void color (void *paint_data,
unsigned int color_index,
float alpha)
float alpha,
hb_font_t *font)
{ func.color (this, paint_data,
color_index, alpha,
font,
!user_data ? nullptr : user_data->color); }
void image (void *paint_data,
hb_blob_t *image,
hb_tag_t format,
hb_glyph_extents_t *extents)
hb_glyph_extents_t *extents,
hb_font_t *font)
{ func.image (this, paint_data,
image, format, extents,
font,
!user_data ? nullptr : user_data->image); }
void linear_gradient (void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float x1, float y1,
float x2, float y2)
float x2, float y2,
hb_font_t *font)
{ func.linear_gradient (this, paint_data,
color_line, x0, y0, x1, y1, x2, y2,
font,
!user_data ? nullptr : user_data->linear_gradient); }
void radial_gradient (void *paint_data,
hb_color_line_t *color_line,
float x0, float y0, float r0,
float x1, float y1, float r1)
float x1, float y1, float r1,
hb_font_t *font)
{ func.radial_gradient (this, paint_data,
color_line, x0, y0, r0, x1, y1, r1,
font,
!user_data ? nullptr : user_data->radial_gradient); }
void sweep_gradient (void *paint_data,
hb_color_line_t *color_line,
float x0, float y0,
float start_angle,
float end_angle)
float end_angle,
hb_font_t *font)
{ func.sweep_gradient (this, paint_data,
color_line, x0, y0, start_angle, end_angle,
font,
!user_data ? nullptr : user_data->sweep_gradient); }
void push_group (void *paint_data)
{ func.push_group (this, paint_data,
void push_group (void *paint_data,
hb_font_t *font)
{ func.push_group (this, paint_data, font,
!user_data ? nullptr : user_data->push_group); }
void pop_group (void *paint_data,
hb_paint_composite_mode_t mode)
hb_paint_composite_mode_t mode,
hb_font_t *font)
{ func.pop_group (this, paint_data,
mode,
font,
!user_data ? nullptr : user_data->pop_group); }
void push_root_transform (void *paint_data,
@@ -141,12 +162,34 @@ struct hb_paint_funcs_t
float upem = font->face->get_upem ();
float slant = font->slant_xy;
func.push_transform (this, paint_data, xscale/upem, 0, slant * yscale/upem, yscale/upem, 0, 0,
func.push_transform (this, paint_data,
xscale/upem, 0, slant * yscale/upem, yscale/upem, 0, 0,
font,
!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)
{
func.pop_transform (this, paint_data,
func.pop_transform (this, paint_data, font,
!user_data ? nullptr : user_data->pop_transform);
}
void push_inverse_root_transform (void *paint_data,
hb_font_t *font)
{
int xscale = font->x_scale, yscale = font->y_scale;
float upem = font->face->get_upem ();
float slant = font->slant_xy;
func.push_transform (this, paint_data,
upem/xscale, 0, slant * upem/xscale, upem/yscale, 0, 0,
font,
!user_data ? nullptr : user_data->push_transform);
}
void pop_inverse_root_transform (void *paint_data,
hb_font_t *font)
{
func.pop_transform (this, paint_data, font,
!user_data ? nullptr : user_data->pop_transform);
}
};
+1 -1
View File
@@ -33,10 +33,10 @@
#include "hb-common.h"
#include "hb-deprecated.h"
#include "hb-draw.h"
#include "hb-paint.h"
#include "hb-face.h"
#include "hb-font.h"
#include "hb-map.h"
#include "hb-paint.h"
#include "hb-set.h"
#include "hb-shape.h"
#include "hb-shape-plan.h"