SUMMARY I have an 800-page EPUB book which I cannot re-share. Okular renders a black background for this, while another ebook reader (http://epubreader.1bestlink.net/) renders it correctly. SOFTWARE/OS VERSIONS KDE Plasma Version: 5.21.4 KDE Frameworks Version: 5.80.0 Qt Version: 5.15.2 ADDITIONAL INFORMATION I tested with Okular built from git, got same result.
Created attachment 137446 [details] CSS file found inside the EPUB
I tried deleting all the occurrences of "color: #000000;" and "background: transparent;" from the CSS and then repack the EPUB, but it still renders black over black.
Can you replace all the text of your restricted book with "Lorem ipsum" or something similar using Sigil or Calibre editor and attach the file (if it's reproducible) to this bug report? Thanks in advance for your answer. P.S. I cannot reproduce the bug with the CSS attached and calibre-crafted book.
Created attachment 137450 [details] Cut-down EPUB file to demonstrate the bug
Confirmed. Calibre viewer shows the white background and Okular shows black.
Thank you for analyzing this bug, Yuri! Calibre also renders black text on a dark background when using the default system theme, but it is possible to fix it by either switching to a light theme, or by selecting "Override all book colors... in dark mode".
There is <body style="background-color:black;"> in cover.xhtml. With style="background-color:black;" removed, everything works as expected. So I think it's not a bug.
Do you think I could file a feature request for an option similar to Calibre? Override all book colors: ( ) Never (o) In dark mode ( ) Always
(In reply to bernie from comment #8) > Do you think I could file a feature request for an option similar to Calibre? > > Override all book colors: > ( ) Never > (o) In dark mode > ( ) Always I might be wrong, but isn't it already here (one of the options on the "Accessibility" page)? https://docs.kde.org/trunk5/en/okular/okular/configaccessibility.html
> I might be wrong, but isn't it already here > (one of the options on the "Accessibility" page)? I tried a few of them, and... - "Change Paper Color" has no effect on this book - "Invert Colors" renders white background with white text (so it's still unreadable) - "Change Dark & Light Colors" renders both page and text in the dark color - "Convert to Black & White" leaves text & page to black - "Invert..." and "Shift..." also have no effect.
On second thought, it seems Calibre is ignoring the "background-color:black" in <body>, because the background is painted in the Breeze-dark window background color. Similarly, http://epubreader.1bestlink.net/ renders page backgrounds in white. Perhaps Okular is ignoring those "background: transparent" attributes in the css file? I'm not sure in what order they should be applied...
Oh, I see now: only cover.xhtml has style="background-color:black;". The following sections don't specify the background-color for <body>, but Okular keeps on using black throughout the entire book. Reopening the bug.
Ok. Here's oneliner that will be never accepted (but tested to work). ;) diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp index 291b9caed..2f79dbc9b 100644 --- a/generators/epub/converter.cpp +++ b/generators/epub/converter.cpp @@ -217,6 +217,7 @@ QTextDocument *Converter::convert(const QString &fileName) // as QTextCharFormat::anchorNames() ignores sections, replace it with <p> htmlContent.replace(QRegExp(QStringLiteral("< *section")), QStringLiteral("<p")); htmlContent.replace(QRegExp(QStringLiteral("< */ *section")), QStringLiteral("</p")); + htmlContent.replace(QStringLiteral("background-color:black;"), QStringLiteral("")); // convert svg tags to img const int maxHeight = mTextDocument->maxContentHeight();
Any update on this? I also have the exact same issue and it makes it impossible to read epubs with Okular