Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emoji generates rendering problem #836

Closed
guillaumebreton opened this issue Mar 23, 2017 · 22 comments
Closed

Emoji generates rendering problem #836

guillaumebreton opened this issue Mar 23, 2017 · 22 comments

Comments

@guillaumebreton
Copy link

guillaumebreton commented Mar 23, 2017

Summary

When an emoji is rendered on the screen, other characters are not rendered at their correct places.

How to reproduce

I've built a test program in Go which displays an emoji and waits for an input. As soon as the input is renderer, an invalid space is placed in front of the line, and if a backspace is used, the complete input is mangled. If the line is selected using the mouse, the complete screen is badly rendered.

Here is a video of the problem : https://youtu.be/R1GpJX7uEdw

This video use the following configuration : https://github.com/guillaumebreton/dotfiles/blob/master/tmux/tmux.conf.symlink

The bug is not present outside TMUX (ie. inside iterm2)

Environment

Platform : Darwin i386 with Iterm2 (Build 3.0.14)
Tmux version : tmux 2.3
$TERM outside TMUX : xterm-256color
$TERM inside TMUX : screen-256color

Logs

Logs of a session with no configuration (as found in CONTRIBUTING.md)
logs.zip

@nicm
Copy link
Member

nicm commented Mar 23, 2017 via email

@guillaumebreton
Copy link
Author

Let me try to build master with --enable-utf8proc 👍

@guillaumebreton
Copy link
Author

The bug is still present with master without --enable-utf8proc.

I tried ./configure --enable-utf8proc but it does not seem to work (configure: error: "utf8proc not found"). How can I use this flag ?

@nicm
Copy link
Member

nicm commented Mar 24, 2017 via email

@guillaumebreton
Copy link
Author

@nicm thanks 👍 Made the test with master and --enabled-utf8proc but the problem persist. ( I didn't test the mouse selection though as I launched Tmux with mo configuration)

Here is a video of the steps I followed : https://youtu.be/Iv53xnAB-CE

@nicm
Copy link
Member

nicm commented Mar 24, 2017 via email

@guillaumebreton
Copy link
Author

guillaumebreton commented Mar 24, 2017

Here are the logs :)
logs_simple_test.zip

@nicm
Copy link
Member

nicm commented Mar 24, 2017

Your libc (or utf8proc if you have built with it) is failing to return a width for this symbol:

1490304541.683582 input_utf8_open 3
1490304541.683594 input_utf8_add
1490304541.683602 Unicode 26a1, wcwidth() -1
1490304541.683608 input_utf8_close 3 '\342\232\241' (width 1)

So tmux has no real choice but to assume it is width 1.

This is a common issue on OS X because the locale support is poor. But I'm surprised utf8proc doesn't have it either. Are you sure you restarted tmux completely after building with utf8proc?

@nicm
Copy link
Member

nicm commented Mar 24, 2017

On Linux, libc tells me this symbol should be width 1. So possibly in this case libc is correct and your terminal has the wrong idea of the width (or they are using different Unicode versions and the width changed).

@guillaumebreton
Copy link
Author

guillaumebreton commented Mar 24, 2017

I ran a tmux kill-server before every test to be sure and the install the utf8proc with brew install utf8proc (which points to http://julialang.org/utf8proc/ version 2.1). In my case, my terminal is rendering everything correctly outside tmux :/

Is there anything I could do to gather more information about this issue ?

@nicm
Copy link
Member

nicm commented Mar 24, 2017

Right but tmux and the terminal have to agree on the widths of characters, just because it works outside doesn't mean it is getting it right.

@guillaumebreton
Copy link
Author

guillaumebreton commented Mar 24, 2017

Ok, it makes sense :). Just to be sure, I tested with Iterm2 and the default OSX terminal and end up with the same result.

@nicm
Copy link
Member

nicm commented Mar 24, 2017

The log you sent me is not from master, can you try again and make sure you have built from the latest Git master?

I think the problem is from the second symbol not the first, which appears to be \357\270\217 which is U+FE0F http://graphemica.com/FE0F which is zero width combining mark, but your system is saying it is width 1.

@guillaumebreton
Copy link
Author

guillaumebreton commented Mar 24, 2017

tmux-server-48424.txt
Sorry 🤦‍♂️ Here is the correct log, I checked the version this time in the log. It may come from the way I output the emoji in the go test program. I'll try to replace it with the unicode value, and keep you updated.

@nicm
Copy link
Member

nicm commented Apr 3, 2017

OK this log is different:

1490353192.403073 input_utf8_close 3 '\342\232\241' (width 2)
1490353192.403097 input_utf8_close 3 '\357\270\217' (width 0)

I think your terminal thinks that \342\232\241 should be width 1 not width 2.

@nicm
Copy link
Member

nicm commented Apr 3, 2017

What does a screenshot of printing these symbols look like inside and outside tmux?

@guillaumebreton
Copy link
Author

While doing screenshots, I found a way to reproduce the bad printing. It seems that it comes from the terminal, as the \342\232\241 character with the \357\270\217 character should be of length 2 not 1. This behaviour can be reproduced inside tmux, outside tmux (in both iterm2 and osx terminal). What do you think ?

screen shot 2017-04-03 at 14 56 33

screen shot 2017-04-03 at 14 56 59

screen shot 2017-04-03 at 15 06 02

@nicm
Copy link
Member

nicm commented Apr 3, 2017

In all these screenshots, the symbol is two cells wide, but the terminal is only moving the cursor by one cell. I think \357\270\217 is irrelevant because it is zero width.

@guillaumebreton
Copy link
Author

If I don't output the \uFE0F character, the character is not "painted" in osx terminal, and it's 1 cell wide.

screen shot 2017-04-03 at 15 19 28

@nicm
Copy link
Member

nicm commented Apr 3, 2017

OK well in your last log tmux thinks the character is 2 cells wide, so that is what the terminal needs to do too or they will not display it properly when used together.

@guillaumebreton
Copy link
Author

Ok, thank a lot for you help 👍 I close the issue.

@lock
Copy link

lock bot commented Feb 16, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants