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:
Daniel Eklöf 2022-12-14 12:33:56 +01:00
parent 3b9aca6a3d
commit d83d7c0468
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 10 additions and 1 deletions

View file

@ -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