diff --git a/modules/juce_graphics/fonts/juce_TextLayout.cpp b/modules/juce_graphics/fonts/juce_TextLayout.cpp index 70547a5645..a0d350ccd7 100644 --- a/modules/juce_graphics/fonts/juce_TextLayout.cpp +++ b/modules/juce_graphics/fonts/juce_TextLayout.cpp @@ -354,26 +354,23 @@ namespace TextLayoutHelpers if (newGlyphs.size() > 0) { - if (! t.isWhitespace && ! t.isNewLine) + currentRun->glyphs.ensureStorageAllocated (currentRun->glyphs.size() + newGlyphs.size()); + auto tokenOrigin = t.area.getPosition().translated (0, t.font.getAscent()); + + if (needToSetLineOrigin) + { + needToSetLineOrigin = false; + currentLine->lineOrigin = tokenOrigin; + } + + auto glyphOffset = tokenOrigin - currentLine->lineOrigin; + + for (int j = 0; j < newGlyphs.size(); ++j) { - currentRun->glyphs.ensureStorageAllocated (currentRun->glyphs.size() + newGlyphs.size()); - auto tokenOrigin = t.area.getPosition().translated (0, t.font.getAscent()); - - if (needToSetLineOrigin) - { - needToSetLineOrigin = false; - currentLine->lineOrigin = tokenOrigin; - } - - 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)); - } + 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(); @@ -497,7 +494,7 @@ namespace TextLayoutHelpers for (i = 0; i < tokens.size(); ++i) { - auto& t = *tokens.getUnchecked(i); + auto& t = *tokens.getUnchecked (i); t.area.setPosition (x, y); t.line = totalLines; x += t.area.getWidth();