Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Shape images in labels at bucket zoom level
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshalamov committed Nov 19, 2019
1 parent a00ec97 commit 7c5e0a4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/mbgl/layout/symbol_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -381,6 +382,7 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap,
/* glyphs */ glyphPositions,
/* images */ imagePositions,
layoutTextSize,
layoutTextSizeAtBucketZoomLevel,
allowVerticalPlacement);

return result;
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/text/shaping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,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;
Expand Down Expand Up @@ -562,7 +563,7 @@ const Shaping getShaping(const TaggedString& formattedString,
glyphMap,
glyphPositions,
imagePositions,
layoutTextSize,
layoutTextSizeAtBucketZoomLevel,
allowVerticalPlacement);

return shaping;
Expand Down
1 change: 1 addition & 0 deletions src/mbgl/text/shaping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const Shaping getShaping(const TaggedString& string,
const GlyphPositions& glyphPositions,
const ImagePositions& imagePositions,
float layoutTextSize,
float layoutTextSizeAtBucketZoomLevel,
bool allowVerticalPlacement);

} // namespace mbgl
5 changes: 4 additions & 1 deletion test/text/shaping.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)}} }
};
Expand All @@ -44,7 +46,8 @@ TEST(Shaping, ZWSP) {
glyphs,
glyphPositions,
imagePositions,
16.0,
layoutTextSize,
layoutTextSizeAtBucketZoomLevel,
/*allowVerticalPlacement*/ false);
};

Expand Down

0 comments on commit 7c5e0a4

Please sign in to comment.