diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-08-20 00:41:55 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-10-31 21:23:59 -0400 |
commit | 85bdfead1b36945db251df22b2db6789cbf4cd6c (patch) | |
tree | 94947aa03ed327bdd38ce74f14f1448c24dd0555 /pango/pango-renderer.c | |
parent | fc2aa99b829f9539d91b6036f1d148a17cc91a61 (diff) | |
download | pango-85bdfead1b36945db251df22b2db6789cbf4cd6c.tar.gz |
Draw strikethrough continuously
Average strikethrough position and thickness across
consecutive struckthrough runs. This gives an OK
result in common cases.
Diffstat (limited to 'pango/pango-renderer.c')
-rw-r--r-- | pango/pango-renderer.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c index df1eb538..51403785 100644 --- a/pango/pango-renderer.c +++ b/pango/pango-renderer.c @@ -46,6 +46,7 @@ struct _LineState gboolean strikethrough; PangoRectangle strikethrough_rect; + int strikethrough_glyphs; int logical_rect_end; }; @@ -251,16 +252,17 @@ draw_strikethrough (PangoRenderer *renderer, { PangoRectangle *rect = &state->strikethrough_rect; gboolean strikethrough = state->strikethrough; + int num_glyphs = state->strikethrough_glyphs; state->strikethrough = FALSE; if (strikethrough) pango_renderer_draw_rectangle (renderer, - PANGO_RENDER_PART_STRIKETHROUGH, - rect->x, - rect->y, - rect->width, - rect->height); + PANGO_RENDER_PART_STRIKETHROUGH, + rect->x, + rect->y / num_glyphs, + rect->width, + rect->height / num_glyphs); } static void @@ -365,7 +367,8 @@ add_strikethrough (PangoRenderer *renderer, int base_x, int base_y, PangoRectangle *ink_rect G_GNUC_UNUSED, - PangoRectangle *logical_rect) + PangoRectangle *logical_rect, + int num_glyphs) { PangoRectangle *current_rect = &state->strikethrough_rect; PangoRectangle new_rect; @@ -375,21 +378,22 @@ add_strikethrough (PangoRenderer *renderer, new_rect.x = base_x + logical_rect->x; new_rect.width = logical_rect->width; - new_rect.y = base_y - strikethrough_position; - new_rect.height = strikethrough_thickness; + new_rect.y = (base_y - strikethrough_position) * num_glyphs; + new_rect.height = strikethrough_thickness * num_glyphs; - if (state->strikethrough && - new_rect.y == current_rect->y && - new_rect.height == current_rect->height) + if (state->strikethrough) { current_rect->width = new_rect.x + new_rect.width - current_rect->x; + current_rect->y += new_rect.y; + current_rect->height += new_rect.height; + state->strikethrough_glyphs += num_glyphs; } else { draw_strikethrough (renderer, state); - *current_rect = new_rect; state->strikethrough = TRUE; + state->strikethrough_glyphs = num_glyphs; } } @@ -601,7 +605,7 @@ pango_renderer_draw_layout_line (PangoRenderer *renderer, if (renderer->strikethrough) add_strikethrough (renderer, &state, metrics, x + x_off, y - rise, - ink, logical); + ink, logical, run->glyphs->num_glyphs); pango_font_metrics_unref (metrics); } |