Create an outline shader for increased legibility against background images #12375

Closed
opened 2026-01-31 03:13:53 +00:00 by claunia · 13 comments
Owner

Originally created by @Regnander on GitHub (Feb 2, 2021).

Originally assigned to: @zadjii-msft on GitHub.

Description of the new feature/enhancement

Note: This was originally suggested in #7809 but the discussion instead turned into how to change the color of the font itself before it was closed, so I'll try to be more specific right from the start and also provide some images.

I like using images as backgrounds for Command Prompt and Git Bash, but the text tends to blend into the image in some places and create a bad contrast (as seen below).

Background image source: https://unsplash.com/photos/MPqbZXcvAvU

Proposed technical implementation details (optional)

I want to be able to set a text background with something like a fontBackground property in the settings, complete with a #rrggbbaa format so it's possible to have it semi-transparent.

What we have now What I want (mockup)
Originally created by @Regnander on GitHub (Feb 2, 2021). Originally assigned to: @zadjii-msft on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> > Note: This was originally suggested in #7809 but the discussion instead turned into how to change the color of the **_font itself_** before it was closed, so I'll try to be more specific right from the start and also provide some images. I like using images as backgrounds for Command Prompt and Git Bash, but the text tends to blend into the image in some places and create a bad contrast (as seen below). ![][terminal text bg off] _Background image source: https://unsplash.com/photos/MPqbZXcvAvU_ # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. --> I want to be able to set a text background with something like a `fontBackground` property in the settings, complete with a `#rrggbbaa` format so it's possible to have it semi-transparent. | What we have now | What I want (mockup) | | ------------------------------- | ------------------------------ | | ![][terminal text bg off small] | ![][terminal text bg on small] | [terminal text bg off]: https://user-images.githubusercontent.com/17113053/106393309-a36f0a00-63f6-11eb-8bf7-93e5694a114b.png [terminal text bg off small]: https://user-images.githubusercontent.com/17113053/106519213-439e5f00-64db-11eb-9d2a-c5677571ed3f.png [terminal text bg on small]: https://user-images.githubusercontent.com/17113053/106519216-4436f580-64db-11eb-9e9f-74e0b2255083.png
Author
Owner

@Regnander commented on GitHub (Feb 2, 2021):

I might add that this comment in the mentioned issue states that the text foreground and background colors are "controlled by the connected client application". Sadly I can only find a way to change the color of the window background in Command Prompt and Git Bash - not the text background.

@Regnander commented on GitHub (Feb 2, 2021): I might add that [this comment](https://github.com/Microsoft/terminal/issues/7809#issuecomment-702871280) in the mentioned issue states that the text foreground and background colors are "controlled by the connected client application". Sadly I can only find a way to change the color of the _window_ background in Command Prompt and Git Bash - not the _text_ background.
Author
Owner

@skyline75489 commented on GitHub (Feb 3, 2021):

the text foreground and background colors are "controlled by the connected client application"

I need to clarify that the "client application" refers to the shells instead of terminals. See What's the difference between a shell and a terminal? for more details.

You can easily get text with colored background using VT sequences, as most CLI applications are doing. But it's generally not a terminal's responsibility to force the text background color.

@skyline75489 commented on GitHub (Feb 3, 2021): > the text foreground and background colors are "controlled by the connected client application" I need to clarify that the "client application" refers to the *shells* instead of *terminals*. See [What's the difference between a shell and a terminal?](https://github.com/microsoft/terminal/blob/main/doc/Niksa.md#whats-the-difference-between-a-shell-and-a-terminal) for more details. You can easily get text with colored background using VT sequences, as most CLI applications are doing. But it's generally not a terminal's responsibility to force the text background color.
Author
Owner

@zadjii-msft commented on GitHub (Feb 3, 2021):

Thanks for helping clarify @​skyline75489!

Huh. So what you're looking for is having a different BG color for cells with {space, default BG attrs} vs {any other char, default BG attrs}. That would treat spaces as still "transparent", but everything else as having a background.

Wait no that wouldn't work exactly either, because all the spaces between words would be transparent then too. That would maybe look more annoying. Hmm. Part of the trick here is that the entire buffer is filled with spaces by default, so it's really, really hard to tell if a cell has been "written to".

I get that this might be valuable, especially for client apps that you can't change. CMD.exe is a great example. That being said, I
m pretty sure @j4james and @dhowett just did a lot of work to basically ensure that this didn't happen, so that the Windows Terminal would be more in-line with other terminal emulators.

@zadjii-msft commented on GitHub (Feb 3, 2021): Thanks for helping clarify @&ZeroWidthSpace;**skyline75489**! Huh. So what you're looking for is having a different BG color for cells with `{space, default BG attrs}` vs `{any other char, default BG attrs}`. That would treat spaces as still "transparent", but everything else as having a background. Wait no that wouldn't work exactly either, because all the spaces between words would be transparent then too. That would maybe look more annoying. Hmm. Part of the trick here is that the entire buffer is filled with spaces by default, so it's _really, really_ hard to tell if a cell has been "written to". I get that this might be valuable, especially for client apps that you _can't_ change. CMD.exe is a great example. That being said, I m pretty sure @j4james and @dhowett just did a lot of work to basically ensure that this _didn't_ happen, so that the Windows Terminal would be more in-line with other terminal emulators.
Author
Owner

@mdtauk commented on GitHub (Feb 3, 2021):

Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds - and still not interfere with the application's choice of Foreground and Background colours?

@mdtauk commented on GitHub (Feb 3, 2021): Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds - and still not interfere with the application's choice of Foreground and Background colours?
Author
Owner

@arvindsree commented on GitHub (Feb 3, 2021):

Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds - and still not interfere with the application's choice of Foreground and Background colours?

I would second this. It would look much cleaner

@arvindsree commented on GitHub (Feb 3, 2021): > Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds - and still not interfere with the application's choice of Foreground and Background colours? I would second this. It would look much cleaner
Author
Owner

@j4james commented on GitHub (Feb 3, 2021):

Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds

See issues #703 and #621.

As for the OP's request, the best I approach I could think of was to use the prompt command to force the background to black rather than default, giving you something like this:

image

Unfortunately, once you start scrolling, it'll fill the screen with black. Or at least it should - sometimes it does, sometimes it doesn't. I think that's another conpty bug. But the end result - when it's "working" - looks like this.

image

If we ever implement the DEC erase color mode, I think that would allow you to disable that effect, but that'll probably just make half of your applications not work correctly, because they likely depend on the current default behaviour.

If you had more control over the shell colors - which might be feasible with PowerShell or bash - you could possibly make just the output use a black background, but then immediately change back to the default colors. That should solve the scroll color problem, but I don't think there's any way you can do that with the cmd shell.

And then there's the issue of the transparency on the background color. Currently we only make the default background color transparent, so that would be an additional feature that would have to be implemented.

@j4james commented on GitHub (Feb 3, 2021): > Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds See issues #703 and #621. As for the OP's request, the best I approach I could think of was to use the prompt command to force the background to black rather than default, giving you something like this: ![image](https://user-images.githubusercontent.com/4181424/106822599-52217d80-6677-11eb-908d-3c82f26f5dda.png) Unfortunately, once you start scrolling, it'll fill the screen with black. Or at least it should - sometimes it does, sometimes it doesn't. I think that's another conpty bug. But the end result - when it's "working" - looks like this. ![image](https://user-images.githubusercontent.com/4181424/106822821-bb08f580-6677-11eb-8b58-95e75f1ef956.png) If we ever implement the DEC erase color mode, I think that would allow you to disable that effect, but that'll probably just make half of your applications not work correctly, because they likely depend on the current default behaviour. If you had more control over the shell colors - which might be feasible with PowerShell or bash - you could possibly make just the output use a black background, but then immediately change back to the default colors. That should solve the scroll color problem, but I don't think there's any way you can do that with the cmd shell. And then there's the issue of the transparency on the background color. Currently we only make the default background color transparent, so that would be an additional feature that would have to be implemented.
Author
Owner

@zadjii-msft commented on GitHub (Mar 29, 2021):

Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds - and still not interfere with the application's choice of Foreground and Background colours?

I would second this. It would look much cleaner

You know, with the pixel shaders we added recently, I bet someone could whip together a shader for outlining text pretty quickly. That's probably the best solution here - one that doesn't involve overly complicating the buffer model, but still gets the desired effect. I'm gonna leave this open tracking that for now - if someone does figure out the outline shader, they're welcome to make a PR to add it to the shader samples we already have.

EDIT: whoops, I figured that out fast:

image

@zadjii-msft commented on GitHub (Mar 29, 2021): > > Would a glow around the letters solve the legibility issue on top of Acrylic backgrounds - and still not interfere with the application's choice of Foreground and Background colours? > > I would second this. It would look much cleaner You know, with the pixel shaders we added recently, I bet someone could whip together a shader for outlining text pretty quickly. That's probably the best solution here - one that doesn't involve overly complicating the buffer model, but still gets the desired effect. I'm gonna leave this open tracking that for now - ~~if someone does figure out the outline shader, they're welcome to make a PR to add it to the shader samples we already have.~~ EDIT: whoops, I figured that out fast: ![image](https://user-images.githubusercontent.com/18356694/112837720-d71a8900-9061-11eb-89fd-712df73e37f0.png)
Author
Owner

@LuanVSO commented on GitHub (Mar 29, 2021):

are pixel shaders broken on preview?
got the shader to work on stable, but preview doesn't work, even if i pass a invalid path it doesn't show the warning that it couldn't find the shader file

@LuanVSO commented on GitHub (Mar 29, 2021): are pixel shaders broken on preview? got the shader to work on stable, but preview doesn't work, even if i pass a invalid path it doesn't show the warning that it couldn't find the shader file
Author
Owner

@zadjii-msft commented on GitHub (Mar 29, 2021):

are pixel shaders broken on preview?

They shouldn't be, but we've had a couple recent reports of them being busted. What property are you setting on the profile? "experimental.pixelShaderPath"?

@zadjii-msft commented on GitHub (Mar 29, 2021): > are pixel shaders broken on preview? They _shouldn't_ be, but we've had a couple recent reports of them being busted. What property are you setting on the profile? `"experimental.pixelShaderPath"`?
Author
Owner

@DHowett commented on GitHub (Mar 29, 2021):

Nah, they definitely are. It's been so busy that I didn't end up servicing that fix early after the 1.7 cycle.

@DHowett commented on GitHub (Mar 29, 2021): Nah, they definitely are. It's been so busy that I didn't end up servicing that fix early after the 1.7 cycle.
Author
Owner

@zadjii-msft commented on GitHub (Mar 29, 2021):

Ah, okay. Explains why it's working locally then 😋

@zadjii-msft commented on GitHub (Mar 29, 2021): Ah, okay. Explains why it's working locally then 😋
Author
Owner

@LuanVSO commented on GitHub (Mar 29, 2021):

Nah, they definitely are. It's been so busy that I didn't end up servicing that fix early after the 1.7 cycle.

oh, ok

@LuanVSO commented on GitHub (Mar 29, 2021): > Nah, they definitely are. It's been so busy that I didn't end up servicing that fix early after the 1.7 cycle. **_oh, ok_**
Author
Owner

@ghost commented on GitHub (Apr 14, 2021):

:tada:This issue was addressed in #9646, which has now been successfully released as Windows Terminal Preview v1.8.1032.0.🎉

Handy links:

@ghost commented on GitHub (Apr 14, 2021): :tada:This issue was addressed in #9646, which has now been successfully released as `Windows Terminal Preview v1.8.1032.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.8.1032.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12375