mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-28 06:46:38 -04:00
vt: improve handling of codepoint 0xfe0f when grapheme-width-method != double-width
The Unicode codepoint 0xfe0f (Variation Selector 16) means the preceding emoji should be rendered with its graphical representation, rather than its text representation. This typically means a double-width glyph. Before this patch, we only handled this correctly for grapheme-width-method=double-width. In all other cases, we treated it as any other codepoint. Meaning, for ‘max’, we called wcwidth(0xfe0f), and compared against the last width. For ‘wcswidth’ (the default), we also called wcwidth(0xfe0f) and added this to the existing grapheme width. With this patch, ‘max’ is changed to treat 0xfe0f as if it has width == 2. So if the preceding emoji has width=1 (typically so), then we now assign it width 2. For `wcswidth`, we simply ignore the existing grapheme width and simply set it to two. This will be correct when 0xfe0f is used correctly, but may yield strange results otherwise.
This commit is contained in:
parent
3b9aca6a3d
commit
d83d7c0468
2 changed files with 10 additions and 1 deletions
|
|
@ -109,6 +109,10 @@
|
|||
config values (e.g. letter offsets, line height etc).
|
||||
* Selection being stuck visually when `IL` and `DL`.`
|
||||
* URL underlines sometimes still being visible after exiting URL mode.
|
||||
* Handling of Unicode Variation Selector-16 when
|
||||
`grapheme-width-method` is set to either `max` or `wcswidth` (the
|
||||
default). Before this, it was only handled correctly when
|
||||
`grapheme-width-method=double-width`.
|
||||
|
||||
[1173]: https://codeberg.org/dnkl/foot/issues/1173
|
||||
[1190]: https://codeberg.org/dnkl/foot/issues/1190
|
||||
|
|
|
|||
5
vt.c
5
vt.c
|
|
@ -832,6 +832,8 @@ action_utf8_print(struct terminal *term, char32_t wc)
|
|||
|
||||
switch (term->conf->tweak.grapheme_width_method) {
|
||||
case GRAPHEME_WIDTH_MAX:
|
||||
if (unlikely(wc == 0xfe0f))
|
||||
width = 2;
|
||||
new_cc->width = max(grapheme_width, width);
|
||||
break;
|
||||
|
||||
|
|
@ -842,6 +844,9 @@ action_utf8_print(struct terminal *term, char32_t wc)
|
|||
break;
|
||||
|
||||
case GRAPHEME_WIDTH_WCSWIDTH:
|
||||
if (unlikely(wc == 0xfe0f))
|
||||
new_cc->width = 2;
|
||||
else
|
||||
new_cc->width = grapheme_width + width;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue