From c0d9f92e1a5aae2f0963d62f9fd480a5926f2d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 15 Jun 2021 17:52:45 +0200 Subject: [PATCH] =?UTF-8?q?render:=20don=E2=80=99t=20modify=20the=20cell?= =?UTF-8?q?=E2=80=99s=20x=20position.=20Fixes=20broken=20underlines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/render.c b/render.c index 6799f23a..d46cb90b 100644 --- a/render.c +++ b/render.c @@ -449,8 +449,8 @@ render_cell(struct terminal *term, pixman_image_t *pix, int width = term->cell_width; int height = term->cell_height; - int x = term->margins.left + col * width; - int y = term->margins.top + row_no * height; + const int x = term->margins.left + col * width; + const int y = term->margins.top + row_no * height; xassert(cell->attrs.selected == 0 || cell->attrs.selected == 1); bool is_selected = cell->attrs.selected; @@ -668,6 +668,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_image_t *clr_pix = pixman_image_create_solid_fill(&fg); + int pen_x = x; for (unsigned i = 0; i < glyph_count; i++) { const int letter_x_ofs = i == 0 ? term->font_x_ofs : 0; @@ -686,13 +687,13 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (!(cell->attrs.blink && term->blink.state == BLINK_OFF)) { pixman_image_composite32( PIXMAN_OP_OVER, glyph->pix, NULL, pix, 0, 0, 0, 0, - x + letter_x_ofs + g_x, y + font_baseline(term) - g_y, + pen_x + letter_x_ofs + g_x, y + font_baseline(term) - g_y, glyph->width, glyph->height); } } else { pixman_image_composite32( PIXMAN_OP_OVER, clr_pix, glyph->pix, pix, 0, 0, 0, 0, - x + letter_x_ofs + g_x, y + font_baseline(term) - g_y, + pen_x + letter_x_ofs + g_x, y + font_baseline(term) - g_y, glyph->width, glyph->height); /* Combining characters */ @@ -731,14 +732,14 @@ render_cell(struct terminal *term, pixman_image_t *pix, PIXMAN_OP_OVER, clr_pix, g->pix, pix, 0, 0, 0, 0, /* Some fonts use a negative offset, while others use a * "normal" offset */ - x + x_ofs + g->x, + pen_x + x_ofs + g->x, y + font_baseline(term) - g->y, g->width, g->height); } } } - x += glyph->advance.x; + pen_x += glyph->advance.x; } pixman_image_unref(clr_pix);