[GH-ISSUE #161] Incorrect rendering of Emojis with Zero-Width-Join characters #129

Closed
opened 2026-03-04 01:02:12 +03:00 by kerem · 4 comments
Owner

Originally created by @bcongdon on GitHub (Sep 1, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/161

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.

Originally created by @bcongdon on GitHub (Sep 1, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/161 It seems that some emojis sequences with zero-width-join runes are unable to be rendered correctly. For example, with the List view: ```go 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](https://user-images.githubusercontent.com/706257/44948603-7fe2a800-add5-11e8-85a5-7a821e74b36e.png) 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. ```go fmt.Println("Emojis: 👩‍🍳 👨‍👨‍👧 🏳️‍🌈") ``` ![screen shot 2018-09-01 at 10 54 31 am](https://user-images.githubusercontent.com/706257/44948600-7bb68a80-add5-11e8-9fcd-ea82703917ea.png) I've also noticed this behavior with the Table view, so I would suspect that this behavior is present in other views as well.
kerem closed this issue 2026-03-04 01:02:12 +03:00
Author
Owner

@rivo commented on GitHub (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.

<!-- gh-comment-id:418697867 --> @rivo commented on GitHub (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.
Author
Owner

@rivo commented on GitHub (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.

<!-- gh-comment-id:418845889 --> @rivo commented on GitHub (Sep 5, 2018): Looking into this some more, I found that I can't solve this without the help of [`tcell`](https://github.com/gdamore/tcell) and [`runewidth`](https://github.com/mattn/go-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.
Author
Owner

@rivo commented on GitHub (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.

<!-- gh-comment-id:424392017 --> @rivo commented on GitHub (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.
Author
Owner

@bcongdon commented on GitHub (Sep 26, 2018):

Thanks, I appreciate you fixing this!

<!-- gh-comment-id:424729322 --> @bcongdon commented on GitHub (Sep 26, 2018): Thanks, I appreciate you fixing this!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#129
No description provided.