[ios , macos] Exclude CJK resources from offline download by default (#14952)
* [iOS, macOS] exclude CJK glyphs resources download by default. * [iOS, macOS] update iosapp * [iOS, macOS] update macOS * [iOS, macOS] update iOS change log * [iOS, macOS] update macOS change log * [iOS, macOS] update comment & add test cases * Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray <friedbunny@users.noreply.github.com> * Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray <friedbunny@users.noreply.github.com> * Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray <friedbunny@users.noreply.github.com> * Update platform/ios/CHANGELOG.md Co-Authored-By: Jason Wray <friedbunny@users.noreply.github.com> * Update platform/macos/CHANGELOG.md Co-Authored-By: Jason Wray <friedbunny@users.noreply.github.com> * Update platform/darwin/test/MGLOfflineRegionTests.m Co-Authored-By: Jason Wray <friedbunny@users.noreply.github.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
_shape = shape;
|
||||
_minimumZoomLevel = minimumZoomLevel;
|
||||
_maximumZoomLevel = maximumZoomLevel;
|
||||
_includesIdeographicGlyphs = YES;
|
||||
_includesIdeographicGlyphs = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
_bounds = bounds;
|
||||
_minimumZoomLevel = minimumZoomLevel;
|
||||
_maximumZoomLevel = maximumZoomLevel;
|
||||
_includesIdeographicGlyphs = YES;
|
||||
_includesIdeographicGlyphs = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
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 @@
|
||||
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,24 @@
|
||||
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
|
||||
|
||||
@@ -8,6 +8,9 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
|
||||
|
||||
* Fixed a custom geometry source bug caused by using the outdated tiles after style update [#15112](https://github.com/mapbox/mapbox-gl-native/pull/15112)
|
||||
|
||||
### Other changes
|
||||
* 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
|
||||
|
||||
### Offline maps
|
||||
|
||||
@@ -103,8 +103,10 @@ static NSString * const MBXOfflinePacksTableViewActiveCellReuseIdentifier = @"Ac
|
||||
}
|
||||
|
||||
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,
|
||||
}];
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
* 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))
|
||||
* 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))
|
||||
* The `MGLIdeographicFontFamilyName` Info.plist key now also accepts an array of font family names, to customize font fallback behavior. It can also be set to a Boolean value of `NO` to force the SDK to typeset CJK characters in a remote font specified by `MGLSymbolStyleLayer.textFontNames`. ([#14862](https://github.com/mapbox/mapbox-gl-native/pull/14862))
|
||||
* Performance improvements for queryRenderedFeatures API and optimization that allocates containers based on a number of rendered layers. ([#14930](https://github.com/mapbox/mapbox-gl-native/pull/14930))
|
||||
* Fixed rendering layers after fill-extrusion regression caused by optimization of fill-extrusion rendering. ([#15065](https://github.com/mapbox/mapbox-gl-native/pull/15065))
|
||||
|
||||
|
||||
### Styles and rendering
|
||||
|
||||
* Setting `MGLMapView.contentInset` now moves the map’s focal point to the center of the content frame after insetting. ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664))
|
||||
|
||||
@@ -932,8 +932,8 @@ NSArray<id <MGLAnnotation>> *MBXFlattenedShapes(NSArray<id <MGLAnnotation>> *sha
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user