[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 2022-12-21 02:11:36 -05:00 committed by Behdad Esfahbod
parent 32ce29f99e
commit 97224f3b63
33 changed files with 639 additions and 457 deletions

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;
}

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) =

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;
}

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;
}

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;

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);
}
}

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;
@ -549,7 +553,8 @@ struct PaintSolid
{
c->funcs->color (c->data,
paletteIndex,
alpha.to_float (c->instancer (varIdxBase, 0)));
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;
}

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;

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;

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

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

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);
}
};

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"

View File

@ -0,0 +1,97 @@
start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 15
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 16
solid 0 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 21
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 18
solid 2 0.200012
end clip
end transform
pop group mode 3
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 20
solid 9 1.000000
end clip
end transform
pop group mode 3
end transform

View File

@ -1,79 +0,0 @@
start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
push group
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
pop group mode 3
push group
start clip glyph 15
solid 9 1.000000
end clip
pop group mode 3
push group
start clip glyph 16
solid 0 1.000000
end clip
pop group mode 3
push group
start clip glyph 21
solid 9 1.000000
end clip
pop group mode 3
push group
push group
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
pop group mode 3
push group
start clip glyph 18
solid 2 0.200012
end clip
pop group mode 3
pop group mode 3
push group
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 20
solid 9 1.000000
end clip
pop group mode 3
end transform

View File

@ -0,0 +1,97 @@
start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 15
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 16
solid 0 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 21
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 18
solid 2 0.200012
end clip
end transform
pop group mode 3
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 20
solid 9 1.000000
end clip
end transform
pop group mode 3
end transform

View File

@ -1,79 +0,0 @@
start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
push group
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
pop group mode 3
push group
start clip glyph 15
solid 9 1.000000
end clip
pop group mode 3
push group
start clip glyph 16
solid 0 1.000000
end clip
pop group mode 3
push group
start clip glyph 21
solid 9 1.000000
end clip
pop group mode 3
push group
push group
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
pop group mode 3
push group
start clip glyph 18
solid 2 0.200012
end clip
pop group mode 3
pop group mode 3
push group
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 20
solid 9 1.000000
end clip
pop group mode 3
end transform

View File

@ -0,0 +1,14 @@
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 clip glyph 174
sweep gradient
center 500.000000 600.000000
angles 0.000000 6.283185
colors
0.250000 7 1.000000
0.416687 4 1.000000
0.583313 0 1.000000
0.750000 8 1.000000
end clip
end transform
end transform

View File

@ -1,12 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 174
sweep gradient
center 500.000000 600.000000
angles 0.000000 6.283185
colors
0.250000 7 1.000000
0.416687 4 1.000000
0.583313 0 1.000000
0.750000 8 1.000000
end clip
end transform

View File

@ -1,18 +1,22 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 4 0.500000
end clip
end transform
push group
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 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 clip glyph 3
solid 1 0.700012
end clip
end transform
end transform
end transform
end transform
pop group mode 4
pop group mode 3
end transform

View File

@ -0,0 +1,18 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 4 0.500000
end clip
end transform
push group
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 clip glyph 3
solid 1 0.700012
end clip
end transform
end transform
pop group mode 4
pop group mode 3
end transform

View File

@ -1,14 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start clip glyph 3
solid 4 0.500000
end clip
push group
start transform 1.000000 0.000000 0.000000 1.000000 200.000000 200.000000
start clip glyph 3
solid 1 0.700012
end clip
end transform
pop group mode 4
pop group mode 3
end transform

View File

@ -1,30 +1,36 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 10 1.000000
end clip
end transform
pop group mode 3
push group
push group
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 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 clip glyph 2
solid 12 1.000000
end clip
end transform
end transform
end transform
end transform
push group
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 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 clip glyph 2
solid 11 1.000000
end clip
end transform
end transform
end transform
end transform
pop group mode 5
pop group mode 3
pop group mode 3

View File

@ -0,0 +1,14 @@
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 clip glyph 165
linear gradient
p0 100.000000 950.000000
p1 2300.000000 950.000000
p2 -1000.000000 250.000000
colors
0.000000 0 1.000000
0.500000 4 1.000000
1.000000 2 1.000000
end clip
end transform
end transform

View File

@ -1,12 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 165
linear gradient
p0 100.000000 950.000000
p1 2300.000000 950.000000
p2 -1000.000000 250.000000
colors
0.000000 0 1.000000
0.500000 4 1.000000
1.000000 2 1.000000
end clip
end transform

View File

@ -0,0 +1,26 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
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 clip glyph 174
solid 3 1.000000
end clip
end transform
end transform
pop group mode 3
push group
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 clip glyph 174
linear gradient
p0 500.000000 250.000000
p1 500.000000 950.000000
p2 600.000000 250.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
end transform
pop group mode 3
end transform

View File

@ -1,22 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 1.000000 0.000000 0.000000 1.000000 150.000000 0.000000
start clip glyph 174
solid 3 1.000000
end clip
end transform
pop group mode 3
push group
start transform 1.000000 0.000000 0.000000 1.000000 -150.000000 0.000000
start clip glyph 174
linear gradient
p0 500.000000 250.000000
p1 500.000000 950.000000
p2 600.000000 250.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
pop group mode 3
end transform

View File

@ -0,0 +1,13 @@
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 clip glyph 6
linear gradient
p0 100.000000 250.000000
p1 900.000000 250.000000
p2 100.000000 300.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
end transform

View File

@ -1,11 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 6
linear gradient
p0 100.000000 250.000000
p1 900.000000 250.000000
p2 100.000000 300.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform

View File

@ -0,0 +1,13 @@
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 clip glyph 2
radial gradient
p0 166.000000 768.000000 radius 0.000000
p1 166.000000 768.000000 radius 256.000000
colors
0.000000 3 1.000000
0.500000 9 1.000000
1.000000 0 1.000000
end clip
end transform
end transform

View File

@ -1,11 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 2
radial gradient
p0 166.000000 768.000000 radius 0.000000
p1 166.000000 768.000000 radius 256.000000
colors
0.000000 3 1.000000
0.500000 9 1.000000
1.000000 0 1.000000
end clip
end transform

View File

@ -484,6 +484,7 @@ push_transform (hb_paint_funcs_t *funcs,
float xx, float yx,
float xy, float yy,
float dx, float dy,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -495,6 +496,7 @@ push_transform (hb_paint_funcs_t *funcs,
static void
pop_transform (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -507,6 +509,7 @@ static void
push_clip_glyph (hb_paint_funcs_t *funcs,
void *paint_data,
hb_codepoint_t glyph,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -519,6 +522,7 @@ static void
push_clip_rectangle (hb_paint_funcs_t *funcs,
void *paint_data,
float xmin, float ymin, float xmax, float ymax,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -530,6 +534,7 @@ push_clip_rectangle (hb_paint_funcs_t *funcs,
static void
pop_clip (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -543,6 +548,7 @@ paint_color (hb_paint_funcs_t *funcs,
void *paint_data,
unsigned int color_index,
float alpha,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -556,6 +562,7 @@ paint_image (hb_paint_funcs_t *funcs,
hb_blob_t *blob,
hb_tag_t format,
hb_glyph_extents_t *extents,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -591,6 +598,7 @@ paint_linear_gradient (hb_paint_funcs_t *funcs,
float x0, float y0,
float x1, float y1,
float x2, float y2,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -611,6 +619,7 @@ paint_radial_gradient (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)
{
paint_data_t *data = user_data;
@ -631,6 +640,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
float cx, float cy,
float start_angle,
float end_angle,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -647,6 +657,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
static void
push_group (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -658,6 +669,7 @@ static void
pop_group (hb_paint_funcs_t *funcs,
void *paint_data,
hb_paint_composite_mode_t mode,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@ -677,16 +689,16 @@ typedef struct {
#define TEST_GLYPHS "fonts/test_glyphs-glyf_colr_1.ttf"
static colrv1_test_t colrv1_tests[] = {
{ NOTO_HAND, 20, 0., 10, "results/hand-20-0-10.txt" },
{ NOTO_HAND, 20, 0.2, 10, "results/hand-20-0.2-10.txt" },
{ TEST_GLYPHS, 20, 0, 6, "results/test-20-0-6.txt" },
{ TEST_GLYPHS, 20, 0, 10, "results/test-20-0-10.txt" },
{ TEST_GLYPHS, 20, 0, 92, "results/test-20-0-92.txt" },
{ TEST_GLYPHS, 20, 0, 106, "results/test-20-0-106.txt" },
{ TEST_GLYPHS, 20, 0, 116, "results/test-20-0-116.txt" },
{ TEST_GLYPHS, 20, 0, 123, "results/test-20-0-123.txt" },
{ TEST_GLYPHS, 20, 0, 165, "results/test-20-0-165.txt" },
{ TEST_GLYPHS, 20, 0, 175, "results/test-20-0-175.txt" },
{ NOTO_HAND, 20, 0., 10, "hand-20-0-10" },
{ NOTO_HAND, 20, 0.2, 10, "hand-20-0.2-10" },
{ TEST_GLYPHS, 20, 0, 6, "test-20-0-6" },
{ TEST_GLYPHS, 20, 0, 10, "test-20-0-10" },
{ TEST_GLYPHS, 20, 0, 92, "test-20-0-92" },
{ TEST_GLYPHS, 20, 0, 106, "test-20-0-106" },
{ TEST_GLYPHS, 20, 0, 116, "test-20-0-116" },
{ TEST_GLYPHS, 20, 0, 123, "test-20-0-123" },
{ TEST_GLYPHS, 20, 0, 165, "test-20-0-165" },
{ TEST_GLYPHS, 20, 0, 175, "test-20-0-175" },
};
static void
@ -738,7 +750,7 @@ test_hb_ot_color_colr_v1 (gconstpointer d)
exit (0);
}
file = g_test_build_filename (G_TEST_DIST, test->output, NULL);
file = g_test_build_filename (G_TEST_DIST, "results", test->output, NULL);
if (!g_file_get_contents (file, &buffer, &len, &error))
{
g_test_message ("File %s not found.", file);
@ -820,11 +832,7 @@ main (int argc, char **argv)
hb_test_add (test_hb_ot_color_png);
hb_test_add (test_hb_ot_color_svg);
for (unsigned int i = 0; i < G_N_ELEMENTS (colrv1_tests); i++)
{
char buf[10] = { 0, };
g_snprintf (buf, 10, "%d", i);
hb_test_add_data_flavor (&colrv1_tests[i], buf, test_hb_ot_color_colr_v1);
}
hb_test_add_data_flavor (&colrv1_tests[i], colrv1_tests[i].output, test_hb_ot_color_colr_v1);
status = hb_test_run();
hb_face_destroy (cpal_v0);

View File

@ -105,36 +105,30 @@ get_cairo_draw_funcs (void)
#ifdef HAVE_CAIRO_USER_FONT_FACE_SET_RENDER_COLOR_GLYPH_FUNC
typedef struct {
cairo_t *cr;
hb_font_t *font;
hb_font_t *unscaled_font;
} paint_data_t;
static void
push_transform (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)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_matrix_t m;
cairo_save (cr);
cairo_matrix_init (&m, xx, yx, xy, yy, dx, dy);
cairo_transform (data->cr, &m);
cairo_transform (cr, &m);
}
static void
pop_transform (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_restore (cr);
}
@ -143,14 +137,14 @@ static void
push_clip_glyph (hb_paint_funcs_t *funcs,
void *paint_data,
hb_codepoint_t glyph,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_save (cr);
cairo_new_path (cr);
hb_font_get_glyph_shape (data->unscaled_font, glyph, get_cairo_draw_funcs (), cr);
hb_font_get_glyph_shape (font, glyph, get_cairo_draw_funcs (), cr);
cairo_close_path (cr);
cairo_clip (cr);
}
@ -159,10 +153,10 @@ static void
push_clip_rectangle (hb_paint_funcs_t *funcs,
void *paint_data,
float xmin, float ymin, float xmax, float ymax,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_save (cr);
cairo_rectangle (cr, xmin, ymin, xmax - xmin, ymax - ymin);
@ -172,10 +166,10 @@ push_clip_rectangle (hb_paint_funcs_t *funcs,
static void
pop_clip (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_restore (cr);
}
@ -183,10 +177,10 @@ pop_clip (hb_paint_funcs_t *funcs,
static void
push_group (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_save (cr);
cairo_push_group (cr);
@ -196,10 +190,10 @@ static void
pop_group (hb_paint_funcs_t *funcs,
void *paint_data,
hb_paint_composite_mode_t mode,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
cairo_pop_group_to_source (cr);
cairo_set_operator (cr, hb_paint_composite_mode_to_cairo (mode));
@ -213,11 +207,11 @@ paint_color (hb_paint_funcs_t *funcs,
void *paint_data,
unsigned int color_index,
float alpha,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
hb_face_t *face = hb_font_get_face (data->font);
cairo_t *cr = data->cr;
cairo_t *cr = (cairo_t *)paint_data;
hb_face_t *face = hb_font_get_face (font);
float r, g, b, a;
hb_face_get_color (face, 0, color_index, alpha, &r, &g, &b, &a);
@ -231,11 +225,10 @@ paint_image (hb_paint_funcs_t *funcs,
hb_blob_t *blob,
hb_tag_t format,
hb_glyph_extents_t *extents,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
hb_font_t *font = data->font;
cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_glyph_image (cr, font, blob, format, extents);
}
@ -247,11 +240,10 @@ paint_linear_gradient (hb_paint_funcs_t *funcs,
float x0, float y0,
float x1, float y1,
float x2, float y2,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
hb_font_t *font = data->font;
cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_linear_gradient (cr, font, color_line, x0, y0, x1, y1, x2, y2);
}
@ -262,11 +254,10 @@ paint_radial_gradient (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)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
hb_font_t *font = data->font;
cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_radial_gradient (cr, font, color_line, x0, y0, r0, x1, y1, r1);
}
@ -277,11 +268,10 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line,
float x0, float y0,
float start_angle, float end_angle,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = (paint_data_t *) paint_data;
cairo_t *cr = data->cr;
hb_font_t *font = data->font;
cairo_t *cr = (cairo_t *)paint_data;
hb_cairo_paint_sweep_gradient (cr, font, color_line, x0, y0, start_angle, end_angle);
}
@ -357,22 +347,12 @@ render_color_glyph (cairo_scaled_font_t *scaled_font,
{
hb_font_t *font = (hb_font_t *) (cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
&_hb_font_cairo_user_data_key));
paint_data_t paint_data;
paint_data.cr = cr;
paint_data.font = font;
hb_face_t *face = hb_font_get_face (font);
paint_data.unscaled_font = hb_font_create (face);
unsigned int upem = hb_face_get_upem (face);
hb_font_set_scale (paint_data.unscaled_font, upem, upem);
hb_font_set_synthetic_slant (paint_data.unscaled_font, 0.);
hb_position_t x_scale, y_scale;
hb_font_get_scale (font, &x_scale, &y_scale);
cairo_scale (cr, +1./x_scale, -1./y_scale);
hb_font_paint_glyph (font, glyph, get_cairo_paint_funcs (), (void *)&paint_data);
hb_font_paint_glyph (font, glyph, get_cairo_paint_funcs (), cr);
hb_glyph_extents_t hb_extents;
hb_font_get_glyph_extents (font, glyph, &hb_extents);
@ -381,8 +361,6 @@ render_color_glyph (cairo_scaled_font_t *scaled_font,
extents->width = (double) hb_extents.width / x_scale;
extents->height = (double)-hb_extents.height / y_scale;
hb_font_destroy (paint_data.unscaled_font);
return CAIRO_STATUS_SUCCESS;
}