summaryrefslogtreecommitdiff
path: root/platform/default/src/mbgl/storage/offline_download.cpp
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-12-18 17:26:31 -0800
committerChris Loer <chris.loer@mapbox.com>2018-12-21 15:13:48 -0800
commitb7e2b11a75fd1b12d0ff948b9602fcd3db3779cf (patch)
tree1571564df596c7720d8bcea8ebdd604032164f09 /platform/default/src/mbgl/storage/offline_download.cpp
parent7d8b4754077aeae576965cd7871d5d00578cdce4 (diff)
downloadqtlocation-mapboxgl-b7e2b11a75fd1b12d0ff948b9602fcd3db3779cf.tar.gz
[core] Support for excluding ideographic glyphs from offline downloads.
Diffstat (limited to 'platform/default/src/mbgl/storage/offline_download.cpp')
-rw-r--r--platform/default/src/mbgl/storage/offline_download.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/platform/default/src/mbgl/storage/offline_download.cpp b/platform/default/src/mbgl/storage/offline_download.cpp
index c97797a5a2..d60ae786dd 100644
--- a/platform/default/src/mbgl/storage/offline_download.cpp
+++ b/platform/default/src/mbgl/storage/offline_download.cpp
@@ -13,6 +13,7 @@
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/tileset.hpp>
#include <mbgl/text/glyph.hpp>
+#include <mbgl/util/i18n.hpp>
#include <mbgl/util/mapbox.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/tile_cover.hpp>
@@ -205,7 +206,10 @@ OfflineRegionStatus OfflineDownload::getStatus() const {
}
if (!parser.glyphURL.empty()) {
- result->requiredResourceCount += parser.fontStacks().size() * GLYPH_RANGES_PER_FONT_STACK;
+ result->requiredResourceCount += parser.fontStacks().size() *
+ (definition.match([](auto& reg){ return reg.includeIdeographs; }) ?
+ GLYPH_RANGES_PER_FONT_STACK :
+ NON_IDEOGRAPH_GLYPH_RANGES_PER_FONT_STACK);
}
if (!parser.spriteURL.empty()) {
@@ -298,9 +302,14 @@ void OfflineDownload::activateDownload() {
}
if (!parser.glyphURL.empty()) {
+ const bool includeIdeographs = definition.match([](auto& reg){ return reg.includeIdeographs; });
for (const auto& fontStack : parser.fontStacks()) {
for (char16_t i = 0; i < GLYPH_RANGES_PER_FONT_STACK; i++) {
- queueResource(Resource::glyphs(parser.glyphURL, fontStack, getGlyphRange(i * GLYPHS_PER_GLYPH_RANGE)));
+ // Assumes that if a glyph range starts with fixed width/ideographic characters, the entire
+ // range will be fixed width.
+ if (includeIdeographs || !util::i18n::allowsFixedWidthGlyphGeneration(i * GLYPHS_PER_GLYPH_RANGE)) {
+ queueResource(Resource::glyphs(parser.glyphURL, fontStack, getGlyphRange(i * GLYPHS_PER_GLYPH_RANGE)));
+ }
}
}
}