From 424104f8ff5f6c00fa7838079a615f346c1f8498 Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Sun, 21 Dec 2025 19:01:00 +1100 Subject: [PATCH] Fix incorrect justification of last line in paragraph (#90) ## Summary * Fix incorrect justification of last line in paragraph * `words` is changing size due to the slice, so `isLastLine` would rarely be right, either removing justification mid-paragraph, or including it in the last line. ## Additional Context * Introduced in #73 --- lib/Epub/Epub/ParsedText.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Epub/Epub/ParsedText.cpp b/lib/Epub/Epub/ParsedText.cpp index eff3fd6..d73f80a 100644 --- a/lib/Epub/Epub/ParsedText.cpp +++ b/lib/Epub/Epub/ParsedText.cpp @@ -144,7 +144,7 @@ void ParsedText::extractLine(const size_t breakIndex, const int pageWidth, const const int spareSpace = pageWidth - lineWordWidthSum; int spacing = spaceWidth; - const bool isLastLine = lineBreak == words.size(); + const bool isLastLine = breakIndex == lineBreakIndices.size() - 1; if (style == TextBlock::JUSTIFIED && !isLastLine && lineWordCount >= 2) { spacing = spareSpace / (lineWordCount - 1);