Skip to content

✨ feat(reader): add a Dark sepia theme (#91) - #92

Merged
vitofico merged 1 commit into
mainfrom
feat/issue-91-dark-sepia-theme
Jul 28, 2026
Merged

✨ feat(reader): add a Dark sepia theme (#91)#92
vitofico merged 1 commit into
mainfrom
feat/issue-91-dark-sepia-theme

Conversation

@vitofico

Copy link
Copy Markdown
Owner

Closes #91.

The problem

Quire ships three reader themes, and on a phone in a dark room none of them work. Light and Sepia are both bright pages; Dark is cold white-on-black at roughly 19.6:1 contrast. The reporter's workaround was to select Sepia and switch on Android's system-wide colour inversion — which also inverts every image and cover in the book.

What this adds

A fourth preset, Dark sepia: warm text on a warm-dark background, using Calibre's own sepia-dark values (#F6F3E9 on #39322B) since that is the scheme the request named. The pair measures 11.36:1 — softer than Dark, still past the WCAG AAA floor. A test asserts it stays above the AA floor of 4.5:1, so a later colour tweak can't quietly make the theme unreadable.

Custom colours were only worth attempting once one thing was settled: whether Readium gates them the same way it gates line height and paragraph indent. If it did, the theme would silently do nothing for anyone who leaves "use the book's paragraph styling" switched on. It doesn't — --USER__textColor and --USER__backgroundColor carry no readium-advanced-on prefix in ReadiumCSS, and the Kotlin side assigns them unconditionally. The same rules are present in the RTL and CJK stylesheets, so right-to-left and vertical-script books get the theme too.

The preset is built on Readium's DARK appearance rather than SEPIA. Sepia would be the intuitive base, but its stylesheet blends images with mix-blend-mode: multiply, which assumes a light backdrop and smears them against a dark one.

Two things that needed care

  • The immersive system bars keyed off theme != DARK. A new dark theme that isn't literally DARK would have got dark icons on a dark background — invisible buttons. That's now !theme.isDark, a property of the theme rather than an equality check.
  • Both theme pickers formatted labels with name.lowercase(), which renders DARK_SEPIA as "Dark_sepia", and laid the options out in a non-wrapping Row that a fourth entry would overflow on a narrow screen. They now share a displayLabel() helper and stack vertically, matching the font-family picker directly below them in both files.

The enum deliberately holds no Readium type. An earlier revision put Theme in the constructor; because Readium's Theme initialises through android.graphics.Color, that dragged the Android framework into the class initializer and broke every plain JVM test that so much as named a theme. The mapping lives in an exhaustive when instead, which still fails compilation if a future theme forgets to declare its appearance.

What does not change

The three existing themes emit null for both colours, so their rendering is byte-identical to before — there's a regression test pinning exactly that. Persistence needed no change: themes are stored by enum name with a fallback to Light, so a downgrade to an older build resets to Light rather than crashing. Nothing outside the reader surface is re-themed; the app's own chrome is untouched.

Links still render cyan rather than warm — night mode forces that colour at higher specificity than the user text colour. That is already true of Dark today, so it's left alone.

Verification

Built and installed on an emulator (Pixel 10, API 37) and read a real EPUB through it. Sampling the rendered page gives exactly #39322B background and #F6F3E9 text, which confirms the preference survives the whole path into ReadiumCSS. The picker renders "Dark sepia" with no underscore and all four options fit.

CONTRIBUTING asks for before/after screenshots on UI changes; they were captured locally during that emulator run but aren't attachable from the CLI, so the pixel sampling above stands in as the evidence.

One unrelated thing surfaced on the emulator: the app trips Android's 16 KB page-size warning via two dependency native libs (libimage_processing_util_jni.so, libandroidx.graphics.path.so). It runs in compatibility mode. Pre-existing and out of scope here, but worth its own issue.

Light, Dark and Sepia all assume you want either a bright page or a
cold high-contrast one. On a phone in a dark room none of them are
comfortable, and the workaround reported in #91 — pick Sepia, then turn
on Android's system-wide colour inversion — inverts images and covers
along with the text.

Dark sepia is warm text on a warm-dark background: Calibre's own
"sepia dark" values (#F6F3E9 on #39322B), since that is the scheme the
request named. The pair is 11.36:1, softer than Dark's ~19.6:1 but well
past the WCAG AAA floor; a test asserts it stays above AA so a later
colour tweak can't quietly make the theme unreadable.

It is built on Readium's DARK appearance rather than SEPIA: the sepia
stylesheet blends images with mix-blend-mode: multiply, which assumes a
light backdrop and smears them against a dark one. The custom colours
ride on top via EpubPreferences.textColor/backgroundColor, which
ReadiumCSS applies unconditionally — unlike line height and paragraph
indent, they are not gated behind the publisher-styles toggle, so the
theme holds either way.

Two call sites needed care:

- The immersive system bars keyed off `theme != DARK`, which would have
  painted dark icons onto the new dark background. That is now
  `!theme.isDark`, a property of the theme rather than an equality test.
- Both theme pickers formatted labels with `name.lowercase()`, which
  renders DARK_SEPIA as "Dark_sepia", and laid four options out in a
  non-wrapping Row. They now share a displayLabel() helper and stack
  vertically, matching the font-family picker directly below them.

The enum deliberately holds no Readium type: Readium's Theme initialises
through android.graphics.Color, so storing one would drag the framework
into the class initializer and force every plain JVM test that names a
theme onto Robolectric.

Verified on an emulator (Pixel 10, API 37): the rendered page samples
exactly #39322B / #F6F3E9. Links stay cyan, as they already do in Dark —
night mode forces that colour at higher specificity.
@vitofico
vitofico merged commit 885268a into main Jul 28, 2026
5 checks passed
@vitofico
vitofico deleted the feat/issue-91-dark-sepia-theme branch July 28, 2026 10:43
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

Successfully merging this pull request may close these issues.

Dark Sepia or custom themes

1 participant