Ambiguous width character incorrectly sized when UseDx enabled in conhost #6466

Closed
opened 2026-01-31 00:39:32 +00:00 by claunia · 4 comments
Owner

Originally created by @j4james on GitHub (Feb 15, 2020).

Environment

Windows build number: Version 10.0.18362.535
Windows Terminal version (if applicable): n/a
Conhost built from commit 4634a68a9b

Steps to reproduce

  1. Set the UseDx registry entry to 1
  2. Open a WSL bash shell in conhost
  3. Run the command printf "12\n\uFFFD\n"

Expected behavior

U+FFFD is an ambiguous width character, which I thought we were supposed to be interpreting as narrow (see PR #2928). It certainly seems to work that way in Windows Terminal.

image

Actual behavior

In conhost (when UseDx is enabled), ambiguous width characters appear to be dependent on the font, so on my system this character is being rendered over two columns as if it were a wide character.

image

Looking at PR #2928, I see we made the glyph width fallback method in TermControl.cpp return false for all values. If I do something similar for the SetGlyphWidthFallback call in srvinit.cpp, that fixes the problem. Is there a reason why we don't want to do that? Are there backwards compatibility issues?

Originally created by @j4james on GitHub (Feb 15, 2020). # Environment Windows build number: Version 10.0.18362.535 Windows Terminal version (if applicable): n/a Conhost built from commit 4634a68a9bbedd860f62cca5748d36c79afb1f82 # Steps to reproduce 1. Set the _UseDx_ registry entry to 1 2. Open a WSL bash shell in conhost 3. Run the command `printf "12\n\uFFFD\n"` # Expected behavior `U+FFFD` is an ambiguous width character, which I thought we were supposed to be interpreting as narrow (see PR #2928). It certainly seems to work that way in Windows Terminal. ![image](https://user-images.githubusercontent.com/4181424/74591836-37439c80-5013-11ea-9207-a8a69eb90450.png) # Actual behavior In conhost (when _UseDx_ is enabled), ambiguous width characters appear to be dependent on the font, so on my system this character is being rendered over two columns as if it were a wide character. ![image](https://user-images.githubusercontent.com/4181424/74591847-52aea780-5013-11ea-88dd-088e553f6ca8.png) Looking at PR #2928, I see we made the glyph width fallback method in [_TermControl.cpp_](https://github.com/microsoft/terminal/blob/38ebf48d79f65d6460451e1b4ff5c5f6f010d9b9/src/cascadia/TerminalControl/TermControl.cpp#L29-L46) return false for all values. If I do something similar for the `SetGlyphWidthFallback` call in [_srvinit.cpp_](https://github.com/microsoft/terminal/blob/a13ccfd0f5c1a63ba602d78afba72ab3abaabf34/src/host/srvinit.cpp#L550-L553), that fixes the problem. Is there a reason why we don't want to do that? Are there backwards compatibility issues?
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 18, 2020):

This is just one of those weird things that the console host is going to have to do for compatibility--this behavior is conserved with the GDI renderer, where I believe we always queried the font when we didn't know. To change that would, perhaps, pose a compatibility issue for CJK/"FE" consumers. ☹️
(@miniksa can keep me honest here)

@DHowett-MSFT commented on GitHub (Feb 18, 2020): This is just one of those _weird_ things that the console host is going to have to do for compatibility--this behavior is conserved with the GDI renderer, where I believe we always queried the font when we didn't know. To change that would, perhaps, pose a compatibility issue for CJK/"FE" consumers. ☹️ (@miniksa can keep me honest here)
Author
Owner

@j4james commented on GitHub (Feb 18, 2020):

I figured it might be something like that. But I thought maybe we could apply the narrow-ambiguous behavior only when in VT mode, and/or only when UseDx is enabled, assuming those are both opt-in modes. Not the end of the world though.

@j4james commented on GitHub (Feb 18, 2020): I figured it might be something like that. But I thought maybe we could apply the narrow-ambiguous behavior only when in VT mode, and/or only when _UseDx_ is enabled, assuming those are both opt-in modes. Not the end of the world though.
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 18, 2020):

In the fullness of time, Dx will (fingers crossed, schedules permitting, etc., etc.) be a viable renderer for the inbox console host as well, and unfortunately VT mode doesn't preclude an application from reading out the output buffer because that application is insane. 😄

This might be a good candidate for the I_SOLEMNLY_SWEAR_I_WILL_BE_A_GOOD_CITIZEN console mode.

@DHowett-MSFT commented on GitHub (Feb 18, 2020): In the fullness of time, Dx will (fingers crossed, schedules permitting, etc., etc.) be a viable renderer for the inbox console host as well, and unfortunately VT mode doesn't preclude an application from reading out the output buffer because that application is insane. :smile: This might be a good candidate for the `I_SOLEMNLY_SWEAR_I_WILL_BE_A_GOOD_CITIZEN` console mode.
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 18, 2020):

I'm gonna close this one out with my condolences.

@DHowett-MSFT commented on GitHub (Feb 18, 2020): I'm gonna close this one out with my condolences.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6466