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

some weird behavior when dealing with full-width characters #14736

Closed
BlueRain-debug opened this issue Jan 26, 2023 · 9 comments
Closed

some weird behavior when dealing with full-width characters #14736

BlueRain-debug opened this issue Jan 26, 2023 · 9 comments
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@BlueRain-debug
Copy link

Windows Terminal version

1.15.3465.0

Windows build number

10.0.19044.2546

Other Software

No response

Steps to reproduce

  1. Run wt.exe
  2. Open a PowerShell Tab
  3. Type something like "echo R2.01/R2.02→R2.03"

Expected Behavior

normal

Actual Behavior

On the right side of the arrow symbol, the cursor appears in the center of the text.

strange

@BlueRain-debug BlueRain-debug added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jan 26, 2023
@lhecker
Copy link
Member

lhecker commented Jan 26, 2023

This is sort of a known issue and I'm sure there have been previous reports like this in the past, like #9940 for instance. Although I'm not entirely sure with which existing issue this one should be deduplicated. It occurs because our text renderer draws text like you would draw proportional fonts. So if your monospace font isn't actually monospace (which may happen due to font fallback), the text might start to be "misaligned". The good news is that I'm working on a proper solution in form of an ongoing "AtlasEngine" rewrite.

@lhecker lhecker added Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Product-Terminal The new Windows Terminal. labels Jan 26, 2023
@zadjii-msft
Copy link
Member

I'm fine calling this /dup #9940. Thanks!

@ghost
Copy link

ghost commented Jan 26, 2023

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jan 26, 2023
@BlueRain-debug
Copy link
Author

BlueRain-debug commented Nov 27, 2023

I'm fine calling this /dup #9940. Thanks!

This issue is marked as resolved in 1.18, but it seems that I can still reproduce it in the latest version of WT from the Store (1.18.2822.0).

image

Do I need to do any additional work?

Update: I also tried enabling the AtlasEngine option but it still has the problem.

@lhecker
Copy link
Member

lhecker commented Nov 27, 2023

@BlueRain-debug That's exactly how this issue is supposed to be fixed.

First, some context: In terminals the UAX #11: East Asian Width standard determines how many columns a glyph occupies. Not the font! Your font happens to have a → that looks 2 columns wide, but that doesn't change what the UAX standard says.

With that in mind, the issue previously was that we didn't respect the UAX standard during text rendering and one overly wide → glyph would shift all following glyphs to the right. That's why the cursor is on top of the "3" glyph here:
strange

With AtlasEngine this issue won't happen anymore. But overly wide glyphs are still overly wide, because that's how the font wants them. In other words, if that → glyph bothers you, you'll have to use a different font unfortunately, as we can't change how the font looks like. 😢

@BlueRain-debug
Copy link
Author

@BlueRain-debug That's exactly how this issue is supposed to be fixed.

First, some context: In terminals the UAX #11: East Asian Width standard determines how many columns a glyph occupies. Not the font! Your font happens to have a → that looks 2 columns wide, but that doesn't change what the UAX standard says.

With that in mind, the issue previously was that we didn't respect the UAX standard during text rendering and one overly wide → glyph would shift all following glyphs to the right. That's why the cursor is on top of the "3" glyph here: strange

With AtlasEngine this issue won't happen anymore. But overly wide glyphs are still overly wide, because that's how the font wants them. In other words, if that → glyph bothers you, you'll have to use a different font unfortunately, as we can't change how the font looks like. 😢

Thanks for your reply, but I still have some doubts.

Did a quick check and it seems that all Windows built-in East Asian (CJK) fonts have the "wrong" character width (the font in the previous screenshots is MS Gothic).

According to EastAsianWidth-15.1.0.txt, Unicode Character "→" (U+2192) is marked as A which means Ambiguous Unicode characters. And the suggestion in the report you provided is: Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). If the context cannot be established reliably, they should be treated as narrow characters by default.

So I'm a little confused now: Is this an issue that the Microsoft East Asia font team needs to investigate? Or should the rendering method be modified based on the actual font context?

By the way, command prompt programs that are opened directly are not affected by this problem.
image

@lhecker
Copy link
Member

lhecker commented Nov 27, 2023

conhost (= the classic console window) uses the font to determine whether an ambiguous glyph should occupy 1 or 2 columns, because that's how it's been doing this since the beginning. We don't do the same thing for Windows Terminal, because all other modern terminals default to treating ambiguous cases as narrow. You can read more about this decision here: #2066

We want this to be configurable though, which is tracked here: #153
Unfortunately we haven't made it a priority yet, because not many people are asking for this. If anyone were to submit a PR for it however, we'd accept it in a heartbeat.

There's also the feature request to allow for the configuration of font fallback which would also help here: #2664
That one is a lot higher priority (188 upvotes), but I haven't gotten to it yet. I've already documented how to do it though and I don't think it'd be too difficult: #2664 (comment)

@BlueRain-debug
Copy link
Author

conhost (= the classic console window) uses the font to determine whether an ambiguous glyph should occupy 1 or 2 columns, because that's how it's been doing this since the beginning. We don't do the same thing for Windows Terminal, because all other modern terminals default to treating ambiguous cases as narrow. You can read more about this decision here: #2066

We want this to be configurable though, which is tracked here: #153 Unfortunately we haven't made it a priority yet, because not many people are asking for this. If anyone were to submit a PR for it however, we'd accept it in a heartbeat.

There's also the feature request to allow for the configuration of font fallback which would also help here: #2664 That one is a lot higher priority (188 upvotes), but I haven't gotten to it yet. I've already documented how to do it though and I don't think it'd be too difficult: #2664 (comment)

I think I understand what's going on behind this. I'm sorry to take up your time.

@DHowett
Copy link
Member

DHowett commented Dec 4, 2023

I'm sorry to take up your time.

It's okay, you don't need to apologize! It's very helpful sometimes when we get a chance to explain what is going on. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

4 participants