From 8f3fcf8275d7ba9b99c94921d9415810a344f166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 25 Jan 2021 10:00:43 +0100 Subject: [PATCH] search: ad-hoc workaround for combining characters with positive x-offsets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When rendering the search input box, do the same ad-hoc workaround for combining characters with a positive x-offset as we do when rendering normal grid cells. In this case, we don’t *know* when we’re dealing with combining characters. But we can detect zero-width characters. For these, check their glyph’s x-offset. If positive, adjust it like we do when rendering combining glyphs in the main grid, to ensure the glyph is positioned over the _previous_ character, not the next. --- CHANGELOG.md | 1 + render.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 509a1972..fc3d168b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ * Scrollback search not matching composed characters. * High CPU usage when holding down e.g. arrow keys while in scrollback search mode. +* Rendering of composed characters in the scrollback search box. ### Security diff --git a/render.c b/render.c index 2dccd6a8..c298aaaa 100644 --- a/render.c +++ b/render.c @@ -2237,7 +2237,7 @@ render_search_box(struct terminal *term) /* Calculate the width of each character */ int widths[text_len + 1]; for (size_t i = 0; i < text_len; i++) - widths[i] = max(1, wcwidth(text[i])); + widths[i] = max(0, wcwidth(text[i])); widths[text_len] = 0; const size_t total_cells = wcswidth(text, text_len); @@ -2429,10 +2429,16 @@ render_search_box(struct terminal *term) x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); } else { + int combining_ofs = width == 0 + ? (glyph->x < 0 + ? width * term->cell_width + : (width - 1) * term->cell_width) + : 0; /* Not a zero-width character - no additional offset */ pixman_image_t *src = pixman_image_create_solid_fill(&fg); pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0, - x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y, + x + x_ofs + combining_ofs + glyph->x, + y + font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src); }