From aca9af020241a4b7e4c172a009bf8d4fcfc4e16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 8 Feb 2024 17:09:27 +0100 Subject: [PATCH] vt: VS16 - variation selector 16 (emoji representation) should only affect emojis --- CHANGELOG.md | 2 ++ vt.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3763aca0..24bd8a86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,8 @@ exactly 0 rows. This happens when `[scrollback].line = 0`, and the window size (number of rows) is a power of two (i.e. 2, 4, 8, 16 etc) ([#1610][1610]). +* VS16 (variation selector 16 - emoji representation) should only + affect emojis. [1531]: https://codeberg.org/dnkl/foot/issues/1531 [1573]: https://codeberg.org/dnkl/foot/issues/1573 diff --git a/vt.c b/vt.c index 7529f302..4d2bf487 100644 --- a/vt.c +++ b/vt.c @@ -850,8 +850,14 @@ action_utf8_print(struct terminal *term, char32_t wc) break; case GRAPHEME_WIDTH_DOUBLE: - if (unlikely(wc == 0xfe0f)) - width = 2; + if (unlikely(wc == 0xfe0f && new_cc->count == 2)) { + /* Only emojis should be affected by VS16 */ + const utf8proc_property_t *props = + utf8proc_get_property(new_cc->chars[0]); + + if (props->boundclass == UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC) + width = 2; + } new_cc->width = min(grapheme_width + width, 2); break;