mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
TextLayout: Skip whitespace tokens in TokenList::createLayout() to fix misalignment when using horizontally centred justification
This commit is contained in:
parent
09c06fb946
commit
e1366361ed
1 changed files with 17 additions and 18 deletions
|
|
@ -354,31 +354,30 @@ namespace TextLayoutHelpers
|
|||
|
||||
if (newGlyphs.size() > 0)
|
||||
{
|
||||
currentRun->glyphs.ensureStorageAllocated (currentRun->glyphs.size() + newGlyphs.size());
|
||||
auto tokenOrigin = t.area.getPosition().translated (0, t.font.getAscent());
|
||||
|
||||
if (needToSetLineOrigin)
|
||||
if (! t.isWhitespace && ! t.isNewLine)
|
||||
{
|
||||
needToSetLineOrigin = false;
|
||||
currentLine->lineOrigin = tokenOrigin;
|
||||
}
|
||||
currentRun->glyphs.ensureStorageAllocated (currentRun->glyphs.size() + newGlyphs.size());
|
||||
auto tokenOrigin = t.area.getPosition().translated (0, t.font.getAscent());
|
||||
|
||||
auto glyphOffset = tokenOrigin - currentLine->lineOrigin;
|
||||
if (needToSetLineOrigin)
|
||||
{
|
||||
needToSetLineOrigin = false;
|
||||
currentLine->lineOrigin = tokenOrigin;
|
||||
}
|
||||
|
||||
for (int j = 0; j < newGlyphs.size(); ++j)
|
||||
{
|
||||
auto x = xOffsets.getUnchecked (j);
|
||||
currentRun->glyphs.add (TextLayout::Glyph (newGlyphs.getUnchecked(j),
|
||||
glyphOffset.translated (x, 0),
|
||||
xOffsets.getUnchecked (j + 1) - x));
|
||||
auto glyphOffset = tokenOrigin - currentLine->lineOrigin;
|
||||
|
||||
for (int j = 0; j < newGlyphs.size(); ++j)
|
||||
{
|
||||
auto x = xOffsets.getUnchecked (j);
|
||||
currentRun->glyphs.add (TextLayout::Glyph (newGlyphs.getUnchecked (j),
|
||||
glyphOffset.translated (x, 0),
|
||||
xOffsets.getUnchecked (j + 1) - x));
|
||||
}
|
||||
}
|
||||
|
||||
charPosition += newGlyphs.size();
|
||||
}
|
||||
else if (t.isWhitespace || t.isNewLine)
|
||||
{
|
||||
++charPosition;
|
||||
}
|
||||
|
||||
if (auto* nextToken = tokens[i + 1])
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue