Support for Mapbox fontstack API

This commit is contained in:
John Firebaugh
2014-08-22 15:31:57 -07:00
parent 3b43c4ddf2
commit 3d9a293258
9 changed files with 112 additions and 23 deletions

View File

@@ -4,6 +4,7 @@
#include <mbgl/util/string.hpp>
#include <mbgl/util/utf.hpp>
#include <mbgl/util/pbf.hpp>
#include <mbgl/util/url.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/token.hpp>
#include <mbgl/util/math.hpp>
@@ -141,14 +142,11 @@ GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, Gl
{
// Load the glyph set URL
std::string url = util::replaceTokens(glyphURL, [&](const std::string &name) -> std::string {
if (name == "fontstack") return fontStack;
if (name == "fontstack") return util::percentEncode(fontStack);
if (name == "range") return std::to_string(glyphRange.first) + "-" + std::to_string(glyphRange.second);
return "";
});
// TODO: Find more reliable URL normalization function
std::replace(url.begin(), url.end(), ' ', '+');
#if defined(DEBUG)
fprintf(stderr, "%s\n", url.c_str());
#endif