Skip to content

Extended-width characters only display in a single column #615

Closed

Description

@kkartaltepe

paste '☆' into your mintty prompt. It will appear as only left half of the character. Some other full width characters render correctly, like 你好.

The star character displays a correct full width character when I am using urxvt on linux. This happens for a handful of other characters as well but I don't have a list of all of them off hand. tested with 2.5.0 from msys2 and 2.6.2

mintty_2016-12-15_12-50-42

Activity

  1. mintty commented on Dec 15, 2016

    @mintty
    Owner

    U+2606 WHITE STAR is a Unicode "ambiguous width" character. Displaying it wide is not correct but context-dependent. Ambiguous width characters are "normally" displayed narrow, i.e. using single-cell width. Only in East Asian display context their display is wide. For mintty, that would be activated by using an East Asian locale, e.g. LC_ALL=ja_JP.UTF-8 mintty.
    The visual display, on the other hand, also depends on the font. For me, the narrow form looks good, while the wide form looks expanded. What are your settings (locale, font)? What's the locale setting when you see this character wide in urxvt?
    star
    star-wide

  2. kkartaltepe commented on Dec 15, 2016

    @kkartaltepe
    Author

    My msys2 system only has LANG=en_US.UTF-8 set. LC_ALL is unset.
    My urxvt system has LC_ALL is en_US.UTF-8 im not sure exactly what LANG is set to, I can get back to you with that in a couple hours.

    In both systems I am using Envy Code R as the primary font. I'm fine with getting a proper single column rendering, but I just want it not to be this broken half character.

  3. mintty commented on Dec 16, 2016

    @mintty
    Owner

    There is a variant Envy Code R for Powerline which has wide ambiguous characters, and maybe urxvt uses that as a criterion to switch to ambiguous wide display. That would explain the difference.
    Can you try on Windows with "Envy Code R" (not "for Powerline")?

  4. kkartaltepe commented on Dec 16, 2016

    @kkartaltepe
    Author

    I am using the original official release of the font found at the creators blog
    https://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released

    Installed are the normal face, italic, and bold. Without the registry hack for cmd prompt and without the visual studio font hacks. I've reinstalled it for the sake of testing and it still shows the same artifact. I use the font at 10pt.

    Here is the terminal using 'Courier New' but effect shows up in all fonts I chose (lucidia console at 10p shows only the far right pixel being cut off, but it is cut off)
    mintty_2016-12-16_10-16-14

  5. mintty commented on Dec 16, 2016

    @mintty
    Owner

    The character looks "normal" for example with DejaVu Sans Mono, Everson Mono Unicode, and FreeMono.
    The reason could be (not yet verified by tracing) that the character is included in those fonts but not in the others, in which case Windows applies its font fallback mechanism, turning up with a character from some other font which does not always match in cell-width. This happens to a range of character that are not typically used in terminals, like encircled numbers, Thai script characters, and lots more.

    Considering what could be done about this in theory, we are facing a trade-off. Currently, via employing Uniscribe (if you use that option), extended font fallback is being used to the benefit of users displaying certain scripts. This feature should not be affected. Testing character availabilty, on the other hand, does not seem to consider font fallback. If we could check which characters would be wider than expected, we could even squeeze the rendering but at a performance penalty, I suppose...
    The best workaround is to select a font that supports the characters you are using.

  6. mintty commented on Dec 16, 2016

    @mintty
    Owner

    By the way, in urxvt (on Windows), the character isn't displayed properly either. It's aligned right and clipped left.

  7. kkartaltepe commented on Dec 16, 2016

    @kkartaltepe
    Author

    Sorry if you misunderstood but I meant urxvt on linux whenever I mentioned it, I dont use any other terminal emulators on windows mintty has won me over :)

  8. mintty commented on Dec 16, 2016

    @mintty
    Owner

    Yes, that's why I mentioned "on Windows" explicitly. Could you make a screenshot of urxvt on Linux?

  9. kkartaltepe commented on Dec 16, 2016

    @kkartaltepe
    Author

    virtualbox_2016-12-16_11-28-21
    Actually got some time to spin up a vm, here is the same character rendered correctly (it looks like it is rendered as a single column character not a wide character). The font setting for Xresources used was
    URxvt.font: xft:Envy Code R:style=Regular:size=10

  10. mintty commented on Dec 16, 2016

    @mintty
    Owner

    But look at its left wing: it's a pixel shorter than the right wing, it's clipped there.

  11. kkartaltepe commented on Dec 16, 2016

    @kkartaltepe
    Author

    Actually you are right the left side of the glyph is clipped. But its much closer
    virtualbox_2016-12-16_11-41-56

  12. changed the title [-]Full width characters only display in a single column[/-] [+]Extended-width characters only display in a single column[/+] on Mar 11, 2017
  13. mintty commented on May 30, 2017

    @mintty
    Owner

    I plan to close this issue because font and width dependencies have been discussed and you can achieve the desired behaviour by starting mintty in ambiguous wide mode (corresponding to xterm -cjk_width), e.g.:
    LC_ALL=ja_JP.utf8 mintty -o Font=BatangChe

    You could be asking for an easier option to trigger this mode, without having to adjust the locale;
    that would be #88.

  14. kkartaltepe commented on May 31, 2017

    @kkartaltepe
    Author

    I'm not sure I understand the issue linked or its significance. That looked like a proposal for a -cjk_width flag that was eventually turned down and instead opting for setting ambiguous width via a test against the Greek letter alpha's width as reported by the current font? So changing my font to one that reports Greek letter alpha's as wide would cause mintty to render ambiguous characters as wide?

    Using the font in your example and setting 'Locale' in mintty options(exporting LC_ALL is overridden somewhere on my setup i guess), I do indeed get this character rendering as full width.

    However, I'm not sure I see how this works in correcting(maybe "forcing" is the right word) rendering of these characters in my current font as even setting locale to ja_JP does not change character width with my chosen font (still Envy Code R). Or is this supposed to mean the only way I can change the rendering is choosing an "appropriate" font as well as an "appropriate" CJK locale.

    I am on 2.7.5 if that matters.

  15. mintty commented on May 31, 2017

    @mintty
    Owner

    ... That looked like a proposal for a -cjk_width flag that was eventually turned down and instead opting for setting ambiguous width via a test against the Greek letter alpha's width as reported by the current font? So changing my font to one that reports Greek letter alpha's as wide would cause mintty to render ambiguous characters as wide?

    That was the solution at that time, yes. But it was later changed to be triggered by locale setting rather than font properties. The font checking code is still in but I have the impression it is not effective anymore.

    Using the font in your example and setting 'Locale' in mintty options(exporting LC_ALL is overridden somewhere on my setup i guess), I do indeed get this character rendering as full width.

    The advantage of using a CJK font is that the glyphs are more likely to match the expected rendering behaviour. It also works for example with DejaVu Sans Mono, but here the glyph looks more widened.
    With Envy Code R actually, I cannot reproduce what you describe. There the glyph is already too wide in non-CJK locale mode, and would get widened extremely in CJK-locale-triggered ambiguous-wide mode, so that only half of the star is visible.
    615

  16. 11 remaining items

  17. kkartaltepe commented on Sep 23, 2017

    @kkartaltepe
    Author

    Long delay on my end, not sure if there were other tweaks but 2.7.9 looks like it also fixed some other rendering glitches i was having with these characters. Haven't noticed any regressions been on 2.7.9 for a few weeks now, Huge thanks!

  18. mintty commented on Sep 23, 2017

    @mintty
    Owner

    Thanks for the feedback; actually there was a related change meanwhile after 2.7.9. I would appreciate if you can check the current repository version too.

  19. kkartaltepe commented on Sep 24, 2017

    @kkartaltepe
    Author
  20. kkartaltepe commented on Oct 2, 2017

    @kkartaltepe
    Author

    So far I have only noticed one difference between 2.7.9 and the commit that I have been running 3cabecf which had do with the ∞ glyph.
    2.7.9 rendered sentence:
    2.7.9
    3cabecf rendered sentence:
    master
    Sentence:
    "I am erdos ∞"

    interestingly if i scale up the font enough the infinity ends up being displayed properly at certain intervals. like so. But going to the next level higher breaks rendering again.
    correct interval on master
    next step master

    --Edit--
    Renders the same on current head 667f9b6

  21. mintty commented on Oct 2, 2017

    @mintty
    Owner

    The scale-jumping is weird and I'll try if I can tweak that.
    But the main purpose of the change was to avoid clipping in as many cases as possible, especially in "ambiguous wide" mode (which people seem to appreciate in support of "Powerline fonts").
    Try the following test cases (added infinity), and also with LC_CTYPE=zh_CN.utf8 mintty:

    ◆◇æœ━╋▅
    ◆H◇HæHœH━H╋H▅H
    HHHHHHHHHHHHHHH
    ※℃℉ÅⅠ∪∬∮⑴ⓠ⓾♬♭♯∞
    ※H℃H℉HÅHⅠH∪H∬H∮H⑴HⓠH⓾H♬H♭H♯H∞H
    
  22. kkartaltepe commented on Oct 2, 2017

    @kkartaltepe
    Author

    Alright i found the issue (error?), I had previously in our escapades with LC_* types. If I have Locale set in my minttyrc then all LC_* types are overridden or just unset (so with Locale=en_US in my config any attempts at setting LC_CTYPE or LC_ALL did nothing).

    Setting LC_CTYPE=zh_CN.utf8 the characters in your test cases are for the most part legible (without LC_CTYPE all but the 3rd test case are illegible). However a number of the characters in ※℃℉ÅⅠ∪∬∮⑴ⓠ⓾♬♭♯∞ are single width in my fonts while some are double width. The single width characters appear to be stretched and cut off most notably Å and now that I take a closer look perhaps infinity as well)

    master en_us
    master en_US
    master zh_ch
    master zn_CH
    2.7.9 en_us
    2.7.9
    LC_CTYPE doesnt appear to function in 2.7.9.

  23. kkartaltepe commented on Oct 2, 2017

    @kkartaltepe
    Author

    Also looks like issues with overlapping characters not re-rendering when being highlighted (from pre-2.7.9) was fixed which is nice :)

  24. mintty commented on Oct 2, 2017

    @mintty
    Owner

    First, LC_CTYPE would be overriden by LC_ALL; maybe that's why it doesn't work? Use LC_ALL=.. mintty then.

    I'm dismayed by your Å, I don't see that here. What's your font?
    That seems to be the only glitch in your screenshot (considering that characters like encircled 10 cannot really be squeezed into a single-width cell).

  25. kkartaltepe commented on Oct 2, 2017

    @kkartaltepe
    Author

    Still using the same Envy Code R linked earlier in this thread, on windows 7 with i believe no other fonts installed. Im not to sure how to figure out where that glyph is coming from but it looks like some how the glyph with the font is not being selected.

    --- edit ---
    It may be the font is too old and doesnt have proper unicode support for the unicode characters it maps. Im not very well informed on the intricacies of fonts.

    --- edit 2 ---
    Oh looks like the font maps 0x00C5 but your test case is 0x212B

  26. mintty commented on Oct 2, 2017

    @mintty
    Owner

    I've just installed Envy Code R (both with and without "for Powerline") and I don't see that effect.

  27. kkartaltepe commented on Oct 3, 2017

    @kkartaltepe
    Author

    I'm not sure how I can help you replicate the issue, I did notice that starting with
    LC_CTYPE=zh_CN.utf8 ./mintty.exe
    print the test to the screen,
    go to options and set locale to en_US
    the text already printed will be modified to look like
    old text after locale change

    Not sure if this is what your text looks like or if this is just some undefined behavior. but this does make the ringed A sit nicely in its double column (similar for ♯) and the symbol provided by the font is no longer stretched (∪) though ∞ which started this all does not change.

  28. mintty commented on Oct 3, 2017

    @mintty
    Owner

    ∞ is actually on the border of fitting into a single-width cell or not, so it might be assessed differently when scaling due to rounding. That would explain the width-jumping when zooming.
    I could add a small tolerance (as I tried before) to catch that, but then other characters would be affected.
    If you want to check out the algorithm for possible tweaking, it's in wininput.c: win_char_width.

  29. mintty commented on Oct 23, 2017

    @mintty
    Owner

    Released 2.8.0.

  30. mintty commented on May 20, 2020

    @mintty
    Owner

    Released 3.1.5 with explicit character width attribute support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions