diff options
author | Andrew Kitchen <andrew.kitchen@mapbox.com> | 2017-11-30 17:13:44 -0800 |
---|---|---|
committer | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2018-01-03 11:37:53 -0600 |
commit | c1705f37fb89cff99bfee0b62afec391feb70606 (patch) | |
tree | 9dc35055de8e09e5c3711219874759a5ad380be3 /platform/macos | |
parent | 0dc00ad877de2a68183257488763be3cb32482c2 (diff) | |
download | qtlocation-mapboxgl-c1705f37fb89cff99bfee0b62afec391feb70606.tar.gz |
[ios, macos] Adds support for specifying an ideographic font family name
Adding a MGLIdeographicFontFamilyName to the containing app's Info.plist
will result in CJK glyphs being rasterized on demand (#10522)
Diffstat (limited to 'platform/macos')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 5fb70d775a..542482e2a3 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -143,6 +143,8 @@ public: @property (nonatomic, readwrite) NSView *attributionView; @property (nonatomic, readwrite) MGLStyle *style; +@property (nonatomic, readonly) NSString *ideographicFontFamilyName; + /// Mapping from reusable identifiers to annotation images. @property (nonatomic) NS_MUTABLE_DICTIONARY_OF(NSString *, MGLAnnotationImage *) *annotationImagesByIdentifier; @@ -217,7 +219,7 @@ public: - (instancetype)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { - [self commonInit:nil]; + [self commonInit]; self.styleURL = nil; } return self; @@ -225,7 +227,7 @@ public: - (instancetype)initWithFrame:(NSRect)frame styleURL:(nullable NSURL *)styleURL { if (self = [super initWithFrame:frame]) { - [self commonInit:nil]; + [self commonInit]; self.styleURL = styleURL; } return self; @@ -233,7 +235,7 @@ public: - (instancetype)initWithCoder:(nonnull NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { - [self commonInit:nil]; + [self commonInit]; } return self; } @@ -252,7 +254,7 @@ public: return @[@"camera", @"debugMask"]; } -- (void)commonInit:(nullable NSString*)fontFamily { +- (void)commonInit { _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; // Set up cross-platform controllers and resources. @@ -271,10 +273,10 @@ public: [[NSFileManager defaultManager] removeItemAtURL:legacyCacheURL error:NULL]; mbgl::DefaultFileSource* mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource; - _mbglThreadPool = mbgl::sharedThreadPool(); + NSString *fontFamilyName = self.ideographicFontFamilyName; - auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::GLContextMode::Unique, mbgl::optional<std::string>(), fontFamily ? std::string([fontFamily UTF8String]) : mbgl::optional<std::string>()); + auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::GLContextMode::Unique, mbgl::optional<std::string>(), fontFamilyName ? std::string([fontFamilyName UTF8String]) : mbgl::optional<std::string>()); _rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView, true); _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default); @@ -652,6 +654,12 @@ public: return _rendererFrontend->getRenderer(); } +#pragma mark Ideographic Font Info + +- (NSString *)ideographicFontFamilyName { + return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"]; +} + #pragma mark View hierarchy and drawing - (void)viewWillMoveToWindow:(NSWindow *)newWindow { |