Skip to content

Commit

Permalink
Improve README Emoji mode table
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed Nov 18, 2024
1 parent 4ccf617 commit 727075e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
(Emoji themselves might display differently)
- Set default Emoji mode for unknown/unsupported terminals to `:none`
(instead of `:basic`)
- Rename `:basic` mode to `:vs16`


## 3.0.1
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,35 @@ Emoji Type | Width / Comment
------------|----------------
Basic/Single Emoji character without Variation Selector | No special handling
Basic/Single Emoji character with VS15 (Text) | No special handling
Basic/Single Emoji character with VS16 (Emoji) | 2 (except with `emoji: :none` or `emoji: :all_no_vs16`)
Emoji Sequence | 2 if Emoji belongs to configured Emoji set
Basic/Single Emoji character with VS16 (Emoji) | 2 or East Asian Width (see below)
Emoji Sequence | 2 if Emoji belongs to configured Emoji set (see below)

#### Emoji Modes

The `emoji:` option can be used to configure which type of Emoji should be considered to have a width of 2 and if VS16-Emoji should be widened. Other sequences are treated as non-combined Emoji, so the widths of all partial Emoji add up (e.g. width of one basic Emoji + one skin tone modifier + another basic Emoji). The following Emoji settings can be used:

Option | Description | Example Terminals
-------|-------------|------------------
`emoji: true` or `emoji: :auto` | Automatically use recommended Emoji setting for your terminal | -
`emoji: false` or `emoji: :none` | No Emoji adjustments, Emoji characters with VS16 not handled | Gnome Terminal, many older terminals
`emoji: :basic` | Full-width VS16-Emoji, but no width adjustments for Emoji sequences: All partial Emoji treated separately with a width of 2 | ?
`emoji: :rgi` | Full-width VS16-Emoji, all RGI Emoji sequences are considered to have a width of 2 | Apple Terminal
`emoji: :possible`| Full-width VS16-Emoji, all possible/well-formed Emoji sequences are considered to have a width of 2 | ?
`emoji: :all` | Full-width VS16-Emoji, all ZWJ/modifier/keycap sequences have a width of 2, even if they are not well-formed Emoji sequences | foot, Contour
`emoji: :all_no_vs16` | VS16-Emoji not handled, all ZWJ/modifier/keycap sequences to have a width of 2, even if they are not well-formed Emoji sequences | WezTerm
Option | VS16-Emoji Width | Emoji Sequences Width / Comment | Example Terminals
-------|------------------|---------------------------------|------------------
`emoji: true` or `emoji: :auto` | - | Automatically use recommended Emoji setting for your terminal | -
`emoji: :all` | 2 | 2 for all ZWJ/modifier/keycap sequences, even if they are not well-formed Emoji sequences | foot, Contour
`emoji: :all_no_vs16` | EAW (1 or 2) | 2 for all ZWJ/modifier/keycap sequences, even if they are not well-formed Emoji sequences | WezTerm
`emoji: :possible`| 2 | 2 for all possible/well-formed Emoji sequences | ?
`emoji: :rgi` | 2 | 2 for all [RGI Emoji](https://www.unicode.org/reports/tr51/#def_rgi_set) sequences | ?
`emoji: :vs16` | 2 | 2 * number of partial Emoji (sequences never considered to be a single / combined Emoji) | kitty
`emoji: false` or `emoji: :none` | EAW (1 or 2) | No Emoji adjustments | gnome-terminal, many older terminals

- *RGI Emoji:* Emoji Recommended for General Interchange
- *ZWJ:* Zero-width Joiner: Codepoint `U+200D`,used in many Emoji sequences

#### Emoji Support in Terminals

Unfortunately, the level of Emoji support varies a lot between terminals. While some of them are able to display (almost) all Emoji sequences correctly, others fall back to displaying sequences of basic Emoji. When `emoji: true` or `emoji: :auto` is used, the gem will attempt to set the best fitting Emoji setting for you (e.g. `:rgi` on "Apple_Terminal" or `:none` on Gnome's terminal widget).
Unfortunately, the level of Emoji support varies a lot between terminals. While some of them are able to display (almost) all Emoji sequences correctly, others fall back to displaying sequences of basic Emoji. When `emoji: true` or `emoji: :auto` is used, the gem will attempt to set the best fitting Emoji setting for you (e.g. `:rgi_at` on "Apple_Terminal" or `:none` on Gnome's terminal widget).

Note that Emoji display and number of terminal columns used might differs a lot. For example, it might be the case that a terminal does not understand which Emoji to display, but still manages to calculate the proper amount of terminal cells. The automatic Emoji support level per terminal only considers the latter (cursor position), not the actual Emoji image(s) displayed. Please [open an issue](https://github.com/janlelis/unicode-display_width/issues/new) if you notice your terminal application could use a better default value. Also see the [ucs-detect project], which is a great resource that compares various terminal's Unicode/Emoji capabilities.
Please note that Emoji display and number of terminal columns used might differs a lot. For example, it might be the case that a terminal does not understand which Emoji to display, but still manages to calculate the proper amount of terminal cells. The automatic Emoji support level per terminal only considers the latter (cursor position), not the actual Emoji image(s) displayed. Please [open an issue](https://github.com/janlelis/unicode-display_width/issues/new) if you notice your terminal application could use a better default value. Also see the [ucs-detect project], which is a great resource that compares various terminal's Unicode/Emoji capabilities.

---

To terminal implementors reading this: Although handling Emoji/ZWJ sequences as always having a width of 2 (`:all` mode described above) has some advantages, it does not lead to a particularly good developer experience. Since there is always the possibility of well-formed Emoji that are currently not supported (non-RGI / future Unicode) appearing, those sequences will take more cells. Instead of overflowing, cutting off sequences or displaying placeholder-Emoji, could it be worthwile to implement the `:rgi` option (see table above) and just give those unknown Emoji the space they need? It is painful to implement, I know, but it kind of underlines the idea that the meaning of an unknown Emoji sequence can still be conveyed (without messing up the terminal at the same time). Just a thought…
**To terminal implementors reading this:** Although handling Emoji/ZWJ sequences as always width 2 (`:all` mode described above) has some advantages, it does not lead to a particularly good developer experience. Since there is always the possibility of well-formed Emoji that are currently not supported (non-RGI / future Unicode) appearing, those sequences will take more cells. Instead of overflowing, cutting off sequences or displaying placeholder-Emoji, could it be worthwile to implement the `:rgi` option (only known Emoji get width 2) and give those unknown Emoji the space they need? It is painful to implement, I know, but it kind of underlines the idea that the meaning of an unknown Emoji sequence can still be conveyed (without messing up the terminal at the same time). Just a thought…

---

Expand Down

0 comments on commit 727075e

Please sign in to comment.