From 7549d36af2e79ebd86ae9cc05a86bfdc22dfebf8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 5 Jul 2021 19:16:25 -0400 Subject: renderer: Fix averaging of strikethroughs In 85bdfead1b36945db251 I made consecutive runs average their strikeout positions, but I did handle the accounting properly, causing previous runs to influence the strikeout of later runs, if we have to draw them separately (due to color change). It would be nicer to average even across color changes and draw the line continuously in that case as well, but that would require two passes over the runs. Fixes: #574 --- pango/pango-renderer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c index 49eec91d..f575707f 100644 --- a/pango/pango-renderer.c +++ b/pango/pango-renderer.c @@ -282,18 +282,22 @@ draw_strikethrough (PangoRenderer *renderer, LineState *state) { PangoRectangle *rect = &state->strikethrough_rect; - gboolean strikethrough = state->strikethrough; int num_glyphs = state->strikethrough_glyphs; - state->strikethrough = FALSE; - - if (strikethrough) + if (state->strikethrough) pango_renderer_draw_rectangle (renderer, PANGO_RENDER_PART_STRIKETHROUGH, rect->x, rect->y / num_glyphs, rect->width, rect->height / num_glyphs); + + state->strikethrough = FALSE; + state->strikethrough_glyphs = 0; + rect->x += rect->width; + rect->width = 0; + rect->y = 0; + rect->height = 0; } static void @@ -336,8 +340,6 @@ handle_line_state_change (PangoRenderer *renderer, rect->width = state->logical_rect_end - rect->x; draw_strikethrough (renderer, state); state->strikethrough = renderer->strikethrough; - rect->x = state->logical_rect_end; - rect->width = 0; } } @@ -484,7 +486,6 @@ add_strikethrough (PangoRenderer *renderer, } else { - draw_strikethrough (renderer, state); *current_rect = new_rect; state->strikethrough = TRUE; state->strikethrough_glyphs = num_glyphs; -- cgit v1.2.1