From 3671bdba0bad960025efa7dc80023a952d5fd753 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sat, 23 May 2026 17:53:45 +0200 Subject: [PATCH 1/7] Recognize and use printed pages info --- docs/epub-toc-navigation.md | 37 ++++ docs/file-formats.md | 29 +++ lib/Epub/Epub.cpp | 112 ++++++++++++ lib/Epub/Epub.h | 3 + lib/Epub/Epub/Section.cpp | 170 +++++++++++++++++- lib/Epub/Epub/Section.h | 14 ++ .../Epub/parsers/ChapterHtmlSlimParser.cpp | 83 ++++++++- lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h | 20 +++ lib/Epub/Epub/parsers/ContentOpfParser.cpp | 11 ++ lib/Epub/Epub/parsers/ContentOpfParser.h | 3 +- lib/Epub/Epub/parsers/PageMapParser.cpp | 97 ++++++++++ lib/Epub/Epub/parsers/PageMapParser.h | 38 ++++ lib/Epub/Epub/parsers/TocNavParser.cpp | 106 +++++++++-- lib/Epub/Epub/parsers/TocNavParser.h | 36 +++- lib/Epub/Epub/parsers/TocNcxParser.cpp | 70 ++++++++ lib/Epub/Epub/parsers/TocNcxParser.h | 31 +++- src/activities/boot_sleep/SleepActivity.cpp | 15 +- src/activities/reader/EpubReaderActivity.cpp | 8 +- src/components/themes/BaseTheme.cpp | 23 ++- src/components/themes/BaseTheme.h | 2 +- 20 files changed, 869 insertions(+), 39 deletions(-) create mode 100644 lib/Epub/Epub/parsers/PageMapParser.cpp create mode 100644 lib/Epub/Epub/parsers/PageMapParser.h diff --git a/docs/epub-toc-navigation.md b/docs/epub-toc-navigation.md index 6f40af82..b84d3871 100644 --- a/docs/epub-toc-navigation.md +++ b/docs/epub-toc-navigation.md @@ -159,6 +159,43 @@ When `startNewTextBlock` reuses an empty text block (the early-return path), `wo `scripts/generate_spine_toc_edges_epub.py` generates `test/epubs/test_spine_toc_edges.epub`, a purpose-built epub that exercises spine/TOC relationship patterns. See the script header for the full list of edge cases covered. +## Printed-page labels (status bar hint) + +The status bar can show the printed-book page number for the current rendered page in addition to the device-relative `currentPage/pageCount` counter, e.g. `(42) 137/305 18%`. The printed-page label is sourced from the EPUB itself; the device counter remains authoritative for spine pagination. + +### Three input formats + +The reader accepts printed-page data from three places, in priority order: + +1. **Inline `doc-pagebreak` markers** in the XHTML (EPUB 3 accessibility convention): any element with `role="doc-pagebreak"` or `epub:type="pagebreak"`. The visible label is read from `aria-label`, falling back to `title`, falling back to the NCX/nav/page-map label if cross-referenced. +2. **EPUB 3 `