From 81a784985eeba8aa58d4f4f53abc9914adda5dd0 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sat, 25 Apr 2026 11:19:39 +0200 Subject: [PATCH] yaclf --- lib/Epub/Epub/ParsedText.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Epub/Epub/ParsedText.cpp b/lib/Epub/Epub/ParsedText.cpp index e24094f7..3ad9337d 100644 --- a/lib/Epub/Epub/ParsedText.cpp +++ b/lib/Epub/Epub/ParsedText.cpp @@ -293,10 +293,11 @@ std::vector ParsedText::computeLineBreaks(const GfxRenderer& renderer, c // Calculate first line indent (only for left/justified text). // Explicit CSS text-indent always applies — author intent overrides the extraParagraphSpacing // toggle. Only the implicit EmSpace fallback in applyParagraphIndent() is gated on it. - const int firstLineIndent = blockStyle.textIndentDefined && (blockStyle.alignment == CssTextAlign::Justify || - blockStyle.alignment == CssTextAlign::Left) - ? std::min(std::max(static_cast(blockStyle.textIndent), -(pageWidth - 1)), pageWidth - 1) - : 0; + const int firstLineIndent = + blockStyle.textIndentDefined && + (blockStyle.alignment == CssTextAlign::Justify || blockStyle.alignment == CssTextAlign::Left) + ? std::min(std::max(static_cast(blockStyle.textIndent), -(pageWidth - 1)), pageWidth - 1) + : 0; // Ensure any word that would overflow even as the first entry on a line is split using fallback hyphenation. for (size_t i = 0; i < wordWidths.size(); ++i) { @@ -494,10 +495,11 @@ std::vector ParsedText::computeHyphenatedLineBreaks(const GfxRenderer& r // Calculate first line indent (only for left/justified text). // Explicit CSS text-indent always applies — author intent overrides the extraParagraphSpacing // toggle. Only the implicit EmSpace fallback in applyParagraphIndent() is gated on it. - const int firstLineIndent = blockStyle.textIndentDefined && (blockStyle.alignment == CssTextAlign::Justify || - blockStyle.alignment == CssTextAlign::Left) - ? std::min(std::max(static_cast(blockStyle.textIndent), -(pageWidth - 1)), pageWidth - 1) - : 0; + const int firstLineIndent = + blockStyle.textIndentDefined && + (blockStyle.alignment == CssTextAlign::Justify || blockStyle.alignment == CssTextAlign::Left) + ? std::min(std::max(static_cast(blockStyle.textIndent), -(pageWidth - 1)), pageWidth - 1) + : 0; // Pre-compute inter-word gaps to avoid repeated codepoint scanning and renderer // calls in the inner loop. When hyphenateWordAtIndex inserts a new word, we insert