From 1f10e91c238c970ee4fca721b57b445aa502d3f0 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Tue, 28 Apr 2026 18:40:37 +0200 Subject: [PATCH] Preserve continuation boundaries when building SD prewarm text --- lib/Epub/Epub/ParsedText.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Epub/Epub/ParsedText.cpp b/lib/Epub/Epub/ParsedText.cpp index ba257c9e..c13a8e99 100644 --- a/lib/Epub/Epub/ParsedText.cpp +++ b/lib/Epub/Epub/ParsedText.cpp @@ -156,13 +156,15 @@ void ParsedText::layoutAndExtractLines( // (advanceX only, no bitmaps) for all unique codepoints in this paragraph so // that calculateWordWidths() can measure text without on-demand SD I/O. if (renderer.isSdCardFont(fontId)) { - size_t totalSize = 1; // reserve room for a possible hyphen fallback - if (!words.empty()) totalSize += words.size() - 1; // inter-word spaces - for (const auto& w : words) totalSize += w.size(); + size_t totalSize = 1; // reserve room for a possible hyphen fallback + for (size_t i = 0; i < words.size(); i++) { + if (i > 0 && !wordContinues[i]) totalSize += 1; + totalSize += words[i].size(); + } std::string allText; allText.reserve(totalSize); for (size_t i = 0; i < words.size(); i++) { - if (i > 0) allText += ' '; + if (i > 0 && !wordContinues[i]) allText += ' '; allText += words[i]; } allText += '-';