From 8ca419fb2ebbba427f2f27ba3d794fb3d6cc5797 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 17 Jul 2018 15:33:50 -0700 Subject: [core] Evict unused font stacks from GlyphManager --- src/mbgl/util/font_stack.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/mbgl/util') diff --git a/src/mbgl/util/font_stack.cpp b/src/mbgl/util/font_stack.cpp index fb3b1b60a2..177d5e6f31 100644 --- a/src/mbgl/util/font_stack.cpp +++ b/src/mbgl/util/font_stack.cpp @@ -1,10 +1,14 @@ #include +#include +#include #include #include namespace mbgl { +using namespace style; + std::string fontStackToString(const FontStack& fontStack) { return boost::algorithm::join(fontStack, ","); } @@ -13,4 +17,40 @@ std::size_t FontStackHash::operator()(const FontStack& fontStack) const { return boost::hash_range(fontStack.begin(), fontStack.end()); } +std::set fontStacks(const std::vector>& layers) { + std::set result; + + for (const auto& layer : layers) { + if (layer->type != LayerType::Symbol) { + continue; + } + + const SymbolLayer::Impl& impl = dynamic_cast(*layer); + if (impl.layout.get().isUndefined()) { + continue; + } + + impl.layout.get().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; + } + } + } + ); + } + + return result; +} + } // namespace mbgl -- cgit v1.2.1