Repository navigation
Description
Issue:
Neutral EastAsianWidth characters are always rendered as narrow
Desired Resolution:
CharWidth=neutral-wide to force rendering of Neutral EastAsianWidth characters as Wide
Terminal:
WSLTTY 3.4.3
WSLTTY config:
# Locale and Charset are unset in config while font is forced to Windows Segoe UI which should be fallback for unicode glyph rendering from other fonts
#Locale=
#Charset=
Font=Segoe UI
Bash ENV:
CHARSET=UTF-8
LANG=C.UTF-8
LC_COLLATE=C
LC_CTYPE=en_US.UTF-8
Alpine linux /etc/profile.d/locale.sh:
export CHARSET=UTF-8
export LANG=C.UTF-8
export LC_COLLATE=C
Background:
I've been struggling with unicode glyph rendering for a couple years with wsltty and assumed it was an improper understanding of the charwidth property or incompatible font selection. However, I've come to the conclusion my expectation is that Neutral EastAsianWidth characters are being forced to narrow rendering per http://unicode.org/reports/tr11/ recommendation and codepoint annotation (https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt). Issue #938 discusses tr11 but neglects the section which suggests that terminals should provide additional resolution for the ambiguity surrounding glyph width rendering.
My specific use-case is to use unicode for diagnostic style information and also for wttr.in weather icons. The Warning and Informational glyphs render narrow in wsltty when I want to force them to render wide to match the surrounding glyphs that are annotated as Wide in EastAsianWidth. Weather related glyphs from U+1F321 through U+1F32C render narrow based on the same adherence to Neutral EastAsianWidth rendering as narrow.
cat unicode.raw
⛔ - Critical - critical conditions
❌ - Error- error condtions
⚠ - Warning - warning conditions
📌 - Notice - normal, but significant, condition
ℹ - Informational - informational message
🚫 - Debug - debug-level message
### Characters by Unicode Block
**Dingbats**
- [ ] U+2728 ✨ Sparkles
- [ ] U+2744 ❄ Snowflake
**Miscellaneous Symbols**
- [X] U+2600 ☀ Black Sun with Rays
- [X] U+2601 ☁ Cloud
- [ ] U+26C5 ⛅ Sun Behind Cloud
- [ ] U+26C6 ⛆ Rain
- [ ] U+26C8 ⛈ Thunder Cloud and Rain
**Miscellaneous Symbols and Pictographs**
- [ ] U+1F300 🌀 Cyclone
- [ ] U+1F30C 🌌 Milky Way
- [ ] U+1F30D 🌍 Earth Globe Europe-Africa
- [ ] U+1F30E 🌎 Earth Globe Americas
- [ ] U+1F30F 🌏 Earth Globe Asia-Australia
- [ ] U+1F310 🌐 Globe with Meridians
- [ ] U+1F311 🌑 New Moon Symbol
- [ ] U+1F312 🌒 Waxing Crescent Moon Symbol
- [ ] U+1F313 🌓 First Quarter Moon Symbol
- [ ] U+1F314 🌔 Waxing Gibbous Moon Symbol
- [ ] U+1F315 🌕 Full Moon Symbol
- [ ] U+1F316 🌖 Waning Gibbous Moon Symbol
- [ ] U+1F317 🌗 Last Quarter Moon Symbol
- [ ] U+1F318 🌘 Waning Crescent Moon Symbol
- [ ] U+1F321 🌡 Themometer
- [ ] U+1F322 🌢 Black Droplet
- [ ] U+1F323 🌣 White Sun
- [ ] U+1F324 🌤 White Sun with Small Cloud
- [ ] U+1F325 🌥 White Sun Behind Cloud
- [ ] U+1F326 🌦 White Sun Behind Cloud with Rain

Activity
mintty commentedon Dec 2, 2020
Your illustrated use cases do not relate to East Asian characters, so maybe you'd like an option that makes all characters the same width. There is Charwidth=single, however it's single-width and rendering of CJK characters in this mode is not very desirable. I was considering a variation Charwidth=double that would render all characters as double-width, however including plain text.
If you'd rather want to target particularly emojis, this has been discussed elsewhere and the problem is missing referable criteria by which to decide characters to be wide that are narrow by Unicode.
Context-dependent width is something that terminals should never do.
You can specify single characters to be double-width explicitly, however, since mintty 3.1.5, with control sequence PEC (CSI 1 SP Z emoji CSI SP Z ).
pagerc commentedon Dec 2, 2020
I'm definitely not after an option to force all characters to a specific width. I just want EastAsianWidth Neutral characters to render as wide instead of narrow. I'm not convinced this isn't related to the tr11 unicode report discussing EastAsianWidth annotations.
My output clearly shows that some unicode characters render single cell width and others double cell width. The only document I can locate for defining what characters render double width and others single width is in relation to the content of https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt:
Specifically if this is not related to EastAsianWidth, can you kindly explain why this subset from Miscellaneous Symbols and Pictographs (not emoticons/emojis) 1F300-1F320 render as wide-width and 1F321-1F32C render as narrow-width?
printf '\U1F311#\n0123456789\n\U1F321#\n'While it's neat that the control sequences exist for a case by case basis of forcing single character output rendering as narrow/wide, it's not really feasible to run all text going to the tty through a control sequence manipulator just to adjust the rendering for character ranges from single-width to double-width. To better explain, while I use wttr.in for weather, I don't control it's output and there are other applications that emit non-emoji unicode that suffer from the narrow/wide issue and as such for proper rendering of Neutral EastAsianWidth characters I'd have to put a buffer between all programs and the tty which seems excessive.
From EastAsianWidth, its clear that the unicode glyphs that I want to render wide are annotated as Neutral:
2139;N # Ll INFORMATION SOURCE
...
26A0;N # So WARNING SIGN
26A1;W # So HIGH VOLTAGE SIGN
...
26D4;W # So NO ENTRY
...
274C;W # So CROSS MARK
...
1F300..1F320;W # So [33] CYCLONE..SHOOTING STAR
1F321..1F32C;N # So [12] THERMOMETER..WIND BLOWING FACE
1F32D..1F335;W # So [9] HOT DOG..CACTUS
...
1F680..1F6C5;W # So [70] ROCKET..LEFT LUGGAGE
mintty commentedon Dec 2, 2020
Let's stop talking about East Asian here as none of the examples you want widened are East Asian.
Changing issue title.
You've answered this question yourself by quoting from the file above and even marking the entries bold. Note that despite the filename EastAsianWidth, the file lists all Unicode characters.
[-]Feature: Explicit option for rendering Neutral EastAsianWidth as Narrow or Wide[/-][+]Feature: Explicit option for rendering emojis as Wide[/+]pagerc commentedon Dec 2, 2020
I want to highlight these are not emoji/emoticons, they are
Miscellaneous SymbolsandMiscellaneous Symbols and Pictographswhich predate emoji/emoticons and from my reading of the tr11 report it's an acceptable option for Neutral characters to be treated as Ambiguous by implementation election and therefore behave the same as ambiguous rendering.Excerpt from tr11 the relevant portion on modern rendering under section 4.2:
mintty commentedon Dec 2, 2020
See also #880, particularly #880 (comment), and #553. Liberal "modern rendering" practice isn't appropriate for a cell-based terminal. Main criteria for width considerations must be that any application shall be able to make reliable assumptions about the effective width of character output. By general paradigm, this is mediated by the locale mechanism.
Exceptions are possible and in fact mintty offers a few of them (see manual), but for any such request you'd need to provide solid and reliable criteria by which any given character should deviate from its standard width. Not something fuzzy as "Asian", "emojis" or "miscellaneous".
pagerc commentedon Dec 2, 2020
I have to disagree with this author:
https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
An implementation that allows the wholesale categorization of neutral characters to be equivalent to ambiguous width characters is suggested as a solution in the technical report.
Therefore, I entirely see it as possible to add an option
neutral=ambigso that thecharwidth=ambig-widewould control the entire class of Neutral width characters to render as wide.The downside obviously is that you'll need a wcwidth implementation that follow the technical report which indicates rendering neutral as ambiguous is permitted by an implementation.
To create the struct definition for
static const struct interval neutral[] = {something like this should get it started:curl -kL https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt | grep ';N ' | sed -e 's:;.*::'*edited to include code correction on grep
mintty commentedon Dec 2, 2020
That should be
grep ';N 'with space, to exclude ';Na'.It would include almost all letters, except plain ASCII, just to note. I doubt that is desirable.
pagerc commentedon Dec 3, 2020
The characters I'm most interested in are definitely all Symbols/emoji related, and you've characterized that as a "fuzzy" set.
Which of these is the best path forward?
mintty neutral=ambig config option for forcing all neutral characters to wide
mintty wide symbol extension ^[]77119;3^G Render symbol unicode ranges or literally described as symbol in name as wide
Push for LANG=en_US@neutralambig or LANG=en_US@widesymbol as new modifier
Push unicode consortium to correct the published widths with a new categorization of "symbol" to identify a new class of unicode characters that should be considered wide, e.g. Symbols, Pictographs, and emoji
Wrap all apps with an output formatter that induces ^[[1 Z for unicode symbols/emoji that are currently classified as Neutral
mintty commentedon Dec 3, 2020
OSC 77119 is something I can imagine to offer, but still, to which ranges?
Among Miscellaneous Symbols, e.g., there are some that should perhaps not be wide, like U+2640, U+2680. Should Miscellaneous Symbols and Arrows (U+2B00-U+2BFF) be affected? Etc.
I could also imagine to provide an option to specify wide character ranges explicitly.
pagerc commentedon Dec 3, 2020
Going off on a tangent, I found that Windows Notepad appears to use dotnet System.Drawing.Graphics.MeasureString and I'm curious if that graphical measurement of font rendering may be preferred to wcwidth/wcswidth for character width calculations. If so, figuring out how cairo/pango implement MeasureString routines may be a means to get a superior implementation than wcwidth/wcswidth for width calculations.
I've tracked the mono implementation to back to cairo/pango when mono System.Drawing.gdipFunctions imports GdiPlus dll like this:
https://github.com/mono/mono/blob/master/mcs/class/System.Drawing/System.Drawing/Graphics.cs#L1934
https://github.com/mono/mono/blob/master/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs#L48
https://github.com/mono/libgdiplus/blob/master/src/text.c#L72
https://github.com/mono/libgdiplus/blob/master/src/text-pango.c#L563
https://github.com/mono/libgdiplus/blob/master/src/text-cairo.c#L114
From https://stackoverflow.com/questions/602912/how-do-you-echo-a-4-digit-unicode-character-in-bash credit https://stackoverflow.com/users/912236.
mintty commentedon Dec 3, 2020
Width measuring is proper for graphic output but not for cell-based output, for which wcwidth is the reference. Note that terminals force output width to fit into the cell matrix, so using font-based metrics makes no sense for terminal applications.
pagerc commentedon Dec 5, 2020
I've been comparing Microsoft Terminal and Alacritty to wsltty and I think my biggest issue with wsltty is the glyph clipping which doesn't seem to impact Alacritty. My intention behind this request was to force rendering of narrow characters to wide to resolve clipping. Alternatively to narrow/wide, are there any wsltty options to change/scale the glyph when rendering so that it doesn't clip/truncate?
I want to highlight that Microsoft Terminal maintains it's own width descriptors. I haven't compared it to wcwidth or EastAsianWidth.txt to see how they deviate, but it'd be interesting to dig into what/why they're doing a custom codepoint width detector.
microsoft/terminal#5934 - talks about Epres emoji widths
microsoft/terminal#5795 - talks about failed attempt to set MS specific emojis to wide and breaking things
microsoft/terminal#900 - identifies a sad spider
https://github.com/microsoft/terminal/blob/main/src/types/CodepointWidthDetector.cpp
Left: Microsoft Terminal | Center: wsltty | Right: Alacrittymintty commentedon Dec 5, 2020
Yes, there is auto-narrowing, which means the glyph is squeezed if it does not fit into the determined cell width. Auto-narrowing is a trade-off, however, as there are undesirable border cases (see #979, #922, #914, #892). Default value is 75, try to reduce e.g.
CharNarrowing=60to see whether your characters are affected. Which are they, anyway?Thanks for the references to MS width handling, I may check them out later. However, the only really authoritative source for character width properties should be Unicode, so the question for clear criteria for the set of characters to be made wide is still open, I guess.
pagerc commentedon Dec 6, 2020
I'm utterly confused as to why I'm getting clipping at this point. I've manually forced my font to
Segoe UIbecause that's the default font fallback, and I get clipping with every settings variation I can think of with narrowing at 50, narrowing at 100, ambig-wide, etc. I'm not really noticing an impact from the CharNarrowing field, do I need another setting to trigger it? I've also used font sizes from 8 to 18 to see if I can see any difference (normally I use font size 8, but enlarged to 18 to see if clipping disappears with larger font, it does not).All of my screenshots show the output of
unicode.rawthat I pasted in my initial problem report at top. Key symbols that cause problems for clipping:3 remaining items
pagerc commentedon Dec 8, 2020
Are there nightly builds for such updates?
mintty commentedon Dec 8, 2020
No, but building mintty yourself is easy, you just need cygwin with packages gcc-core and make.
k-takata commentedon Dec 8, 2020
@mintty How about updating the
INSTALLfile, and link it from README.md?workaround for mysterious output delay during non-BMP width detection (…
mintty commentedon Dec 20, 2020
Released 3.4.4.
speedup of width detection for auto-narrowing for certain characters (#…
visual double-width of symbols and emojis with subsequent space (#1104,
mintty commentedon Sep 3, 2021
Released 3.5.1.
fix auto-widening of ambiguous-width letters (broken since 3.4.4) (?#…
mintty commentedon Feb 20, 2022
I had to tweak 81e327 for another issue.
Please recheck this issue if possible.
pagerc commentedon Feb 20, 2022
Looks good on 3.5.3, maybe some left clipping on icons:
pagerc commentedon Feb 20, 2022
Narrowing turned off, still some minor clipping on the black droplet and the cloud symbols, but passably readable and better than my earlier issues:

mintty commentedon Feb 20, 2022
Thanks, what I actually meant is to check the current master version / latest commit. Compiling mintty is easy, no further dependencies, just gcc and make needed.
pagerc commentedon Feb 21, 2022
It might be easy, but the makefile is incompatible with my Alpine Linux WSL build environment on Windows. I might be able to address the incompatibility in a couple weeks to get a build going. In the meantime, if you have a wsltty build for Windows, I can test that sooner.