🐛 Respect spine page-progression-direction in Readium manifests - #1438
Merged
aaronleopold merged 1 commit intoSep 30, 2026
Merged
Conversation
omegaatt36
force-pushed
the
fix/spine-reading-progression
branch
from
September 22, 2026 08:32
03dde3f to
bd457c3
Compare
omegaatt36
force-pushed
the
fix/spine-reading-progression
branch
2 times, most recently
from
September 22, 2026 09:01
58a94e3 to
fb104b7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
omegaatt36
force-pushed
the
fix/spine-reading-progression
branch
from
September 22, 2026 16:29
fb104b7 to
689e046
Compare
Contributor
Author
|
test after patch test with codecov |
Collaborator
|
Thank you, @omegaatt36! I'm hoping to have time to review this over the weekend |
EPUB 3 declares reading direction on <spine page-progression-direction>, but the manifest generator looked for a 'direction' metadata entry that never exists on standard books. readingProgression was therefore always published as 'ltr'. Readium's web reader only enables its CJK vertical pipeline (vertical ReadiumCSS, CJKVerticalSnapper, noVerticalPagination) when the manifest reports 'rtl' alongside a CJK primary language, so vertical Japanese and Chinese EPUBs fell back to horizontal layout in Firefox and to mismatched pagination in Chrome (see stumpapp#723). epub-rs parses only the spine's 'toc' attribute, so the OPF is read directly from the archive. Spine values win over a legacy <meta name="direction"> entry, and non-directional spine values (e.g. 'default') fall through to the legacy meta, then to 'ltr'. Refs stumpapp#723
omegaatt36
force-pushed
the
fix/spine-reading-progression
branch
from
September 30, 2026 12:01
689e046 to
bd7cef3
Compare
aaronleopold
enabled auto-merge (squash)
September 30, 2026 14:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ReadiumManifestGenerator::extract_metadataresolvedreadingProgressionviaget_first("direction"), i.e. it looked for adirectionitem in the OPF<metadata>. That key never exists on standard books:page-progression-directionis an attribute on the<spine>element, and theepubcrate (stumpapp/epub-rs @ baf89d1) never parses it (it only reads the spine'stocattribute). The lookup therefore almost always fell back to"ltr", and EPUB manifests were published withreadingProgression: "ltr".Why this matters
@readium/navigator'sgetScriptMode()only selects its CJK vertical pipeline (cjk-vertical— vertical ReadiumCSS,noVerticalPagination, forced scrolled layout withCJKVerticalSnapper, and the EBPAJ fonts patch for books carryingebpaj:guide-version) when the manifest reportsrtlalongside a CJK primary language.With the manifest saying
ltr:-webkit-writing-mode: vertical-rl) masked this partially, producing the symptoms described in [BUG] Issues with Japanese epubs #723 (lines aligned to the bottom, punctuation on the wrong side); in Firefox, which supports neither-epub-writing-modenor-webkit-writing-mode, vertical books fell back to fully horizontal text.After this change the vertical pipeline activates and vertical EPUBs render correctly in both browsers.
Changes
page-progression-directionfrom the OPF<spine>directly (epub.get_resource_str_by_path(root_file)+ quick-xml), matching onlocal_name()so prefixed variants like<opf:spine>are handled identically<meta name="direction">fallback. Values other thanltr/rtl(e.g. EPUB 3's"default") don't specify a direction: they fall through to the legacy meta if present, then to"ltr"defaultwith and without a legacy meta); the existing fixture is asserted to remain"ltr"Verification
cargo test -p stump_core --lib: 216 passed (15 inreadium::generator);cargo clippy -- -D warningscleanpage-progression-direction="rtl"): manifest now reports"rtl", and the reader renders vertical text correctly in both Firefox (Zen) and ChromeNotes
writing-mode/layout half (thedirectionhalf was fixed in 🐛 Fix Japanese epub text direction #740). I deliberately did not mark it as closing [BUG] Issues with Japanese epubs #723, since that issue may deserve a broader follow-up discussion.conformsTo/rendition:layoutmetadata, so FXL publications are treated as reflowable by the Readium navigator. Forja/zh+rtlfixed-layout books (most manga), the newcjk-verticalpath is now reachable — worth testing with a manga EPUB. The proper fix belongs in a separate PR/issue (emitting layout metadata in the manifest).-epub-writing-mode/-webkit-writing-mode, but it is a symptom-level workaround (and fights the frame'sconnect-src 'none'CSP); fixing the manifest enables Readium's purpose-built pipeline instead.LLM disclosure
Per the contributing guidelines: this contribution was developed with the help of an LLM coding assistant. I reviewed, tested and verified the final change myself (including running the server and reading the affected book in both Firefox and Chrome), and this PR body was written with its help. No commits are signed by the tool.