mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
[color] Move slanting to font layer
COLRv1 is still being double-slanted. Investigating.
This commit is contained in:
1 parent
9dbb84e6fd
commit
a69713b520
11 files changed
+34
-32
No files matched your search
@@ -954,7 +954,7 @@ struct CBDT
|
||||
if (unlikely (blob == hb_blob_get_empty ()))
|
||||
return false;
|
||||
|
||||
if (unlikely (!hb_font_get_glyph_extents (font, glyph, &extents)))
|
||||
if (unlikely (!font->get_glyph_extents (glyph, &extents, false)))
|
||||
return false;
|
||||
|
||||
if (unlikely (!get_extents (font, glyph, &pixel_extents, false)))
|
||||
@@ -964,7 +964,7 @@ struct CBDT
|
||||
blob,
|
||||
pixel_extents.width, -pixel_extents.height,
|
||||
HB_PAINT_IMAGE_FORMAT_PNG,
|
||||
font->slant_xy,
|
||||
0.f,
|
||||
&extents);
|
||||
|
||||
hb_blob_destroy (blob);
|
||||
|
||||
@@ -2634,7 +2634,6 @@ struct COLR
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ugh. We need to undo the synthetic slant here. Leave it for now. :-(.
|
||||
extents->x_bearing = e.xmin;
|
||||
extents->y_bearing = e.ymax;
|
||||
extents->width = e.xmax - e.xmin;
|
||||
|
||||
@@ -244,7 +244,7 @@ struct sbix
|
||||
if (blob == hb_blob_get_empty ())
|
||||
return false;
|
||||
|
||||
if (!hb_font_get_glyph_extents (font, glyph, &extents))
|
||||
if (!font->get_glyph_extents (glyph, &extents, false))
|
||||
return false;
|
||||
|
||||
if (unlikely (!get_extents (font, glyph, &pixel_extents, false)))
|
||||
@@ -254,7 +254,7 @@ struct sbix
|
||||
blob,
|
||||
pixel_extents.width, -pixel_extents.height,
|
||||
HB_PAINT_IMAGE_FORMAT_PNG,
|
||||
font->slant_xy,
|
||||
0.f,
|
||||
&extents);
|
||||
|
||||
hb_blob_destroy (blob);
|
||||
|
||||
@@ -108,7 +108,7 @@ struct SVG
|
||||
blob,
|
||||
0, 0,
|
||||
HB_PAINT_IMAGE_FORMAT_SVG,
|
||||
font->slant_xy,
|
||||
0.f,
|
||||
nullptr);
|
||||
|
||||
hb_blob_destroy (blob);
|
||||
|
||||
@@ -101,7 +101,7 @@ _hb_cairo_paint_glyph_image (hb_cairo_context_t *c,
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
hb_tag_t format,
|
||||
float slant,
|
||||
HB_UNUSED float slant_deprecated,
|
||||
hb_glyph_extents_t *extents)
|
||||
{
|
||||
cairo_t *cr = c->cr;
|
||||
@@ -186,12 +186,6 @@ _hb_cairo_paint_glyph_image (hb_cairo_context_t *c,
|
||||
cairo_matrix_t matrix = {(double) width, 0, 0, (double) height, 0, 0};
|
||||
cairo_pattern_set_matrix (pattern, &matrix);
|
||||
|
||||
/* Undo slant in the extents and apply it in the context. */
|
||||
extents->width -= extents->height * slant;
|
||||
extents->x_bearing -= extents->y_bearing * slant;
|
||||
cairo_matrix_t cairo_matrix = {1., 0., (double) slant, 1., 0., 0.};
|
||||
cairo_transform (cr, &cairo_matrix);
|
||||
|
||||
cairo_translate (cr, extents->x_bearing, extents->y_bearing);
|
||||
cairo_scale (cr, extents->width, extents->height);
|
||||
cairo_set_source (cr, pattern);
|
||||
|
||||
+14
-3
@@ -580,15 +580,26 @@ struct hb_font_t
|
||||
}
|
||||
|
||||
void paint_glyph (hb_codepoint_t glyph,
|
||||
hb_paint_funcs_t *paint_funcs, void *paint_data,
|
||||
unsigned int palette,
|
||||
hb_color_t foreground)
|
||||
hb_paint_funcs_t *paint_funcs, void *paint_data,
|
||||
unsigned int palette,
|
||||
hb_color_t foreground,
|
||||
bool synthetic = true)
|
||||
{
|
||||
/* Slant */
|
||||
if (synthetic && slant_xy)
|
||||
hb_paint_push_transform (paint_funcs, paint_data,
|
||||
1.f, 0.f,
|
||||
slant_xy, 1.f,
|
||||
0.f, 0.f);
|
||||
|
||||
klass->get.f.paint_glyph (this, user_data,
|
||||
glyph,
|
||||
paint_funcs, paint_data,
|
||||
palette, foreground,
|
||||
!klass->user_data ? nullptr : klass->user_data->paint_glyph);
|
||||
|
||||
if (synthetic && slant_xy)
|
||||
hb_paint_pop_transform (paint_funcs, paint_data);
|
||||
}
|
||||
|
||||
/* A bit higher-level, and with fallback */
|
||||
|
||||
+2
-6
@@ -518,13 +518,9 @@ hb_ft_paint_glyph_colr (hb_font_t *font,
|
||||
if (FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box))
|
||||
{
|
||||
c.funcs->push_clip_rectangle (c.data,
|
||||
clip_box.bottom_left.x +
|
||||
roundf (hb_min (font->slant_xy * clip_box.bottom_left.y,
|
||||
font->slant_xy * clip_box.top_left.y)),
|
||||
clip_box.bottom_left.x,
|
||||
clip_box.bottom_left.y,
|
||||
clip_box.top_right.x +
|
||||
roundf (hb_max (font->slant_xy * clip_box.bottom_right.y,
|
||||
font->slant_xy * clip_box.top_right.y)),
|
||||
clip_box.top_right.x,
|
||||
clip_box.top_right.y);
|
||||
clip = true;
|
||||
is_bounded = true;
|
||||
|
||||
+2
-2
@@ -951,7 +951,7 @@ hb_ft_paint_glyph (hb_font_t *font,
|
||||
nullptr, nullptr);
|
||||
|
||||
hb_glyph_extents_t extents;
|
||||
if (!hb_font_get_glyph_extents (font, gid, &extents))
|
||||
if (!font->get_glyph_extents (gid, &extents, false))
|
||||
goto out;
|
||||
|
||||
if (!paint_funcs->image (paint_data,
|
||||
@@ -959,7 +959,7 @@ hb_ft_paint_glyph (hb_font_t *font,
|
||||
bitmap.width,
|
||||
bitmap.rows,
|
||||
HB_PAINT_IMAGE_FORMAT_BGRA,
|
||||
font->slant_xy,
|
||||
0.f,
|
||||
&extents))
|
||||
{
|
||||
/* TODO Try a forced outline load and paint? */
|
||||
|
||||
+3
-3
@@ -615,7 +615,7 @@ hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
|
||||
* @width: width of the raster image in pixels, or 0
|
||||
* @height: height of the raster image in pixels, or 0
|
||||
* @format: the image format as a tag
|
||||
* @slant: the synthetic slant ratio to be applied to the image during rendering
|
||||
* @slant: Deprecated. set to 0.0
|
||||
* @extents: (nullable): the extents of the glyph
|
||||
*
|
||||
* Perform a "image" paint operation.
|
||||
@@ -628,10 +628,10 @@ hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
hb_tag_t format,
|
||||
float slant,
|
||||
HB_UNUSED float slant,
|
||||
hb_glyph_extents_t *extents)
|
||||
{
|
||||
funcs->image (paint_data, image, width, height, format, slant, extents);
|
||||
funcs->image (paint_data, image, width, height, format, 0.f, extents);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -281,7 +281,7 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
|
||||
* @width: width of the raster image in pixels, or 0
|
||||
* @height: height of the raster image in pixels, or 0
|
||||
* @format: the image format as a tag
|
||||
* @slant: the synthetic slant ratio to be applied to the image during rendering
|
||||
* @slant: Deprecated. Always set to 0.0.
|
||||
* @extents: (nullable): glyph extents for desired rendering
|
||||
* @user_data: User data pointer passed to hb_paint_funcs_set_image_func()
|
||||
*
|
||||
|
||||
+6
-4
@@ -162,10 +162,11 @@ struct hb_paint_funcs_t
|
||||
{
|
||||
float upem = font->face->get_upem ();
|
||||
int xscale = font->x_scale, yscale = font->y_scale;
|
||||
float slant = font->slant_xy;
|
||||
|
||||
push_transform (paint_data,
|
||||
xscale/upem, 0, slant * yscale/upem, yscale/upem, 0, 0);
|
||||
xscale/upem, 0,
|
||||
0, yscale/upem,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
void push_inverse_font_transform (void *paint_data,
|
||||
@@ -174,10 +175,11 @@ struct hb_paint_funcs_t
|
||||
float upem = font->face->get_upem ();
|
||||
int xscale = font->x_scale ? font->x_scale : upem;
|
||||
int yscale = font->y_scale ? font->y_scale : upem;
|
||||
float slant = font->slant_xy;
|
||||
|
||||
push_transform (paint_data,
|
||||
upem/xscale, 0, -slant * upem/xscale, upem/yscale, 0, 0);
|
||||
upem/xscale, 0,
|
||||
0, upem/yscale,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
HB_NODISCARD
|
||||
|
||||
Reference in new issue
Block a user