diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-01-05 12:40:54 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-01-10 15:31:12 -0800 |
commit | 76ed5079a547e9f98616a9401c8814d224cec9d8 (patch) | |
tree | 4bad1bcefd0744a0262d6973b825a977fa2cfe45 /src/mbgl/layout | |
parent | 158bd5e08cae5974a9c587677d7d8e63a36a5ff0 (diff) | |
download | qtlocation-mapboxgl-76ed5079a547e9f98616a9401c8814d224cec9d8.tar.gz |
[core, ios, macos, android] Add data-driven-styling support for `text-font`
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index fc1ede56ff..a41a98fcaf 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -32,7 +32,7 @@ using namespace style; template <class Property> static bool has(const style::SymbolLayoutProperties::PossiblyEvaluated& layout) { return layout.get<Property>().match( - [&] (const std::string& s) { return !s.empty(); }, + [&] (const typename Property::Type& t) { return !t.empty(); }, [&] (const auto&) { return true; } ); } @@ -82,7 +82,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, layout.get<IconPitchAlignment>() = layout.get<IconRotationAlignment>(); } - const bool hasText = has<TextField>(layout) && !layout.get<TextFont>().empty(); + const bool hasText = has<TextField>(layout) && has<TextFont>(layout); const bool hasIcon = has<IconImage>(layout); if (!hasText && !hasIcon) { @@ -143,12 +143,15 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, && layout.get<SymbolPlacement>() == SymbolPlacementType::Line && util::i18n::allowsVerticalWritingMode(*ft.text); + FontStack fontStack = layout.evaluate<TextFont>(zoom, ft); + GlyphIDs& dependencies = glyphDependencies[fontStack]; + // Loop through all characters of this text and collect unique codepoints. for (char16_t chr : *ft.text) { - glyphDependencies[layout.get<TextFont>()].insert(chr); + dependencies.insert(chr); if (canVerticalizeText) { if (char16_t verticalChr = util::i18n::verticalizePunctuation(chr)) { - glyphDependencies[layout.get<TextFont>()].insert(verticalChr); + dependencies.insert(verticalChr); } } } @@ -183,18 +186,20 @@ void SymbolLayout::prepare(const GlyphMap& glyphMap, const GlyphPositions& glyph const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map && layout.get<SymbolPlacement>() == SymbolPlacementType::Line; - auto glyphMapIt = glyphMap.find(layout.get<TextFont>()); - const Glyphs& glyphs = glyphMapIt != glyphMap.end() - ? glyphMapIt->second : Glyphs(); - - auto glyphPositionsIt = glyphPositions.find(layout.get<TextFont>()); - const GlyphPositionMap& glyphPositionMap = glyphPositionsIt != glyphPositions.end() - ? glyphPositionsIt->second : GlyphPositionMap(); - for (auto it = features.begin(); it != features.end(); ++it) { auto& feature = *it; if (feature.geometry.empty()) continue; + FontStack fontStack = layout.evaluate<TextFont>(zoom, feature); + + auto glyphMapIt = glyphMap.find(fontStack); + const Glyphs& glyphs = glyphMapIt != glyphMap.end() + ? glyphMapIt->second : Glyphs(); + + auto glyphPositionsIt = glyphPositions.find(fontStack); + const GlyphPositionMap& glyphPositionMap = glyphPositionsIt != glyphPositions.end() + ? glyphPositionsIt->second : GlyphPositionMap(); + std::pair<Shaping, Shaping> shapedTextOrientations; optional<PositionedIcon> shapedIcon; |