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

TextLayout: Ensure that line origin is set correctly when line starts with whitespace or newline glyphs

This commit is contained in:
ed 2021-09-01 16:11:11 +01:00
parent c26ff2da6b
commit b760620e05

View file

@ -352,7 +352,11 @@ namespace TextLayoutHelpers
if (currentRun == nullptr) currentRun = std::make_unique<TextLayout::Run>();
if (currentLine == nullptr) currentLine = std::make_unique<TextLayout::Line>();
if (newGlyphs.size() > 0)
const auto numGlyphs = newGlyphs.size();
charPosition += numGlyphs;
if (numGlyphs > 0
&& (! (t.isWhitespace || t.isNewLine) || needToSetLineOrigin))
{
currentRun->glyphs.ensureStorageAllocated (currentRun->glyphs.size() + newGlyphs.size());
auto tokenOrigin = t.area.getPosition().translated (0, t.font.getAscent());
@ -372,8 +376,6 @@ namespace TextLayoutHelpers
glyphOffset.translated (x, 0),
xOffsets.getUnchecked (j + 1) - x));
}
charPosition += newGlyphs.size();
}
if (auto* nextToken = tokens[i + 1])