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

Dark mode for pdf #1879

Closed
Nriver opened this issue Nov 25, 2022 · 2 comments
Closed

Dark mode for pdf #1879

Nriver opened this issue Nov 25, 2022 · 2 comments

Comments

@Nriver
Copy link

Nriver commented Nov 25, 2022

Dark mode works well for epub. But I noticed the dark mode/night theme does not work in pdf files for now. Could it be supported?

@danielweck
Copy link
Member

danielweck commented Nov 28, 2022

Hello, much like with EPUB Fixed-Layout (FXL) / pre-paginated documents, publisher styles take precedence over user preferences when rendering PDF files. These "pixel perfect" formats are all about respecting authored layout / format / typeset / colour scheme. There is a strong case for accessibility when implementing support for "dark" / "night" / "high contrast" colour themes, but that is where reflowable / flexible formats are more suitable as they do not get in the way of achieving higher accessibility / usability (notably, EPUB and HTML without any "fixed" styling).

Over the years, this topic has been much discussed over at PDF.js (the library used under the hood by Thorium to render PDF documents):

https://github.com/mozilla/pdf.js

https://mozilla.github.io/pdf.js/web/viewer.html

I believe PDF.js supports Windows "high contrast mode", but I have never tried it myself (I work primarily on Mac OS computers)

Imagine trying to consistently override the styles of such a PDF document (warning, 5MB download):

https://github.com/mozilla/pdf.js/files/1522715/wuppertal_2012.pdf

One common approach is to apply a CSS filter that "inverts" colours (nowadays modern CSS engines also support contrast directives), but there are significant caveats such as treating embedded images appropriately.

Technically it would be near impossible to consistently apply fine-grained CSS "colour" overrides that would result in the expected outcome (e.g. "background" vs. "foreground" colour with adequate contrast) because of overlapping layout boxes, poor semantic structure, etc. So the naive / brute-force CSS "filter" approach makes sense.

I am closing this issue as I believe this is an intractable problem, and I think slightly outside the scope of Thorium given our current development resources (we focus more on EPUB and audiobooks, PDF is a "bonus" feature in my opinion ;)

But please feel free to continue the discussion here, and if there is further interest we can migrate this issue to a proper GitHub "discussion".

@danielweck
Copy link
Member

Related issue: #577

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants