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

Closed
opened 2026-01-31 06:38:26 +00:00 by claunia · 9 comments
Owner

Originally created by @BlueRain-debug on GitHub (Jan 26, 2023).

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

Originally created by @BlueRain-debug on GitHub (Jan 26, 2023). ### 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](https://user-images.githubusercontent.com/68976789/214798933-95b24776-f877-41bd-9a06-5d692bce8fa4.png) ### Actual Behavior On the right side of the arrow symbol, the cursor appears in the center of the text. ![strange](https://user-images.githubusercontent.com/68976789/214799291-21737ae5-dcf6-442d-b732-d5c8b154e2bd.png)
claunia added the Area-RenderingIssue-BugResolution-DuplicateProduct-Terminal labels 2026-01-31 06:38:26 +00:00
Author
Owner

@lhecker commented on GitHub (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 commented on GitHub (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.
Author
Owner

@zadjii-msft commented on GitHub (Jan 26, 2023):

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

@zadjii-msft commented on GitHub (Jan 26, 2023): I'm fine calling this /dup #9940. Thanks!
Author
Owner

@ghost commented on GitHub (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 commented on GitHub (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!
Author
Owner

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

@BlueRain-debug commented on GitHub (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](https://github.com/microsoft/terminal/assets/68976789/451e1fb4-0b95-4b39-9698-494d8d20636a) Do I need to do any additional work? Update: I also tried enabling the AtlasEngine option but it still has the problem.
Author
Owner

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

@lhecker commented on GitHub (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](https://www.unicode.org/reports/tr11/tr11-41.html) 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](https://user-images.githubusercontent.com/68976789/214799291-21737ae5-dcf6-442d-b732-d5c8b154e2bd.png) 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. 😢
Author
Owner

@BlueRain-debug commented on GitHub (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. 😢

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

@BlueRain-debug commented on GitHub (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](https://www.unicode.org/reports/tr11/tr11-41.html) 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](https://user-images.githubusercontent.com/68976789/214799291-21737ae5-dcf6-442d-b732-d5c8b154e2bd.png) > > 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](https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.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](https://github.com/microsoft/terminal/assets/68976789/9a8912ae-e7ad-474e-8de9-dd5c4f6b6ca1)
Author
Owner

@lhecker commented on GitHub (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: https://github.com/microsoft/terminal/issues/2664#issuecomment-1513254341

@lhecker commented on GitHub (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: https://github.com/microsoft/terminal/issues/2664#issuecomment-1513254341
Author
Owner

@BlueRain-debug commented on GitHub (Dec 2, 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)

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

@BlueRain-debug commented on GitHub (Dec 2, 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)](https://github.com/microsoft/terminal/issues/2664#issuecomment-1513254341) I think I understand what's going on behind this. I'm sorry to take up your time.
Author
Owner

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

@DHowett commented on GitHub (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. :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19265