Eugeny / tabby

A terminal for a more modern age
https://tabby.sh
MIT License
58.25k stars 3.35k forks source link

Minimum Contrast Ratio broken for light themes #9607

Open destin-v opened 4 months ago

destin-v commented 4 months ago

Describe the problem:

When setting the minimum contrast ratio under Appearance it will work on dark themes like Tabby Default. But if you use Tabby Default Light it will not work. I am on MacOS with NerdFonts. I also noticed that when

To Reproduce:

1. Select the Tabby Default light.


Screenshot 2024-04-29 at 1 03 20 PM

2. Then set minimum contrast ratio to a high number.


Screenshot 2024-04-29 at 1 03 59 PM

3. Open a terminal and type ls. This will show no text because there is no contrast.

z0ow commented 1 month ago

Hi, I have set a custom light theme for my instance, but the text is hard to recognize because it is too similar to the background.

By reproducing, the higher Minimum contrast ratio option means lighter foreground (text) colors as I tested. The source codes to increase foreground contrast to the background are:

https://github.com/Eugeny/tabby/blob/f523b114cad47731eb7f307dcd486e7c49956300/tabby-core/src/services/themes.service.ts#L175-L185

,

https://github.com/Eugeny/tabby/blob/f523b114cad47731eb7f307dcd486e7c49956300/tabby-core/src/services/themes.service.ts#L169-L173

,

https://github.com/Eugeny/tabby/blob/f523b114cad47731eb7f307dcd486e7c49956300/tabby-core/src/services/themes.service.ts#L157-L159

and

https://github.com/Eugeny/tabby/blob/f523b114cad47731eb7f307dcd486e7c49956300/tabby-core/src/services/themes.service.ts#L157-L159

In the Tabby Default Light theme the FG and BG are HSL(60, 1%, 30%)/HEX(4D4D4C) and HSL(0, 100%, 100%)/HEX(FFFFFF), respectively. After ensuring/increasing operations the FG has been changed to about HSL(0, 0%, 71%)/HEX(B5B5B5). The above algorithm intends to create a new color to match the minimum contrast limitation by decreasing/increasing saturation and does not contain a BUG. The interesting thing is the minimumContrastRatio is passed to xterm:

https://github.com/Eugeny/tabby/blob/f523b114cad47731eb7f307dcd486e7c49956300/tabby-terminal/src/frontends/xtermFrontend.ts#L417

In xterm documentation, this option should work properly to match this rule, but it failed. I also noticed my minimum contrast ratio is set to 10 (not sure if it has been changed before), which is not the default value of 4.

https://github.com/Eugeny/tabby/blob/f523b114cad47731eb7f307dcd486e7c49956300/tabby-terminal/src/config.ts#L54

In my case, resetting the minimum contrast ratio to 4 or setting it to 1 (do nothing) can finely solve this problem. Please try it 😄.