Fix SGR 2 (dim/faint) rendering on light backgrounds#478
Fix SGR 2 (dim/faint) rendering on light backgrounds#478evertjr wants to merge 1 commit intomigueldeicaza:mainfrom
Conversation
|
I'll be testing for a while to see if this introduces any problems during use, when I'm confident I'll mark as ready for review. |
|
Perhaps we should just use alpha transparency in that case, rather than going to black. That should give us the same effect, this is what Ghostty does. |
819d08e to
86bdaba
Compare
86bdaba to
5e6a2c9
Compare
|
Thank you, this makes sense. U had initially missed the bit about the character drawing challenge, in that case, perhaps your color mixing is a better approach. What do you think? |
dimmedColor() blended the foreground toward black (RGB * 0.5), which made dim text darker on light backgrounds — the opposite of "faint". Replace with dimmedColor(towards:) that takes the cell background color and produces a fully-opaque 50 % blend between foreground and background. This reduces contrast correctly regardless of whether the theme is light or dark, and avoids tiling artifacts on box-drawing character runs that semi-transparent fills would cause.
I think you're right, if we need to pre-composite for tiled characters anyway, doing it at the source for all dim text is simpler. I'll revert to the background-blend approach in dimmedColor() and drop the separate opaqueComposite method |
5e6a2c9 to
058be6f
Compare
|
@migueldeicaza did you had time to take look on this approach? |

Problem
dimmedColor()reduces each RGB component by 50 %, effectively blending toward black. On dark backgrounds this looks correct, but on light backgrounds it makes dim text darker.A secondary issue: an alpha-based workaround (

withAlphaComponent(0.5)) produces the right apparent color but leaves visible seams between adjacent box-drawing characters (e.g.─────) because each cell composites independently.This problem is visible on Claude Code in light theme:
SwiftTerm:

macOS Terminal:

Fix
Replace the no-arg
dimmedColor()withdimmedColor(towards:)that takes the cell's background color and produces a fully-opaque 50 % blend between foreground and background. This:NSColor) and iOS (UIColor)The call site in
AppleTerminalViewalready computes the background color for each cell, so passing it to the new method is straightforward.Here is how it looks after the fix:
