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

Incorrect rendering of Emojis with Zero-Width-Join characters #161

Closed
bcongdon opened this issue Sep 1, 2018 · 4 comments
Closed

Incorrect rendering of Emojis with Zero-Width-Join characters #161

bcongdon opened this issue Sep 1, 2018 · 4 comments

Comments

@bcongdon
Copy link

bcongdon commented Sep 1, 2018

It seems that some emojis sequences with zero-width-join runes are unable to be rendered correctly.

For example, with the List view:

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	list := tview.NewList().
		AddItem("👩‍🍳", "Some explanatory text", 'a', nil).
		AddItem("👨‍👨‍👧", "Some explanatory text", 'a', nil).
		AddItem("🏳️‍🌈", "Some explanatory text", 'a', nil).
		AddItem("Quit", "Press to exit", 'q', func() {
			app.Stop()
		})
	if err := app.SetRoot(list, true).Run(); err != nil {
		panic(err)
	}
}

These emojis are rendered as their component emojis, instead of the full emoji sequence.
screen shot 2018-09-01 at 10 53 43 am

I've double checked that this is not a problem with my terminal emulator, as using the native fmt.Println function on these emojis renders them correctly.

fmt.Println("Emojis: 👩‍🍳 👨‍👨‍👧 🏳️‍🌈")

screen shot 2018-09-01 at 10 54 31 am

I've also noticed this behavior with the Table view, so I would suspect that this behavior is present in other views as well.

@rivo
Copy link
Owner

rivo commented Sep 5, 2018

Thanks for spotting this. Approximately 90% of my work on tview is spent on making Unicode characters work properly. I thought I had solved it but there are obviously still issues.

I'll look into this. Might take me some time if I find there's no simple fix.

@rivo
Copy link
Owner

rivo commented Sep 5, 2018

Looking into this some more, I found that I can't solve this without the help of tcell and runewidth (see referenced issues). Both of these packages seem to have issues with unicode sequences containing zero-width joiners.

Once support for ZWJs is implemented in these packages, I can fix it in tview as well. I hope that the maintainers will add support for ZWJ.

@rivo rivo closed this as completed in 29458da Sep 25, 2018
@rivo
Copy link
Owner

rivo commented Sep 25, 2018

I just added support for zero-width joiners in tview. Note that the width of these characters will still be wrong. Once @mattn fixes mattn/go-runewidth#20, this should go away.

@bcongdon
Copy link
Author

Thanks, I appreciate you fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants