Add character-offset bookmarks for FreeInkBook

Implements layout-independent bookmarks using character offsets within chapters instead of percentage-based positions. This allows bookmarks to restore to the exact position regardless of font size or orientation changes. Adds TOC navigation helpers, book progress calculation based on spine item sizes, and a NONE BidiBaseDir option for pre-reordered text. Legacy bookmarks without character offsets fall back to percentage-based positioning.
This commit is contained in:
Justin Mitchell
2026-07-08 00:56:53 -04:00
parent 0848649ce2
commit 3421171670
24 changed files with 1090 additions and 1624 deletions
+3
View File
@@ -424,6 +424,7 @@ bool JsonSettingsIO::saveBookmarks(const std::vector<BookmarkEntry>& bookmarks,
obj["si"] = bookmark.computedSpineIndex;
obj["pc"] = bookmark.computedChapterPageCount;
obj["pp"] = bookmark.computedChapterProgress;
if (bookmark.hasCharStart) obj["cs"] = bookmark.charStart;
}
String json;
@@ -451,6 +452,8 @@ bool JsonSettingsIO::loadBookmarks(std::vector<BookmarkEntry>& bookmarks, const
bookmark.computedSpineIndex = obj["si"] | static_cast<uint16_t>(0);
bookmark.computedChapterPageCount = obj["pc"] | static_cast<uint16_t>(0);
bookmark.computedChapterProgress = obj["pp"] | static_cast<uint16_t>(0);
bookmark.hasCharStart = !obj["cs"].isNull();
bookmark.charStart = obj["cs"] | static_cast<uint32_t>(0);
}
LOG_DBG("BKM", "Loaded %zu bookmarks from file", bookmarks.size());