[PR #2928] [MERGED] TermControl: force all ambiguous glyphs to be narrow #25148

Open
opened 2026-01-31 09:07:36 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2928
Author: @DHowett-MSFT
Created: 9/27/2019
Status: Merged
Merged: 10/15/2019
Merged by: @DHowett-MSFT

Base: masterHead: dev/duhowett/lose_a_little_bit_of_weight_but_not_too_much


📝 Commits (1)

  • c2a0d19 TermControl: force all ambiguous glyphs to be narrow

📊 Changes

1 file changed (+20 additions, -5 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+20 -5)

📄 Description

From Egmont Koblinger:

In terminal emulation, apps have to be able to print something and
keep track of the cursor, whereas they by design have no idea of the
font being used. In many terminals the font can also be changed runtime
and it's absolutely not feasible to then rearrange the cells. In some
other cases there is no font at all (e.g. the libvterm headless terminal
emulation library, or a detached screen/tmux), or there are multiple
fonts at once (a screen/tmux attached from multiple graphical
emulators).

The only way to do that is via some external agreement on the number
of cells, which is typically the Unicode EastAsianWidth, often accessed
via wcwidth(). It's not perfect (changes through Unicode versions, has
ambiguous characters, etc.) but is still the best we have.

glibc's wcwidth() reports 1 for ambiguous width characters, so the de
facto standard is that in terminals they are narrow.

If the glyph is wider then the terminal has to figure out what to do.
It could crop it (newer versions of Konsole, as far as I know), overflow
to the right (VTE), shrink it (Kitty I believe does this), etc.

See Also:
https://bugzilla.gnome.org/show_bug.cgi?id=767529
https://gitlab.freedesktop.org/terminal-wg/specifications/issues/9
https://www.unicode.org/reports/tr11/tr11-34.html

Salient point from proposed update to Unicode Standard Annex #11:

Note: The East_Asian_Width property is not intended for use by modern
terminal emulators without appropriate tailoring on a case-by-case
basis.

Fixes #2066
Fixes #2375

PR Checklist

  • Closes stuff
  • written by an employee
  • Testing sorta done
  • Requires documentation to be updated
  • I've discussed this with core contributors already. AT LENGTH.

Validation Steps Performed

This one has some followup issues. I went wild on it, but it does still have some issues. It makes #900 worse, and introduces a debug break you hit when the renderer and the column counter disagree. It might make the renderer discard the rest of the line it was working on.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2928 **Author:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Created:** 9/27/2019 **Status:** ✅ Merged **Merged:** 10/15/2019 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `dev/duhowett/lose_a_little_bit_of_weight_but_not_too_much` --- ### 📝 Commits (1) - [`c2a0d19`](https://github.com/microsoft/terminal/commit/c2a0d19fb95c759c70d91cd31ea7b77b4410cac1) TermControl: force all ambiguous glyphs to be narrow ### 📊 Changes **1 file changed** (+20 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+20 -5) </details> ### 📄 Description From Egmont Koblinger: > In terminal emulation, apps have to be able to print something and keep track of the cursor, whereas they by design have no idea of the font being used. In many terminals the font can also be changed runtime and it's absolutely not feasible to then rearrange the cells. In some other cases there is no font at all (e.g. the libvterm headless terminal emulation library, or a detached screen/tmux), or there are multiple fonts at once (a screen/tmux attached from multiple graphical emulators). > The only way to do that is via some external agreement on the number of cells, which is typically the Unicode EastAsianWidth, often accessed via wcwidth(). It's not perfect (changes through Unicode versions, has ambiguous characters, etc.) but is still the best we have. > glibc's wcwidth() reports 1 for ambiguous width characters, so the de facto standard is that in terminals they are narrow. > If the glyph is wider then the terminal has to figure out what to do. It could crop it (newer versions of Konsole, as far as I know), overflow to the right (VTE), shrink it (Kitty I believe does this), etc. See Also: https://bugzilla.gnome.org/show_bug.cgi?id=767529 https://gitlab.freedesktop.org/terminal-wg/specifications/issues/9 https://www.unicode.org/reports/tr11/tr11-34.html Salient point from proposed update to Unicode Standard Annex #11: > Note: The East_Asian_Width property is not intended for use by modern terminal emulators without appropriate tailoring on a case-by-case basis. Fixes #2066 Fixes #2375 ## PR Checklist * [x] Closes stuff * [x] written by an employee * [x] Testing sorta done * [ ] ~Requires documentation to be updated~ * [x] I've discussed this with core contributors already. AT LENGTH. ## Validation Steps Performed This one has some followup issues. I went wild on it, but it does still have some issues. It makes #900 worse, and introduces a debug break you hit when the renderer and the column counter disagree. It might make the renderer discard the rest of the line it was working on. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:07:36 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25148