diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-19 15:30:19 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-19 17:16:54 +0200 |
commit | 8ac87ec5cb2374d212a31942ca19ce395704eb69 (patch) | |
tree | 9ec08c29e1a4f5e779f9c69ba7d96411f1c64f1d /src/mbgl/util/font_stack.cpp | |
parent | 9592e61288d071a7927c7cf99e7e5f3f97711642 (diff) | |
download | qtlocation-mapboxgl-8ac87ec5cb2374d212a31942ca19ce395704eb69.tar.gz |
Refactor util::fontStacks()
So that it does not downcast `Layer::Impl` instances.
Also, an unneeded `std::vector` construction was removed from
`Parser::fontStacks()`.
Diffstat (limited to 'src/mbgl/util/font_stack.cpp')
-rw-r--r-- | src/mbgl/util/font_stack.cpp | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/src/mbgl/util/font_stack.cpp b/src/mbgl/util/font_stack.cpp index 4093a21793..362fdf1845 100644 --- a/src/mbgl/util/font_stack.cpp +++ b/src/mbgl/util/font_stack.cpp @@ -1,5 +1,4 @@ #include <mbgl/util/font_stack.hpp> -#include <mbgl/util/logging.hpp> #include <mbgl/style/layers/symbol_layer_impl.hpp> #include <mbgl/util/hash.hpp> @@ -23,35 +22,8 @@ FontStackHash FontStackHasher::operator()(const FontStack& fontStack) const { std::set<FontStack> fontStacks(const std::vector<Immutable<style::Layer::Impl>>& layers) { std::set<FontStack> result; - for (const auto& layer : layers) { - if (layer->type != LayerType::Symbol) { - continue; - } - - const SymbolLayer::Impl& impl = dynamic_cast<const SymbolLayer::Impl&>(*layer); - if (impl.layout.get<TextField>().isUndefined()) { - continue; - } - - impl.layout.get<TextFont>().match( - [&] (Undefined) { - result.insert({"Open Sans Regular", "Arial Unicode MS Regular"}); - }, - [&] (const FontStack& constant) { - result.insert(constant); - }, - [&] (const auto& function) { - for (const auto& value : function.possibleOutputs()) { - if (value) { - result.insert(*value); - } else { - Log::Warning(Event::ParseStyle, "Layer '%s' has an invalid value for text-font and will not render text. Output values must be contained as literals within the expression.", impl.id.c_str()); - break; - } - } - } - ); + layer->populateFontStack(result); } return result; |