mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
TextLayout: Preserve leading whitespaces
This fixes the CodeEditorComponent regression present since
03e79f8f12.
This commit is contained in:
parent
ef8417023e
commit
3c4aa8d0ce
1 changed files with 14 additions and 4 deletions
|
|
@ -456,13 +456,23 @@ void TextLayout::createStandardLayout (const AttributedString& text)
|
|||
run->font = font;
|
||||
run->colour = colour;
|
||||
|
||||
for (decltype (glyphs.size()) i = 0, iMax = glyphs.size(); i < iMax; ++i)
|
||||
const auto beyondLastNonWhitespace = [&]
|
||||
{
|
||||
if (glyphs[i].whitespace)
|
||||
continue;
|
||||
auto i = glyphs.size();
|
||||
|
||||
for (auto it = std::reverse_iterator { glyphs.end() },
|
||||
end = std::reverse_iterator { glyphs.begin() };
|
||||
it != end && it->whitespace;
|
||||
++it)
|
||||
{
|
||||
--i;
|
||||
}
|
||||
|
||||
return i;
|
||||
}();
|
||||
|
||||
for (size_t i = 0; i < beyondLastNonWhitespace; ++i)
|
||||
run->glyphs.add ({ (int) glyphs[i].glyphId, positions[i] - line->lineOrigin, glyphs[i].advance.x });
|
||||
}
|
||||
|
||||
line->runs.add (std::move (run));
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue