From 9a6f81a1efdf1218a7cb11839356dc7a081e69a6 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Wed, 7 Dec 2016 15:38:46 -0800 Subject: Render newlines in labels even if there's nothing else on the line. --- src/mbgl/text/glyph_set.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mbgl/text/glyph_set.cpp b/src/mbgl/text/glyph_set.cpp index 3b2687fbac..537d9c0579 100644 --- a/src/mbgl/text/glyph_set.cpp +++ b/src/mbgl/text/glyph_set.cpp @@ -189,7 +189,8 @@ void GlyphSet::shapeLines(Shaping& shaping, // Collapse whitespace so it doesn't throw off justification boost::algorithm::trim_if(line, boost::algorithm::is_any_of(u" \t\n\v\f\r")); - if (line.empty()) { + if (line.empty()) { + y += lineHeight; // Still need a line feed after empty line continue; } @@ -205,18 +206,17 @@ void GlyphSet::shapeLines(Shaping& shaping, x += glyph.metrics.advance + spacing; } - if (static_cast(shaping.positionedGlyphs.size()) == lineStartIndex) { - continue; + // Only justify if we placed at least one glyph + if (static_cast(shaping.positionedGlyphs.size()) != lineStartIndex) { + float lineLength = x - spacing; // Don't count trailing spacing + maxLineLength = util::max(lineLength, maxLineLength); + + justifyLine(shaping.positionedGlyphs, sdfs, lineStartIndex, + static_cast(shaping.positionedGlyphs.size()) - 1, justify); } - float lineLength = x - spacing; // Don't count trailing spacing - maxLineLength = util::max(lineLength, maxLineLength); - - justifyLine(shaping.positionedGlyphs, sdfs, lineStartIndex, - static_cast(shaping.positionedGlyphs.size()) - 1, justify); - x = 0; - y += lineHeight; // Move to next line + y += lineHeight; } align(shaping, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, -- cgit v1.2.1