1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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
5e4016b4fb, which accidentally changed it.
This commit is contained in:
attila 2024-10-07 15:24:11 +02:00
parent b545b79cb3
commit bd14d47211

View file

@ -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<float>::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);