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>2016-12-21 13:38:39 -0800
commit9a6f81a1efdf1218a7cb11839356dc7a081e69a6 (patch)
tree94cffc82090b1d46d1dcdd7b02d734f90a5a4a67
parentbbeda5d497ade17e3667a341b620504b2c259d23 (diff)
downloadqtlocation-mapboxgl-9a6f81a1efdf1218a7cb11839356dc7a081e69a6.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,