terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Italics & Bold not rendering properly if they are the final character - text looks "cut off"

Open Nosamdaman opened this issue 4 years ago • 56 comments

Environment

Windows build number: [Version 10.0.19042.844]
Windows Terminal version: 1.6.10571.0

Any other software?
Ubuntu using WSL 1
Fish Shell

Steps to reproduce

Print any italic text to the terminal

Expected behavior

All characters should be italicized and fully visible.

Actual behavior

The last character before a newline is cut-off where the italic character would bleed into the next character. Note this occurs when using both Cascadia Code and FiraCode in my testing.

After further testing, we've determined that the issue is related to the cleartype antialiasing setting. Using grayscale eliminates the issue.

image

Nosamdaman avatar Mar 04 '21 21:03 Nosamdaman

Interestingly, switching the font back and forth actually fixes the issue for anything that has already been printed.

Nosamdaman avatar Mar 04 '21 21:03 Nosamdaman

Huh. Good catch!

zadjii-msft avatar Mar 04 '21 21:03 zadjii-msft

What is "set_color"?

I have no problem doing it manually (in TCSH).

image

vefatica avatar Mar 04 '21 21:03 vefatica

It's a function in Fish that makes colorizing output a little easier. And not every character crosses over into the next spot, I found that '0' did it a lot. image

Nosamdaman avatar Mar 04 '21 21:03 Nosamdaman

Everything seems to be fine:

aaa

237dmitry avatar Mar 04 '21 21:03 237dmitry

Huh. I've noticed that any action that would cause a re-render like changing the font or font size fixes the issue for anything that's already been printed.

Nosamdaman avatar Mar 04 '21 21:03 Nosamdaman

Thanks. I was using Consolas. I switch to Cascadia Code and tried a few characters that are tycically wide, and a few font sizes. I'm still OK (though the lowercase w's are a bit weird).

image

vefatica avatar Mar 04 '21 21:03 vefatica

I believe this only happens when you're changing colors. So in most cases you wouldn't see it at the end of a line, but I'm guessing the OP is actually writing out text with a black background while the rest of the screen is using the default color (which just happens to be the same value as black), so there is actually an invisible transition from black to default where the characters get clipped.

I'm was aware this could happen when I implemented italics, but I didn't think there was much we could do about it.

j4james avatar Mar 04 '21 21:03 j4james

That makes sense, except I'm not changing the background color as far as I know

Nosamdaman avatar Mar 04 '21 22:03 Nosamdaman

Hmm... you're right. The test case you did with the escape sequence is clearly using the default background, so it can't be that. I'm not sure what is triggering it for you then. I wonder if the acrylic background is the issue.

j4james avatar Mar 04 '21 22:03 j4james

Turning off acrylic didn't fix the issue ... but switching my anti-aliasing mode from "cleartype" to "grayscale" did. It seems like that's what's causing it.

Nosamdaman avatar Mar 04 '21 22:03 Nosamdaman

this only happens when you're changing colors

bbb

May be this is "fish"-behavior

237dmitry avatar Mar 04 '21 22:03 237dmitry

I've confirmed it happens in bash as well

Nosamdaman avatar Mar 04 '21 22:03 Nosamdaman

switching my anti-aliasing mode from "cleartype" to "grayscale" did. It seems like that's what's causing it.

Yep, that's it. I can reproduce it now too.

j4james avatar Mar 04 '21 22:03 j4james

So, when we render individual "runs" of text we clip the rendering region to the estimated space to avoid characters overhanging their boxes. The italics and the spaces are logically two units . . . at first.

I suspect that when we re-render the line containing the italic text (in response to a selection, cursor blink, etc.), we decide that the italic text plus the spaces after it are a single run and don't clip it. Probably due to our "identical visual representation for space characters" "optimization" ;P

DHowett avatar Mar 04 '21 22:03 DHowett

@DHowett So for me in the shell (fish) and on Ubuntu 20.10 it is fine image But in Neovim comments that are italic has this issue for some reason image

Antonio-Bennett avatar Apr 03 '21 00:04 Antonio-Bennett

I'm having the same issue, which I notice only with neovim so far and fonts without italic variant

xbb avatar Apr 19 '21 14:04 xbb

I'm also seeing this issue in vim/neovim regardless of "antialiasingMode": "cleartype" or "antialiasingMode": "grayscale". Especially noticeable when 0 or { are the ending characters.

grayscale_vim

Although, grayscale seemingly fixes it in the shell, zsh in this case.

echo -e "\e[3m foo {{{ \e[23m" grayscale_shell

Windows Terminal Preview
Version: 1.8.1032.0

Gee19 avatar May 24 '21 06:05 Gee19

might I add that the behavior is not consistent though, on certain lines the last character will not be cut out.. while on some it will be?...

Screenshot_34

Windows Terminal version (or Windows build number)

10.0.19042.1052

Other Software

Ubuntu WSL, using Vim inside the terminal

Font Used

Ubuntu Mono (which has true italic)

chrisdcao avatar Jun 24 '21 04:06 chrisdcao

I know that italics usually goes out of their bounding box in the font design, and turning on full-hinting like windows does will force the font to strictly follow the the box guide, which might cut some characters off..

But how does that explain characters without the error though.. That's what confuses me..

Caption: Italic goes off bounding box, which make full-hinting system like windows terminal likely to cut off: Screenshot_35

chrisdcao avatar Jun 24 '21 04:06 chrisdcao

Sometimes terminal's text run splitter chooses to end the run at the last character and clip to the bounding box, and sometimes it encompasses one or more of the following space characters. When it chooses to include the spaces, the clip extends to cover those cells and doesn't truncate the last glyph.

DHowett avatar Jun 24 '21 04:06 DHowett

Would there be a way to fix this? I mean it sounds like we can fix this by making the behavior of clipping more consistent (like always encompasses some of the following space characters until a non-italic glyph, for example)..

I have no idea how hard it is to implement the functionality though

chrisdcao avatar Jun 24 '21 04:06 chrisdcao

Any updates on this? Literally the ONLY issue I have with windows terminal is this!

aprowe avatar Sep 13 '21 18:09 aprowe

Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button? image That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

zadjii-msft avatar Sep 14 '21 10:09 zadjii-msft

I have the same problem when using Neovim with WSL2 and Windows Terminal

Rz-Rz avatar Dec 04 '21 14:12 Rz-Rz

For me, using Inconsolata (Nerd Font version), I get black boxes, presumably where the next character is supposed to be..? image

Cascadia Code does tend to do what is mentioned above and clips text.

Pranav-Badrinathan avatar Jan 04 '22 00:01 Pranav-Badrinathan

@Pranav-Badrinathan this is because the Italic variant of your font has a significantly smaller width than the Roman variant. That's actually a hole that was introduced to make up for the accumulated missing width.

DHowett avatar Jan 04 '22 00:01 DHowett

Yeah, this is really more a variant of #10678, only kind of in reverse. I'm assuming the atlas renderer should fix this.

j4james avatar Jan 04 '22 00:01 j4james

...Italic variant of your font has a significantly smaller width than the Roman variant. That's actually a hole that was introduced to make up for the accumulated missing width.

Makes sense. 1 to 2 pixels slimmer in Italics, and as you said that causes it to freak out a bit when the sentence gets long enough, by the time which the character is quite far behind. 😅

Surprising, as the font is monospace, and I thought that they were supposed to remain the same size regardless formatting... Oh well. Glad to see that this issue is set to be resolved this year!

Pranav-Badrinathan avatar Jan 05 '22 23:01 Pranav-Badrinathan

has anyone has a solution for this? it is because bold font is showing as a regular font and not being bolded

bryant-the-coder avatar Feb 01 '22 23:02 bryant-the-coder