From 396a5ff79b6d59e1f187ba8d0a99d3aa58870fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 2 Jul 2021 16:29:08 +0200 Subject: [PATCH] allow-overflowing-double-width-glyphs: take glyph offset into account A narrow, but offset:ed glyph should still be considered double width. This patch also fixes a crash, when the maybe-double width glyph is in the last column. This is a regression. --- CHANGELOG.md | 7 +++++++ render.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3908ca8..a7dd2a15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,13 @@ ### Deprecated ### Removed ### Fixed + +* Glyph offset not being taken into account when applying + `tweak.allow-overflowing-double-width-glyphs`. +* Regression: crash when a single-char, double-width glyph is in the + last column, and `tweak.allow-overflowing-double-width-glyphs=yes`. + + ### Security ### Contributors diff --git a/render.c b/render.c index 499303f0..dbca64aa 100644 --- a/render.c +++ b/render.c @@ -618,13 +618,13 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (term->conf->tweak.allow_overflowing_double_width_glyphs && ((glyph_count > 0 && cell_cols == 1 && - glyphs[0]->width >= term->cell_width * 15 / 10 && - glyphs[0]->width < 3 * term->cell_width && - col < term->cols - 1) || + glyphs[0]->x + glyphs[0]->width >= term->cell_width * 15 / 10 && + glyphs[0]->x + glyphs[0]->width < 3 * term->cell_width) || (term->conf->tweak.pua_double_width && ((base >= 0x00e000 && base <= 0x00f8ff) || (base >= 0x0f0000 && base <= 0x0ffffd) || (base >= 0x100000 && base <= 0x10fffd)))) && + col < term->cols - 1 && (row->cells[col + 1].wc == 0 || row->cells[col + 1].wc == L' ')) { cell_cols = 2;