Score:1

Unicode characters do not have correct width in the terminal

mx flag

This doesn't happen with all unicode characters, but does happen with scissors: ✂️ It seems to be a problem independent of font as I've tried multiple different monospace fonts, patched and unpatched with "Nerd fonts" (I did try system default monospace)

neovim: scissors emoji in neovim scissors overlap the next character in neovim

vscode: scissors emoji rendered in vscode uses a different character / emoji set, but it looks like vscode renders differently, as there is no overlap

gedit: scissors emoji is rendered correctly renders as I'd expect: no overlap

terminal: scissors emoji in the terminal has the same problem as in neovim

github: https://github.com/NullVoxPopuli/dotfiles/blob/75ad3987e4eaa550e7dfb70a37ffe2b756594bd9/home/scripts/unme

github rendering of the scissors emoji GitHub in Firefox looks correct

Is there a way to configure the terminal to have consistent emoji/unicode width/rendering?

vanadium avatar
cn flag
No problem here in gnome-terminal or vim. Scissors character takes two spaces.
NullVoxPopuli avatar
mx flag
hmm -- I'm using gnome-terminal. I wonder if it could be my font. I'm using `DejaVuSansMono Nerd Font Mono` in my terminal. what font are you using?
NullVoxPopuli avatar
mx flag
added locale, bashrc, and link to bash_profile
NullVoxPopuli avatar
mx flag
updated with fzf.bash!
NullVoxPopuli avatar
mx flag
how would anything in my bash_profile affect how the terminal renders text tho?
NullVoxPopuli avatar
mx flag
oh, I just commented out my entire .bash_profile and opened a new terminal, and the problem persists -- so... I don't think it's at all related to my .bash_profile
Raffa avatar
jp flag
I checked on my system today and I get the same of what you describe ... It is a rendering issue not related to fonts as much as it is related to that special Unicode emoji ... Unicode characters/emojis come in different widths/spaces (single or double) ... gnome-terminal appears to have this problem of not correctly accounting for some double space characters ... a simple solution is to add an extra space after that character like so `dev="/✂️ /"`
Raffa avatar
jp flag
Please run this example `printf "|-|--|--|--|\n|\u2714|\u274c|\u270c|\u270c |\n^-^--^--^--^\n"` and compare how `u270c` needs an added space `u270c ` to be printed correctly while the character `u274c` is printed correctly although it is a double width like `u270c` ... It's just a matter of Unicode support.
NullVoxPopuli avatar
mx flag
So how do I improve unicode support in my terminal? is there anything I can do? does gnome-terminal need a bug reported? or.. would they care?
Raffa avatar
jp flag
gnome-terminal depends on [many components](https://packages.ubuntu.com/focal/gnome-terminal) among which [libcairo](https://packages.ubuntu.com/focal/libcairo2) which is the rendering engine/component …. So I would say a limitation rather than a bug … unfortunately AFAIK there is nothing you can do in this regard unless if you are willing to experiment with [other terminal emulators](https://www.tecmint.com/linux-terminal-emulators/) to see if any of them renders those unicode characters correctly.
NullVoxPopuli avatar
mx flag
Found the code -- https://gitlab.freedesktop.org/cairo/cairo/-/tree/master -- I'll open an issue and see where that goes
NullVoxPopuli avatar
mx flag
reported here: https://gitlab.freedesktop.org/cairo/cairo/-/issues/573
Милош Павловић avatar
ao flag
In terminal it's only a graphical representation of a character. Different font is used render emojis, most likely Noto Color Emoji. Does it overlaps with the text variation selector appended \ufe0e at the end `printf "\u2702\ufe0e"`? This is \u2702 with emoji presentation selector \ufe0e to force emoji `printf "\u2702\ufe0f"`
Милош Павловић avatar
ao flag
Btw, I remember I used pango to render images from emoji with imagemagick. `convert -list format | grep -i pango PANGO* PANGO r-- Pango Markup Language (Pangocairo 1.46.2)` The vommand was `convert -background transparent -pointsize 90 'pango:✂️' scissors.png` Most likely this library is used for rendering emojis [PangoCairo](https://docs.gtk.org/PangoCairo/). Yes [gitlab.gnome.org/GNOME/pango/-/tree/main/pango](https://gitlab.gnome.org/GNOME/pango/-/tree/main/pango)
Artur Meinild avatar
vn flag
Double-width Unicode characters will usually pose challenges with some terminal emulators. My suggestion is either to find a hack that makes it work for you, or only use single-width characters (if it needs to be compatible across multiple platforms).
Raffa avatar
jp flag
Nice and prompt reply from the cairo team ... I had a chance to test with pango and it appears it's not a problem there as well ... tried `pango-view --font="Ubuntu Mono 24" --text='dev="/✂️/"'` and it rendered correctly ... Mmmm are you thinking what I'm thinking? :) ... I'm thinking gnome-terminal's implementation of those libraries.
Raffa avatar
jp flag
After all this investigation, I think it’s worth a bug report to the gnome-terminal team (most likely it’s a bug in gnome-terminal’s implementation of those tow libraries) … I have to say, however, I am impressed by your enthusiasm and zeal following the root cause of this issue … I suggest you document what’s in the comments in an answer for posterity as I think it will be a valuable resource about text layout and rendering in gnome-terminal. Meanwhile, although chances are little, I hope someone will come up with a robust solution.
NullVoxPopuli avatar
mx flag
Reported here: https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7907 Hopefully someone sees it
Raffa avatar
jp flag
Please see `gedit /usr/share/i18n/charmaps/UTF-8.gz` ... it's the Unicode database/standard ... search in it for the codes mentioned in @МилошПавловић [comment](https://askubuntu.com/questions/1351278/unicode-characters-do-not-have-correct-width-in-the-terminal#comment2457287_1351278) `u2702`, `ufe0e` and `ufe0f` ... look at their description in that file ... It will help you write a canonical and more precise answer ... I am looking forward to reading it.
Милош Павловић avatar
ao flag
The issue is in the Vte Terminal widget [https://gitlab.gnome.org/GNOME/vte](https://gitlab.gnome.org/GNOME/vte). Not in gnome-terminal. Gnome terminal sets the cell size but Vte doesn't have a mechanism to expand individual cells if the glyph is bigger.
Raffa avatar
jp flag
@МилошПавловић I expanded the cells with `dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/cell-width-scale 2.0` and get what you mean `2.0`(double cell) but, it's a gnome-terminal issue either ways ... vte developers seem aware of this issue and explain how they handle it here: https://gitlab.gnome.org/GNOME/vte/-/blob/master/doc/ambiguous.txt
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.