Terminal.Gui icon indicating copy to clipboard operation
Terminal.Gui copied to clipboard

Wide Glyphs do not work correctly on `conhost`

Open tig opened this issue 2 years ago • 7 comments

Run the scenario Buttons with host console and you'll see the same. I really don't know why this happens but I'm sure the right string are passed to the console.

image

Originally posted by @BDisp in https://github.com/gui-cs/Terminal.Gui/issues/2928#issuecomment-1785413495

This problem is not just about Button. conhost operates differently from WT when rendering wide glyphs.

Run CharMap under conhost to see: image

Note that NetDriver doesn't work correctly either.: image

tig avatar Oct 30 '23 16:10 tig

I am beginning to suspect the REAL problem is Rune.GetColumns(), which depends on wcwidth is returning values different than what WT is using internally (and WT an conhost behave differently in this regard).

The real fix to all of this is to figure out how to calculate the number of columns the same way WT is doing it.

tig avatar Oct 31 '23 17:10 tig

I am beginning to suspect the REAL problem is Rune.GetColumns(), which depends on wcwidth is returning values different than what WT is using internally (and WT an conhost behave differently in this regard).

You probably are right. Maybe you can open an issue on the owner repo?

The real fix to all of this is to figure out how to calculate the number of columns the same way WT is doing it.

Yes, this probably be a good choice. Do you are going to investigate the code?

BDisp avatar Oct 31 '23 18:10 BDisp

Yes, this probably be a good choice. Do you are going to investigate the code?

Yes, I am actively working on this as part of #2610

tig avatar Oct 31 '23 18:10 tig

I think that haven't anything related with wide char. I did this change to GetColumns:

image

and the result is:

image

The width is really 1 but conhost doesn't render well on all situations with certain character.

BDisp avatar Oct 31 '23 22:10 BDisp

It's more subtle than that. How each terminal internally stores code points in cells and how it deals with cells to the left or right varies widely.

Run v1 charmap in conhost/wt/netdriver/windowsdriver and see wild differences.

tig avatar Nov 01 '23 17:11 tig

It's more subtle than that. How each terminal internally stores code points in cells and how it deals with cells to the left or right varies widely.

You are right is terminal dependent. The case of the the terminal doesn't handle the same way for all of them. In this case is only on the second button of the Top app and on the Dialog the situation is worst.

Run v1 charmap in conhost/wt/netdriver/windowsdriver and see wild differences.

Yes I already did and I see it happens with WindowsDriver and NetDriver. We can't do nothing unless it's fixed by Microsoft I guess.

BDisp avatar Nov 01 '23 18:11 BDisp

@tig see this code point U+1085F “𐡟” where seems to occupies two columns but GetColumn return one. I know that depend if the font support or not a code point but cmd and conhost support it. It feels like it gets too tight.

image

BDisp avatar Nov 01 '23 21:11 BDisp