[PR #5277] [MERGED] Use grayscale AA always on non-opaque backgrounds #26218

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5277
Author: @zadjii-msft
Created: 4/7/2020
Status: Merged
Merged: 4/24/2020
Merged by: @undefined

Base: masterHead: dev/migrie/b/5098-cleartype-on-light


📝 Commits (9)

  • d714a10 maybe it's because we're treating the foreground as having an alpha?
  • a7aceaf Revert "maybe it's because we're treating the foreground as having an alpha?"
  • d958c91 This works but it's really dirty - just render things on the transparent default BG as grayscale always
  • 29b36f7 Only do the grayscale thing if opacity != 1.0f
  • b12e11c This is a tad bit cleaner
  • e5c9765 this is much cleaner
  • a9a2811 good bot
  • 60da00a Merge remote-tracking branch 'origin/master' into dev/migrie/b/5098-cleartype-on-light
  • fd072bb Initialize the opacity correctly too'

📊 Changes

5 files changed (+132 additions, -3 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+29 -1)
📝 src/renderer/dx/CustomTextRenderer.cpp (+37 -0)
📝 src/renderer/dx/CustomTextRenderer.h (+3 -0)
📝 src/renderer/dx/DxRenderer.cpp (+60 -2)
📝 src/renderer/dx/DxRenderer.hpp (+3 -0)

📄 Description

Summary of the Pull Request

When we're on acrylic, we can't have cleartype text unfortunately. This PR changes the DX renderer to force cleartype runs of text that are on a non-opaque background to use grayscale AA instead.

References

Here are some of the URLS I was referencing as writing this:

Additionally:

  • This was introduced in #4711

PR Checklist

Detailed Description of the Pull Request / Additional comments

Basically, if you use cleartype on a light background, what you'll get today is the text foreground color added to the background. This will make the text look basically invisible.

So, what I did was use some trickery with PushLayer to basically create a layer where the text would be forced to render in grayscale AA. I only enable this layer pushing business when both:

  • The user has enabled cleartype text
  • The background opacity < 1.0

This plumbs some information through from the TermControl to the DX Renderer to make this smooth.

Validation Steps Performed

Opened both cleartype and grayscale panes SxS, and messed with the opacity liberally.


🔄 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/5277 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 4/7/2020 **Status:** ✅ Merged **Merged:** 4/24/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/b/5098-cleartype-on-light` --- ### 📝 Commits (9) - [`d714a10`](https://github.com/microsoft/terminal/commit/d714a10095cbd2cc3029ccdf53cf1588f7686e02) maybe it's because we're treating the foreground as having an alpha? - [`a7aceaf`](https://github.com/microsoft/terminal/commit/a7aceaf286115ecabe635e769b0bc8f2aef8818b) Revert "maybe it's because we're treating the foreground as having an alpha?" - [`d958c91`](https://github.com/microsoft/terminal/commit/d958c91031b0d96beb13478f67b16f9d2f1b2cee) This works but it's really dirty - just render things on the transparent default BG as grayscale always - [`29b36f7`](https://github.com/microsoft/terminal/commit/29b36f72c064ac692bdec0c0f52489890dca9cad) Only do the grayscale thing if opacity != 1.0f - [`b12e11c`](https://github.com/microsoft/terminal/commit/b12e11c5c9634e986672317539047385007b087f) This is a tad bit cleaner - [`e5c9765`](https://github.com/microsoft/terminal/commit/e5c976569f9b64eb5cf8ffe44c8104cbaf581716) this is much cleaner - [`a9a2811`](https://github.com/microsoft/terminal/commit/a9a28114a0072eaa31c3f120bd9ec47ef16cb0df) good bot - [`60da00a`](https://github.com/microsoft/terminal/commit/60da00a371690d279e8276a7170afa348a890abc) Merge remote-tracking branch 'origin/master' into dev/migrie/b/5098-cleartype-on-light - [`fd072bb`](https://github.com/microsoft/terminal/commit/fd072bb6993292cebe805c3e02872c9974c71efb) Initialize the opacity correctly too' ### 📊 Changes **5 files changed** (+132 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+29 -1) 📝 `src/renderer/dx/CustomTextRenderer.cpp` (+37 -0) 📝 `src/renderer/dx/CustomTextRenderer.h` (+3 -0) 📝 `src/renderer/dx/DxRenderer.cpp` (+60 -2) 📝 `src/renderer/dx/DxRenderer.hpp` (+3 -0) </details> ### 📄 Description ## Summary of the Pull Request When we're on acrylic, we can't have cleartype text unfortunately. This PR changes the DX renderer to force cleartype runs of text that are on a non-opaque background to use grayscale AA instead. ## References Here are some of the URLS I was referencing as writing this: * https://stackoverflow.com/q/23587787 * https://docs.microsoft.com/en-us/windows/win32/direct2d/supported-pixel-formats-and-alpha-modes#cleartype-and-alpha-modes * https://devblogs.microsoft.com/oldnewthing/20150129-00/?p=44803 * https://docs.microsoft.com/en-us/windows/win32/api/d2d1/ne-d2d1-d2d1_layer_options * https://docs.microsoft.com/en-us/windows/win32/direct2d/direct2d-layers-overview#d2d1_layer_parameters1-and-d2d1_layer_options1 * https://docs.microsoft.com/en-us/windows/win32/api/dcommon/ne-dcommon-d2d1_alpha_mode?redirectedfrom=MSDN#cleartype-and-alpha-modes * https://stackoverflow.com/a/26523006 Additionally: * This was introduced in #4711 ## PR Checklist * [x] Closes #5098 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments Basically, if you use cleartype on a light background, what you'll get today is the text foreground color _added_ to the background. This will make the text look basically invisible. So, what I did was use some trickery with `PushLayer` to basically create a layer where the text would be forced to render in grayscale AA. I only enable this layer pushing business when both: * The user has enabled cleartype text * The background opacity < 1.0 This plumbs some information through from the TermControl to the DX Renderer to make this smooth. ## Validation Steps Performed Opened both cleartype and grayscale panes SxS, and messed with the opacity liberally. --- <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:14:44 +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#26218