summaryrefslogtreecommitdiff
path: root/src/mbgl/layout
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-11-13 10:47:41 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-02 17:11:49 +0200
commita9c3b5a389a249a9ddb62250cdcb8f8edb2f7280 (patch)
tree822eb59b22229f0beed4d10e39089da036f29172 /src/mbgl/layout
parenta01ecc92a079cb488d5f24d374d82e5fc34fe14b (diff)
downloadqtlocation-mapboxgl-a9c3b5a389a249a9ddb62250cdcb8f8edb2f7280.tar.gz
[core] Add evaluated images to styled text sections
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index af0b1bd21b..54708d5549 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -146,27 +146,34 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
ft.formattedText = TaggedString();
for (const auto & section : formatted.sections) {
- std::string u8string = section.text;
- if (textTransform == TextTransformType::Uppercase) {
- u8string = platform::uppercase(u8string);
- } else if (textTransform == TextTransformType::Lowercase) {
- u8string = platform::lowercase(u8string);
- }
+ if (!section.image) {
+ std::string u8string = section.text;
+ if (textTransform == TextTransformType::Uppercase) {
+ u8string = platform::uppercase(u8string);
+ } else if (textTransform == TextTransformType::Lowercase) {
+ u8string = platform::lowercase(u8string);
+ }
- ft.formattedText->addSection(applyArabicShaping(util::convertUTF8ToUTF16(u8string)),
- section.fontScale ? *section.fontScale : 1.0,
- section.fontStack ? *section.fontStack : baseFontStack,
- section.textColor);
+ ft.formattedText->addTextSection(applyArabicShaping(util::convertUTF8ToUTF16(u8string)),
+ section.fontScale ? *section.fontScale : 1.0,
+ section.fontStack ? *section.fontStack : baseFontStack,
+ section.textColor);
+ } else {
+ layoutParameters.imageDependencies.emplace(section.image->id(), ImageType::Icon);
+ ft.formattedText->addImageSection(section.image->id());
+ }
}
-
const bool canVerticalizeText = layout->get<TextRotationAlignment>() == AlignmentType::Map
&& layout->get<SymbolPlacement>() != SymbolPlacementType::Point
&& ft.formattedText->allowsVerticalWritingMode();
// Loop through all characters of this text and collect unique codepoints.
for (std::size_t j = 0; j < ft.formattedText->length(); j++) {
- const auto& sectionFontStack = formatted.sections[ft.formattedText->getSectionIndex(j)].fontStack;
+ const auto& section = formatted.sections[ft.formattedText->getSectionIndex(j)];
+ if (section.image) continue;
+
+ const auto& sectionFontStack = section.fontStack;
GlyphIDs& dependencies =
layoutParameters.glyphDependencies[sectionFontStack ? *sectionFontStack : baseFontStack];
char16_t codePoint = ft.formattedText->getCharCodeAt(j);