From d49268439356e4fdde43cf841c4ed8f8ce0f9a90 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sun, 17 May 2026 14:01:22 +0200 Subject: [PATCH] Prperly use font override on boot --- src/main.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 09a04b1d..8ab62df7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -201,9 +201,27 @@ void ensureSdFontLoadedForPath(const char* path) { const bool isTxtMd = static_cast(FsHelpers::hasTxtExtension)(filePath) || static_cast(FsHelpers::hasMarkdownExtension)(filePath); if (isTxtMd) { + // TXT/MD has no per-book SD font override — use global settings directly. sdFontSystem.ensureLoaded(renderer, SETTINGS.txtSdFontFamilyName, SETTINGS.txtFontSize); + return; + } + + // For EPUB: honour per-book SD font and/or size overrides. The book record + // is available here — the reader activity hasn't started yet, but + // RecentBooksStore already has the persisted overrides for this path. + const RecentBook book = RECENT_BOOKS.getBookByPath(path); + const uint8_t effectiveSize = + (book.fontSizeOverride >= 0) ? static_cast(book.fontSizeOverride) : SETTINGS.fontSize; + + if (!book.sdFontFamilyOverride.empty()) { + // Per-book SD font override: load that family at the effective size. + sdFontSystem.ensureLoaded(renderer, book.sdFontFamilyOverride.c_str(), effectiveSize); + } else if (book.fontFamilyOverride >= 0) { + // Per-book built-in font override: no SD font needed; unload if one was active. + sdFontSystem.ensureLoaded(renderer, "", effectiveSize); } else { - sdFontSystem.ensureLoaded(renderer, SETTINGS.sdFontFamilyName, SETTINGS.fontSize); + // No family override: use global SD font (if any) at the effective size. + sdFontSystem.ensureLoaded(renderer, SETTINGS.sdFontFamilyName, effectiveSize); } }