From 43b7968c746b8585cfb9427ad556e61c15483a98 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 18 Jun 2019 14:55:11 +0800 Subject: [PATCH 01/12] [iOS, macOS] exclude CJK glyphs resources download by default. --- platform/darwin/src/MGLShapeOfflineRegion.mm | 2 +- platform/darwin/src/MGLTilePyramidOfflineRegion.mm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLShapeOfflineRegion.mm b/platform/darwin/src/MGLShapeOfflineRegion.mm index 25b6b8e1667..b4f4b5e92a3 100644 --- a/platform/darwin/src/MGLShapeOfflineRegion.mm +++ b/platform/darwin/src/MGLShapeOfflineRegion.mm @@ -72,7 +72,7 @@ - (instancetype)initWithStyleURL:(NSURL *)styleURL shape:(MGLShape *)shape fromZ _shape = shape; _minimumZoomLevel = minimumZoomLevel; _maximumZoomLevel = maximumZoomLevel; - _includesIdeographicGlyphs = YES; + _includesIdeographicGlyphs = NO; } return self; } diff --git a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm index a398d6baa4a..73fcaa91d8e 100644 --- a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm +++ b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm @@ -68,7 +68,7 @@ - (instancetype)initWithStyleURL:(NSURL *)styleURL bounds:(MGLCoordinateBounds)b _bounds = bounds; _minimumZoomLevel = minimumZoomLevel; _maximumZoomLevel = maximumZoomLevel; - _includesIdeographicGlyphs = YES; + _includesIdeographicGlyphs = NO; } return self; } From 975c341c840a4faab13b598aa2a02d461f5dac69 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 18 Jun 2019 15:02:51 +0800 Subject: [PATCH 02/12] [iOS, macOS] update iosapp --- platform/ios/app/MBXOfflinePacksTableViewController.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/ios/app/MBXOfflinePacksTableViewController.m b/platform/ios/app/MBXOfflinePacksTableViewController.m index e237df4019c..4459711b583 100644 --- a/platform/ios/app/MBXOfflinePacksTableViewController.m +++ b/platform/ios/app/MBXOfflinePacksTableViewController.m @@ -103,8 +103,10 @@ - (IBAction)addCurrentRegion:(id)sender { } MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:mapView.styleURL bounds:mapView.visibleCoordinateBounds fromZoomLevel:mapView.zoomLevel toZoomLevel:mapView.maximumZoomLevel]; - BOOL hasIdeographicFontFamilyName = !![[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"]; - region.includesIdeographicGlyphs = hasIdeographicFontFamilyName; + id ideographicFontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"]; + if([ideographicFontFamilyName isKindOfClass:[NSNumber class]] && ![ideographicFontFamilyName boolValue]){ + region.includesIdeographicGlyphs = YES; + } NSData *context = [NSKeyedArchiver archivedDataWithRootObject:@{ MBXOfflinePackContextNameKey: name, }]; From dbb524bdee201bc3d3535282a41ce5bb24e7d0d4 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 18 Jun 2019 15:09:08 +0800 Subject: [PATCH 03/12] [iOS, macOS] update macOS --- platform/macos/app/MapDocument.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 213aa33107e..1ab8b690b91 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -932,8 +932,8 @@ - (IBAction)addOfflinePack:(id)sender { self.minimumOfflinePackZoomLevelFormatter.maximum = @(ceil(self.mapView.maximumZoomLevel)); self.maximumOfflinePackZoomLevelFormatter.maximum = @(ceil(self.mapView.maximumZoomLevel)); - NSString *fontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"]; - self.includesIdeographicGlyphsBox.state = fontFamilyName ? NSOffState : NSOnState; + id ideographicFontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"]; + self.includesIdeographicGlyphsBox.state = ([ideographicFontFamilyName isKindOfClass:[NSNumber class]] && ![ideographicFontFamilyName boolValue]) ? NSOffState : NSOnState; [self.addOfflinePackWindow makeFirstResponder:self.offlinePackNameField]; __weak __typeof__(self) weakSelf = self; From ce1c98bfd665d29358f01125683adda6496f8049 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 18 Jun 2019 15:21:04 +0800 Subject: [PATCH 04/12] [iOS, macOS] update iOS change log --- platform/ios/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 2867879bc9c..2216f071ddd 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## Master + +* Exclude CJK resources from offline download by default. ([#14176](https://github.com/mapbox/mapbox-gl-native/pull/14176)) + ## 5.1.0 ### Styles and rendering From 943b315c531f3202e1d4a5cee440791afe5a83c1 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 18 Jun 2019 15:22:33 +0800 Subject: [PATCH 05/12] [iOS, macOS] update macOS change log --- platform/macos/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 3eb34c5ac10..27fba3ae506 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -4,6 +4,7 @@ * Added an `MGLMapView.prefetchesTiles` property to configure lower-resolution tile prefetching behavior. ([#14816](https://github.com/mapbox/mapbox-gl-native/pull/14816)) * Fixed queryRenderedFeatues bug caused by incorrect sort feature index calculation. ([#14884](https://github.com/mapbox/mapbox-gl-native/pull/14884)) +* Exclude CJK resources from offline download by default. ([#14176](https://github.com/mapbox/mapbox-gl-native/pull/14176)) ### Styles and rendering From 70c30909cf33a47bc4a3a780d038b33c1ffc0127 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 9 Jul 2019 16:02:42 +0800 Subject: [PATCH 06/12] [iOS, macOS] update comment & add test cases --- platform/darwin/src/MGLOfflineRegion.h | 2 +- platform/darwin/test/MGLOfflineRegionTests.m | 25 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/platform/darwin/src/MGLOfflineRegion.h b/platform/darwin/src/MGLOfflineRegion.h index 6a9bdbc3998..c668e3bf224 100644 --- a/platform/darwin/src/MGLOfflineRegion.h +++ b/platform/darwin/src/MGLOfflineRegion.h @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN See `MGLIdeographicFontFamilyName` setting. Also, for regions outside of China, Japan, and Korea, these glyphs will rarely appear for non-CJK users. - By default, this property is set to `YES`, so that the offline pack will + By default, this property is set to `NO`, so that the offline pack will include ideographic glyphs. */ @property (nonatomic) BOOL includesIdeographicGlyphs; diff --git a/platform/darwin/test/MGLOfflineRegionTests.m b/platform/darwin/test/MGLOfflineRegionTests.m index 4d5767a8d26..f17b3ceccf1 100644 --- a/platform/darwin/test/MGLOfflineRegionTests.m +++ b/platform/darwin/test/MGLOfflineRegionTests.m @@ -12,7 +12,7 @@ - (void)testStyleURLs { MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(kCLLocationCoordinate2DInvalid, kCLLocationCoordinate2DInvalid); MGLTilePyramidOfflineRegion *region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:nil bounds:bounds fromZoomLevel:0 toZoomLevel:DBL_MAX]; XCTAssertEqualObjects(region.styleURL, [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion], @"Streets isn’t the default style."); - + NSURL *localURL = [NSURL URLWithString:@"beautiful.style"]; XCTAssertThrowsSpecificNamed([[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:localURL bounds:bounds fromZoomLevel:0 toZoomLevel:DBL_MAX], NSException, MGLInvalidStyleURLException, @"No exception raised when initializing region with a local file URL as the style URL."); } @@ -22,7 +22,7 @@ - (void)testTilePyramidRegionEquality { MGLTilePyramidOfflineRegion *original = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] bounds:bounds fromZoomLevel:5 toZoomLevel:10]; MGLTilePyramidOfflineRegion *copy = [original copy]; XCTAssertEqualObjects(original, copy, @"Tile pyramid region should be equal to its copy."); - + XCTAssertEqualObjects(original.styleURL, copy.styleURL, @"Style URL has changed."); XCTAssert(MGLCoordinateBoundsEqualToCoordinateBounds(original.bounds, copy.bounds), @"Bounds have changed."); XCTAssertEqual(original.minimumZoomLevel, copy.minimumZoomLevel, @"Minimum zoom level has changed."); @@ -48,4 +48,25 @@ - (void)testGeometryRegionEquality { XCTAssertEqual(original.includesIdeographicGlyphs, copy.includesIdeographicGlyphs, @"Include ideographs has changed."); } +- (void)testIncludesIdeographicGlyphsByDefault{ + + //Tile pyramid offline region + { + MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(kCLLocationCoordinate2DInvalid, kCLLocationCoordinate2DInvalid); + MGLTilePyramidOfflineRegion *tilePyramidOfflineRegion = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] bounds:bounds fromZoomLevel:5 toZoomLevel:10]; + XCTAssertFalse(tilePyramidOfflineRegion.includesIdeographicGlyphs, @"tile pyramid offline region should not include ideographic glyphs"); + } + + //Shape offline region + { + NSString *geojson = @"{\"type\": \"Point\", \"coordinates\": [-3.8671874999999996, 52.482780222078226] }"; + NSError *error; + MGLShape *shape = [MGLShape shapeWithData: [geojson dataUsingEncoding:NSUTF8StringEncoding] encoding: NSUTF8StringEncoding error:&error]; + XCTAssertNil(error); + MGLShapeOfflineRegion *shapeOfflineRegion = [[MGLShapeOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] shape:shape fromZoomLevel:5 toZoomLevel:10]; + XCTAssertFalse(shapeOfflineRegion.includesIdeographicGlyphs, @"tile pyramid offline region should not include ideographic glyphs"); + + } +} + @end From 13ac436b5f18c579cc34a3228219c477e65ee114 Mon Sep 17 00:00:00 2001 From: m-stephen Date: Wed, 10 Jul 2019 10:06:25 +0800 Subject: [PATCH 07/12] Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray --- platform/darwin/test/MGLOfflineRegionTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/darwin/test/MGLOfflineRegionTests.m b/platform/darwin/test/MGLOfflineRegionTests.m index f17b3ceccf1..38a090d15e4 100644 --- a/platform/darwin/test/MGLOfflineRegionTests.m +++ b/platform/darwin/test/MGLOfflineRegionTests.m @@ -48,7 +48,7 @@ - (void)testGeometryRegionEquality { XCTAssertEqual(original.includesIdeographicGlyphs, copy.includesIdeographicGlyphs, @"Include ideographs has changed."); } -- (void)testIncludesIdeographicGlyphsByDefault{ +- (void)testIncludesIdeographicGlyphsByDefault { //Tile pyramid offline region { From 3997c99f2ec97e58f10be1f6758f6abdbc63abd4 Mon Sep 17 00:00:00 2001 From: m-stephen Date: Wed, 10 Jul 2019 10:06:41 +0800 Subject: [PATCH 08/12] Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray --- platform/darwin/test/MGLOfflineRegionTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/darwin/test/MGLOfflineRegionTests.m b/platform/darwin/test/MGLOfflineRegionTests.m index 38a090d15e4..1ac6e19a11e 100644 --- a/platform/darwin/test/MGLOfflineRegionTests.m +++ b/platform/darwin/test/MGLOfflineRegionTests.m @@ -50,7 +50,7 @@ - (void)testGeometryRegionEquality { - (void)testIncludesIdeographicGlyphsByDefault { - //Tile pyramid offline region + // Tile pyramid offline region { MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(kCLLocationCoordinate2DInvalid, kCLLocationCoordinate2DInvalid); MGLTilePyramidOfflineRegion *tilePyramidOfflineRegion = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] bounds:bounds fromZoomLevel:5 toZoomLevel:10]; From c0da17a0177a4bd87a614bdefdad8217de720c05 Mon Sep 17 00:00:00 2001 From: m-stephen Date: Wed, 10 Jul 2019 10:06:48 +0800 Subject: [PATCH 09/12] Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray --- platform/darwin/test/MGLOfflineRegionTests.m | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/darwin/test/MGLOfflineRegionTests.m b/platform/darwin/test/MGLOfflineRegionTests.m index 1ac6e19a11e..cc7b2d2c719 100644 --- a/platform/darwin/test/MGLOfflineRegionTests.m +++ b/platform/darwin/test/MGLOfflineRegionTests.m @@ -65,7 +65,6 @@ - (void)testIncludesIdeographicGlyphsByDefault { XCTAssertNil(error); MGLShapeOfflineRegion *shapeOfflineRegion = [[MGLShapeOfflineRegion alloc] initWithStyleURL:[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion] shape:shape fromZoomLevel:5 toZoomLevel:10]; XCTAssertFalse(shapeOfflineRegion.includesIdeographicGlyphs, @"tile pyramid offline region should not include ideographic glyphs"); - } } From 5fc92d97c9570122798c3123b8be6d219cb35942 Mon Sep 17 00:00:00 2001 From: m-stephen Date: Wed, 10 Jul 2019 10:07:02 +0800 Subject: [PATCH 10/12] Update platform/ios/CHANGELOG.md Co-Authored-By: Jason Wray --- platform/ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index c3317eaf471..723bba6e548 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -4,7 +4,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ## master -* Exclude CJK resources from offline download by default. ([#14176](https://github.com/mapbox/mapbox-gl-native/pull/14176)) +* Ideographic glyphs from Chinese, Japanese, and Korean are no longer downloaded by default as part of offline packs; they are instead rendered on-device, saving bandwidth and storage while improving performance. ([#14176](https://github.com/mapbox/mapbox-gl-native/pull/14176)) ## 5.2.0 From 8f134746ce8553c2d1b4fc3013348f7185bfe556 Mon Sep 17 00:00:00 2001 From: m-stephen Date: Wed, 10 Jul 2019 10:07:11 +0800 Subject: [PATCH 11/12] Update platform/macos/CHANGELOG.md Co-Authored-By: Jason Wray --- platform/macos/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 7f34cc1816b..3b3dabdea7e 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -4,7 +4,7 @@ * Added an `MGLMapView.prefetchesTiles` property to configure lower-resolution tile prefetching behavior. ([#14816](https://github.com/mapbox/mapbox-gl-native/pull/14816)) * Fixed queryRenderedFeatues bug caused by incorrect sort feature index calculation. ([#14884](https://github.com/mapbox/mapbox-gl-native/pull/14884)) -* Exclude CJK resources from offline download by default. ([#14176](https://github.com/mapbox/mapbox-gl-native/pull/14176)) +* Ideographic glyphs from Chinese, Japanese, and Korean are no longer downloaded by default as part of offline packs; they are instead rendered on-device, saving bandwidth and storage while improving performance. ([#14176](https://github.com/mapbox/mapbox-gl-native/pull/14176)) ### Styles and rendering From 604844a8b3f97952c2f9049746fd41a4e01f3ac0 Mon Sep 17 00:00:00 2001 From: m-stephen Date: Wed, 10 Jul 2019 10:07:19 +0800 Subject: [PATCH 12/12] Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray --- platform/darwin/test/MGLOfflineRegionTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/darwin/test/MGLOfflineRegionTests.m b/platform/darwin/test/MGLOfflineRegionTests.m index cc7b2d2c719..0af9ebb5fa9 100644 --- a/platform/darwin/test/MGLOfflineRegionTests.m +++ b/platform/darwin/test/MGLOfflineRegionTests.m @@ -57,7 +57,7 @@ - (void)testIncludesIdeographicGlyphsByDefault { XCTAssertFalse(tilePyramidOfflineRegion.includesIdeographicGlyphs, @"tile pyramid offline region should not include ideographic glyphs"); } - //Shape offline region + // Shape offline region { NSString *geojson = @"{\"type\": \"Point\", \"coordinates\": [-3.8671874999999996, 52.482780222078226] }"; NSError *error;