summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-11-19 11:50:55 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-02 12:08:37 +0200
commit5695a3c68be49f1b1d89e0ed02905f8ecf2f30ed (patch)
treeff4be678405d55d76c9b1aa1d2c99206a5f8cc15
parent6e0c9eae5715b08d5152cd4bdc65224ce5f52b6e (diff)
downloadqtlocation-mapboxgl-5695a3c68be49f1b1d89e0ed02905f8ecf2f30ed.tar.gz
[core] Shape images in labels at bucket zoom level
-rw-r--r--src/mbgl/layout/symbol_layout.cpp2
-rw-r--r--src/mbgl/text/shaping.cpp3
-rw-r--r--src/mbgl/text/shaping.hpp1
-rw-r--r--test/text/shaping.test.cpp5
4 files changed, 9 insertions, 2 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 4c5836df21..ca61844417 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -355,6 +355,7 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap,
optional<PositionedIcon> shapedIcon;
std::array<float, 2> textOffset{{0.0f, 0.0f}};
const float layoutTextSize = layout->evaluate<TextSize>(zoom + 1, feature);
+ const float layoutTextSizeAtBucketZoomLevel = layout->evaluate<TextSize>(zoom, feature);
const float layoutIconSize = layout->evaluate<IconSize>(zoom + 1, feature);
// if feature has text, shape the text
@@ -381,6 +382,7 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap,
/* glyphs */ glyphPositions,
/* images */ imagePositions,
layoutTextSize,
+ layoutTextSizeAtBucketZoomLevel,
allowVerticalPlacement);
return result;
diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp
index b977112d1f..fb1aa04346 100644
--- a/src/mbgl/text/shaping.cpp
+++ b/src/mbgl/text/shaping.cpp
@@ -532,6 +532,7 @@ const Shaping getShaping(const TaggedString& formattedString,
const GlyphPositions& glyphPositions,
const ImagePositions& imagePositions,
float layoutTextSize,
+ float layoutTextSizeAtBucketZoomLevel,
bool allowVerticalPlacement) {
assert(layoutTextSize);
std::vector<TaggedString> reorderedLines;
@@ -561,7 +562,7 @@ const Shaping getShaping(const TaggedString& formattedString,
glyphMap,
glyphPositions,
imagePositions,
- layoutTextSize,
+ layoutTextSizeAtBucketZoomLevel,
allowVerticalPlacement);
return shaping;
diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp
index c170642e82..1f62f38521 100644
--- a/src/mbgl/text/shaping.hpp
+++ b/src/mbgl/text/shaping.hpp
@@ -73,6 +73,7 @@ const Shaping getShaping(const TaggedString& string,
const GlyphPositions& glyphPositions,
const ImagePositions& imagePositions,
float layoutTextSize,
+ float layoutTextSizeAtBucketZoomLevel,
bool allowVerticalPlacement);
} // namespace mbgl
diff --git a/test/text/shaping.test.cpp b/test/text/shaping.test.cpp
index 53f8505393..d86bf30eb9 100644
--- a/test/text/shaping.test.cpp
+++ b/test/text/shaping.test.cpp
@@ -25,6 +25,8 @@ TEST(Shaping, ZWSP) {
auto immutableGlyph = Immutable<Glyph>(makeMutable<Glyph>(std::move(glyph)));
const std::vector<std::string> fontStack{{"font-stack"}};
const SectionOptions sectionOptions(1.0f, fontStack);
+ const float layoutTextSize = 16.0f;
+ const float layoutTextSizeAtBucketZoomLevel = 16.0f;
GlyphMap glyphs = {
{ FontStackHasher()(fontStack), {{u'中', std::move(immutableGlyph)}} }
};
@@ -44,7 +46,8 @@ TEST(Shaping, ZWSP) {
glyphs,
glyphPositions,
imagePositions,
- 16.0,
+ layoutTextSize,
+ layoutTextSizeAtBucketZoomLevel,
/*allowVerticalPlacement*/ false);
};