Add font foverrides to reader menu

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
jpirnay
2026-04-24 11:38:55 +02:00
co-authored by Copilot
parent e87cdf22ce
commit 7533ed1a9c
9 changed files with 265 additions and 87 deletions
+14 -2
View File
@@ -24,6 +24,8 @@ void RecentBooksStore::addBook(const std::string& path, const std::string& title
const std::string& series, const std::string& coverBmpPath) {
int8_t embeddedStyleOverride = -1;
int8_t imageRenderingOverride = -1;
int8_t fontFamilyOverride = -1;
int8_t fontSizeOverride = -1;
// Remove existing entry if present
auto it =
@@ -31,12 +33,14 @@ void RecentBooksStore::addBook(const std::string& path, const std::string& title
if (it != recentBooks.end()) {
embeddedStyleOverride = it->embeddedStyleOverride;
imageRenderingOverride = it->imageRenderingOverride;
fontFamilyOverride = it->fontFamilyOverride;
fontSizeOverride = it->fontSizeOverride;
recentBooks.erase(it);
}
// Add to front
recentBooks.insert(recentBooks.begin(),
{path, title, author, series, coverBmpPath, embeddedStyleOverride, imageRenderingOverride});
recentBooks.insert(recentBooks.begin(), {path, title, author, series, coverBmpPath, embeddedStyleOverride,
imageRenderingOverride, fontFamilyOverride, fontSizeOverride});
// Trim to max size
if (recentBooks.size() > MAX_RECENT_BOOKS) {
@@ -80,6 +84,12 @@ RecentBook RecentBooksStore::getBookByPath(const std::string& path) const {
bool RecentBooksStore::setReaderOverrides(const std::string& path, const int8_t embeddedStyleOverride,
const int8_t imageRenderingOverride) {
return setReaderOverrides(path, embeddedStyleOverride, imageRenderingOverride, -1, -1);
}
bool RecentBooksStore::setReaderOverrides(const std::string& path, const int8_t embeddedStyleOverride,
const int8_t imageRenderingOverride, const int8_t fontFamilyOverride,
const int8_t fontSizeOverride) {
auto it =
std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; });
if (it == recentBooks.end()) {
@@ -88,6 +98,8 @@ bool RecentBooksStore::setReaderOverrides(const std::string& path, const int8_t
it->embeddedStyleOverride = embeddedStyleOverride;
it->imageRenderingOverride = imageRenderingOverride;
it->fontFamilyOverride = fontFamilyOverride;
it->fontSizeOverride = fontSizeOverride;
return saveToFile();
}