From a4f73a37affda7c4e27ad205c64cbd110a6541f2 Mon Sep 17 00:00:00 2001 From: attila Date: Mon, 3 Feb 2025 17:03:40 +0100 Subject: [PATCH] ShapedText: Fix input text range calculation logic during wrapping --- .../juce_graphics/detail/juce_SimpleShapedText.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/detail/juce_SimpleShapedText.cpp b/modules/juce_graphics/detail/juce_SimpleShapedText.cpp index d7f7614a58..4ae2b4196a 100644 --- a/modules/juce_graphics/detail/juce_SimpleShapedText.cpp +++ b/modules/juce_graphics/detail/juce_SimpleShapedText.cpp @@ -635,6 +635,11 @@ public: auto getTextRange() const { return textRange; } const auto& getFont() const { return subOwnedGlyphsSpan.font; } + void setTextRange (Range newRange) + { + textRange = newRange; + } + private: GlyphsStorage subOwnedGlyphsSpan; Span glyphs; @@ -931,9 +936,14 @@ struct Shaper while (end < endIt && end->cluster < nextSoftBreakBefore) ++end; + const auto startingCluster = std::max (startFrom, start->cluster); + + if (! result.empty()) + result.back().setTextRange (result.back().getTextRange().withEnd (startingCluster)); + result.push_back ({ glyphsIt->value, Span { start, (size_t) std::distance (start, end) }, - { startFrom, nextSoftBreakBefore }, + { startingCluster, nextSoftBreakBefore }, visualOrder[(size_t) start->cluster] }); if (end != endIt && end->cluster >= nextSoftBreakBefore)