From 3319aa1720224cd197905294c63f0c7f3d8eae3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=E1=BA=A1m=20B=C3=ACnh=20An?= <111893501+brianhuster@users.noreply.github.com> Date: Mon, 20 Jul 2026 19:02:08 +0700 Subject: [PATCH] fix(epub): preserve word continuation when splitting CJK text on MAX_WORD_SIZE (#2652) --- lib/Epub/Epub/Section.cpp | 2 +- lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Epub/Epub/Section.cpp b/lib/Epub/Epub/Section.cpp index 56daeed0..10d2b4f3 100644 --- a/lib/Epub/Epub/Section.cpp +++ b/lib/Epub/Epub/Section.cpp @@ -17,7 +17,7 @@ namespace { // v30: Arabic shaping changed both drawing and measurement (getTextAdvanceX now // measures the shaped visual text); cached word positions from v29 no longer // match what drawText renders. -constexpr uint8_t SECTION_FILE_VERSION = 30; +constexpr uint8_t SECTION_FILE_VERSION = 31; // Written into the version field while a build is in progress; patched to // SECTION_FILE_VERSION only when the build is finalized. An abandoned / // crash-interrupted .bin therefore carries version 0, which loadSectionFile rejects diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index 2ec1d2c2..a686b366 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -1154,12 +1154,14 @@ void XMLCALL ChapterHtmlSlimParser::characterData(void* userData, const XML_Char } self->partWordBufferIndex = safeLen; self->flushPartWordBuffer(); + self->nextWordContinues = true; for (int j = 0; j < overflow; j++) { self->partWordBuffer[j] = saved[j]; } self->partWordBufferIndex = overflow; } else { self->flushPartWordBuffer(); + self->nextWordContinues = true; } }