From bd14d47211e9cf6690c7f2cbab7cd92815984ab4 Mon Sep 17 00:00:00 2001 From: attila Date: Mon, 7 Oct 2024 15:24:11 +0200 Subject: [PATCH] SimpleShapedText: Restore and tidy up earlier line breaking logic This commit isn't fixing any known bugs, but restores the soft break iteration logic to its state prior to 5e4016b4fbecdc5b21fabf6c8a559677321a6acf, which accidentally changed it. --- modules/juce_graphics/fonts/juce_SimpleShapedText.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp b/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp index e7278c9f17..705fc54210 100644 --- a/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp +++ b/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp @@ -1035,7 +1035,7 @@ void SimpleShapedText::shape (const String& data, ConsumableGlyphs glyphsToConsume { data, range, shapingParams }; const auto appendingToFirstLine = [&] { return lineNumbers.isEmpty(); }; - const auto appendingToLastLine = [&] { return (int64) lineNumbers.size() == options.getMaxNumLines() - 1; }; + const auto appendingToBeforeLastLine = [&] { return (int64) lineNumbers.size() < options.getMaxNumLines() - 1; }; while (! glyphsToConsume.isEmpty()) { @@ -1060,7 +1060,7 @@ void SimpleShapedText::shape (const String& data, static constexpr auto floatMax = std::numeric_limits::max(); for (auto breakBefore = softBreakIterator.next(); - breakBefore.has_value() && (appendingToFirstLine() || ! appendingToLastLine()); + breakBefore.has_value() && (appendingToFirstLine() || appendingToBeforeLastLine()); breakBefore = softBreakIterator.next()) { if (auto safeAdvance = glyphsToConsume.getAdvanceXUpToBreakPointIfSafe (*breakBefore, @@ -1218,9 +1218,11 @@ void SimpleShapedText::shape (const String& data, while (! glyphsToAdd.glyphs.empty()) { + const auto appendingToLastLine = ! appendingToBeforeLastLine(); + glyphsToAdd = addGlyphsToLine (glyphsToAdd, - (appendingToLastLine() || ! options.getAllowBreakingInsideWord()) ? CanAddGlyphsBeyondLineLimits::yes - : CanAddGlyphsBeyondLineLimits::no); + (appendingToLastLine || ! options.getAllowBreakingInsideWord()) ? CanAddGlyphsBeyondLineLimits::yes + : CanAddGlyphsBeyondLineLimits::no); if (! glyphsToAdd.glyphs.empty()) commitLine (bidiParagraph);