summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2016-12-07 15:38:46 -0800
committerChris Loer <chris.loer@gmail.com>2017-01-05 10:22:53 -0800
commit35ccb01dbdf95595591c7b2bf3c4a0882a1b9be7 (patch)
tree687a82a6c82b7962300f5a230ec1178abe1bdc90
parentf68449aeb8a4d874c15958edfcb02bc1ad7015a2 (diff)
downloadqtlocation-mapboxgl-35ccb01dbdf95595591c7b2bf3c4a0882a1b9be7.tar.gz
Render newlines in labels even if there's nothing else on the line.
-rw-r--r--src/mbgl/text/glyph_set.cpp20
1 files 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<uint32_t>(shaping.positionedGlyphs.size()) == lineStartIndex) {
- continue;
+ // Only justify if we placed at least one glyph
+ if (static_cast<uint32_t>(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<uint32_t>(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<uint32_t>(shaping.positionedGlyphs.size()) - 1, justify);
-
x = 0;
- y += lineHeight; // Move to next line
+ y += lineHeight;
}
align(shaping, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight,