Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is unreadable if the system theme is dark #4385

Closed
whitequark opened this issue May 9, 2024 · 5 comments · Fixed by #4391
Closed

Documentation is unreadable if the system theme is dark #4385

whitequark opened this issue May 9, 2024 · 5 comments · Fixed by #4391
Labels
fix pending PR with a fix is pending

Comments

@whitequark
Copy link
Member

E.g. here:

Screenshot_20240509_070157

I've fixed this problem before so let me know if you want assistance in doing this in a sphinx-compatibel way without JS.

@whitequark whitequark added the bug label May 9, 2024
@jix
Copy link
Member

jix commented May 9, 2024

On my personal blog I'm handling diagrams with some CSS that inverts the brightness but keeps the hues roughly the same, might be useful here too:

filter: url("data:image/svg+xml,<svg xmlns='http%3A//www.w3.org/2000/svg'><filter id='f'><feColorMatrix color-interpolation-filters='sRGB' type='matrix' values='1.47 -1.73 -0.467 0 0.867 -0.733 0.467 -0.467 0 0.867 -0.667 -1.07 1.07 0 0.867 0 0 0 1.0 0'></feColorMatrix></filter></svg>#f");

The color-interpolation-filters='sRGB' is needed to get consistent behavior across browsers even though it's arguably wrong. The exact transformation matrix also depends on the foreground and background colors used in the theme (mostly because mapping #000 in diagrams made for light themes to #fff in dark themes is too bright and it should be mapped to the body text color instead).

@whitequark
Copy link
Member Author

Oh, that's way more advanced than what I did! Very clever. How's the performance like?

@jix
Copy link
Member

jix commented May 9, 2024

I haven't noticed any negative performance impact of this, including on mobile browsers, but my blog also isn't the most demanding page in general. AFAICT from chrome's rendering dev tools the SVGs are still rendered once (with the filter applied) into tiles/layers shared with the surrounding content, so unless it's used for animated or otherwise dynamic content I wouldn't expect this to have a significant impact on performance. I didn't find a way to easily check how Firefox behaves here.

@jix
Copy link
Member

jix commented May 9, 2024

I also found the python script I used to compute the matrix coefficients: invert_filter.py. Lines 13 to 17 contain the foreground and background colors for both themes and lines 19 to 23 are used to constrain the remaining degrees of freedom and I played around with those until it looked good to me.

@KrystalDelusion
Copy link
Member

image
Took a bit to figure out how to get it to work with the dark/light mode switcher but it even works for the TeX generated graphics. PR soon to follow.

@KrystalDelusion KrystalDelusion linked a pull request May 10, 2024 that will close this issue
@KrystalDelusion KrystalDelusion added fix pending PR with a fix is pending and removed bug labels May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pending PR with a fix is pending
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants