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
+1 -3
View File
@@ -28,9 +28,7 @@ const EpdGlyph* EpdFontFamily::getGlyph(const uint32_t cp, const Style style) co
return getFont(style)->getGlyph(cp);
}
bool EpdFontFamily::hasGlyph(const uint32_t cp, const Style style) const {
return getFont(style)->hasGlyph(cp);
}
bool EpdFontFamily::hasGlyph(const uint32_t cp, const Style style) const { return getFont(style)->hasGlyph(cp); }
int8_t EpdFontFamily::getKerning(const uint32_t leftCp, const uint32_t rightCp, const Style style) const {
return getFont(style)->getKerning(leftCp, rightCp);
+1
View File
@@ -471,6 +471,7 @@ void GfxRenderer::drawText(const int fontId, const int x, const int y, const cha
namespace {
const char* resolveVisualText(const char* text, std::string& visualBuffer, const BidiUtils::BidiBaseDir baseDir) {
if (!text || *text == '\0') return text;
if (baseDir == BidiUtils::BidiBaseDir::NONE) return text; // caller supplies visual order
if (baseDir != BidiUtils::BidiBaseDir::RTL) {
// Byte-level scan: skip BiDi when no RTL script lead bytes are present.
+4 -1
View File
@@ -8,7 +8,10 @@ namespace BidiUtils {
// AUTO: scan text for first strong directional character (P2/P3 rules)
// LTR: force left-to-right paragraph embedding level
// RTL: force right-to-left paragraph embedding level
enum class BidiBaseDir : signed char { AUTO = -1, LTR = 0, RTL = 1 };
// NONE: text is already in visual order (e.g. FreeInkBook page runs, which
// bake UAX#9 reordering and Arabic shaping in at layout time) — draw
// byte-for-byte, never reorder
enum class BidiBaseDir : signed char { NONE = -2, AUTO = -1, LTR = 0, RTL = 1 };
} // namespace BidiUtils
class FontCacheManager;