diff --git a/lib/EpdFont/SdCardFont.cpp b/lib/EpdFont/SdCardFont.cpp index 7da85eb8..74166706 100644 --- a/lib/EpdFont/SdCardFont.cpp +++ b/lib/EpdFont/SdCardFont.cpp @@ -8,6 +8,7 @@ #include #include #include +#include static_assert(sizeof(EpdGlyph) == 16, "EpdGlyph must be 16 bytes to match .cpfont file layout"); static_assert(sizeof(EpdUnicodeInterval) == 12, "EpdUnicodeInterval must be 12 bytes to match .cpfont file layout"); diff --git a/lib/EpdFont/SdCardFont.h b/lib/EpdFont/SdCardFont.h index 07fab5a3..9564622d 100644 --- a/lib/EpdFont/SdCardFont.h +++ b/lib/EpdFont/SdCardFont.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "EpdFont.h" #include "EpdFontData.h" diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index dfab4fa7..c678bc14 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -1785,14 +1785,44 @@ bool EpubReaderActivity::drawCurrentPageToBuffer(const std::string& filePath, Gf } }; + const int effectiveFontId = getEffectiveFontId(effectiveFontFamily, effectiveFontSize); + const auto getEffectiveLineCompression = [&](int fontId) { + const int notosansId = CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::NOTOSANS, effectiveFontSize); + const int opendyslexicId = + CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::OPENDYSLEXIC, effectiveFontSize); + + if (fontId == notosansId || fontId == opendyslexicId) { + switch (SETTINGS.lineSpacing) { + case CrossPointSettings::TIGHT: + return 0.90f; + case CrossPointSettings::NORMAL: + default: + return 0.95f; + case CrossPointSettings::WIDE: + return 1.0f; + } + } + + switch (SETTINGS.lineSpacing) { + case CrossPointSettings::TIGHT: + return 0.95f; + case CrossPointSettings::NORMAL: + default: + return 1.0f; + case CrossPointSettings::WIDE: + return 1.1f; + } + }; + + const float effectiveLineCompression = getEffectiveLineCompression(effectiveFontId); auto section = std::make_unique
(epub, spineIndex, renderer); - if (!section->loadSectionFile(getEffectiveFontId(effectiveFontFamily, effectiveFontSize), - getEffectiveReaderLineCompression(), SETTINGS.extraParagraphSpacing, - SETTINGS.paragraphAlignment, viewportWidth, viewportHeight, SETTINGS.hyphenationEnabled, - SETTINGS.embeddedStyle, SETTINGS.imageRendering)) { + if (!section->loadSectionFile(getEffectiveFontId(effectiveFontFamily, effectiveFontSize), effectiveLineCompression, + SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth, + viewportHeight, SETTINGS.hyphenationEnabled, SETTINGS.embeddedStyle, + SETTINGS.imageRendering)) { LOG_DBG("SLP", "EPUB: section cache not found for spine %d, rebuilding", spineIndex); if (!section->createSectionFile(getEffectiveFontId(effectiveFontFamily, effectiveFontSize), - getEffectiveReaderLineCompression(), SETTINGS.extraParagraphSpacing, + effectiveLineCompression, SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth, viewportHeight, SETTINGS.hyphenationEnabled, SETTINGS.embeddedStyle, SETTINGS.imageRendering)) { LOG_ERR("SLP", "EPUB: failed to rebuild section cache for spine %d", spineIndex);