summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/darwin/src/MGLRendererConfiguration.h19
-rw-r--r--platform/darwin/src/MGLRendererConfiguration.mm36
-rw-r--r--platform/ios/CHANGELOG.md4
-rw-r--r--platform/ios/app/Info.plist2
-rw-r--r--platform/ios/docs/guides/Info.plist Keys.md14
-rw-r--r--platform/macos/CHANGELOG.md1
-rw-r--r--platform/macos/app/Info.plist2
-rw-r--r--platform/macos/docs/guides/Info.plist Keys.md14
8 files changed, 75 insertions, 17 deletions
diff --git a/platform/darwin/src/MGLRendererConfiguration.h b/platform/darwin/src/MGLRendererConfiguration.h
index ee5aaef174..bbcc3a8c75 100644
--- a/platform/darwin/src/MGLRendererConfiguration.h
+++ b/platform/darwin/src/MGLRendererConfiguration.h
@@ -26,11 +26,20 @@ MGL_EXPORT
/** The name of the font family to use for client-side text rendering.
Currently only used for CJK glyphs. Changing this at run time is not currently
- supported. Enable client-side rendering of CJK glyphs by setting
- `MGLIdeographicFontFamilyName` in your containing app's Info.plist to a value
- which will be available at run time. Default font for local ideograph font family
- is "PingFang". */
-@property (nonatomic, readonly) std::string localFontFamilyName;
+ supported. By default, client-side rendering is enabled for CJK glyphs using Apple
+ system default font.
+
+ Set `MGLIdeographicFontFamilyName` in your containing app's Info.plist to a string
+ value for using your specific local font which will be available at run time,
+ e.g. "PingFang TC".
+
+ Set `MGLIdeographicFontFamilyName` in your containing app's Info.plist to a array of
+ font family names. Once the front ones are unavaiable, it will fallback to others until
+ using default system font.
+
+ Set `MGLIdeographicFontFamilyName` to a Boolean value `NO` for using your custom remote font.
+ */
+@property (nonatomic, readonly) mbgl::optional<std::string> localFontFamilyName;
/**
A Boolean value indicating whether symbol layers may enable per-source symbol
diff --git a/platform/darwin/src/MGLRendererConfiguration.mm b/platform/darwin/src/MGLRendererConfiguration.mm
index d616e93eb2..3ae0c1a6c6 100644
--- a/platform/darwin/src/MGLRendererConfiguration.mm
+++ b/platform/darwin/src/MGLRendererConfiguration.mm
@@ -69,10 +69,40 @@ static NSString * const MGLCollisionBehaviorPre4_0Key = @"MGLCollisionBehaviorPr
return mbgl::optional<std::string>();
}
-- (std::string)localFontFamilyName {
- NSString *fontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"];
+- (mbgl::optional<std::string>)localFontFamilyName {
+
+ std::string systemFontFamilyName;
+#if TARGET_OS_IPHONE
+ systemFontFamilyName = std::string([[UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName UTF8String]);
+#else
+ systemFontFamilyName = std::string([[NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName UTF8String]);
+#endif
- return fontFamilyName ? std::string([fontFamilyName UTF8String]) : std::string("PingFang");
+ id fontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"];
+
+ if([fontFamilyName isKindOfClass:[NSNumber class]] && ![fontFamilyName boolValue])
+ {
+ return mbgl::optional<std::string>();
+ }
+ else if([fontFamilyName isKindOfClass:[NSString class]])
+ {
+ return fontFamilyName ? std::string([fontFamilyName UTF8String]) : systemFontFamilyName;
+ }
+ //Ability to specify an array of fonts for fallbacks for `localIdeographicFontFamily`
+ else if ([fontFamilyName isKindOfClass:[NSArray class]]){
+ for(NSString *name in fontFamilyName){
+#if TARGET_OS_IPHONE
+ if([[UIFont familyNames] containsObject:name]){
+ return std::string([name UTF8String]);
+ }
+#else
+ if([[[NSFontManager sharedFontManager] availableFontFamilies] containsObject:name]){
+ return std::string([name UTF8String]);
+ }
+#endif
+ }
+ }
+ return systemFontFamilyName;
}
@end
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 196c777a88..dc421fce22 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -8,6 +8,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Fixed style change transition regression caused by delayed setting of the updated layer properties. ([#15016](https://github.com/mapbox/mapbox-gl-native/pull/15016))
+### Other changes
+
+* 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))
+
## 5.2.0
### Offline maps
diff --git a/platform/ios/app/Info.plist b/platform/ios/app/Info.plist
index e2f294a5a5..c302f306a6 100644
--- a/platform/ios/app/Info.plist
+++ b/platform/ios/app/Info.plist
@@ -24,8 +24,6 @@
<string>7877</string>
<key>LSRequiresIPhoneOS</key>
<true/>
- <key>MGLIdeographicFontFamilyName</key>
- <string>PingFang TC</string>
<key>NSHumanReadableCopyright</key>
<string>© 2014–2019 Mapbox</string>
<key>NSLocationAlwaysUsageDescription</key>
diff --git a/platform/ios/docs/guides/Info.plist Keys.md b/platform/ios/docs/guides/Info.plist Keys.md
index 97b9d7419e..71b31b988a 100644
--- a/platform/ios/docs/guides/Info.plist Keys.md
+++ b/platform/ios/docs/guides/Info.plist Keys.md
@@ -22,7 +22,15 @@ If you have implemented custom opt-out of Mapbox Telemetry within the user inter
## MGLIdeographicFontFamilyName
-The name of the font family to use for client-side text rendering of CJK ideographs. Set this to the name of a font family which will be available at run time, e.g. `PingFang TC` (iOS 9+), `Heiti TC` (iOS 8+), another appropriate built-in font, or a font provided by your application. Note that if a non-existent font is specified, iOS will fall back to using Helvetica which is likely not to include support for the glyphs needed to render maps in your application.
+The name of the font family to use for client-side text rendering of CJK ideographs.
+
+Set MGLIdeographicFontFamilyName in your containing application's Info.plist to font family name(s) that will be available at run time, such as “PingFang TC” or “Marker Felt”. This plist key accepts:
+
+A string value of a single font family name.
+
+An array of font family names. Fonts will be used in the defined order, eventually falling back to default system font if none are available.
+
+A boolean value NO to disable client-side rendering of CJK glyphs — remote fonts specified in your style will be used instead.
## MGLCollisionBehaviorPre4_0
@@ -30,4 +38,6 @@ The name of the font family to use for client-side text rendering of CJK ideogra
Beginning in version 4.0, the SDK also performs collision detection between style layers based on different sources by default. For the default behavior, omit the `MGLCollisionBehaviorPre4_0` key or set it to NO (`false`).
-This property may also be set using `[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"MGLCollisionBehaviorPre4_0"]`; it will override any value specified in the `Info.plist`. \ No newline at end of file
+This property may also be set using `[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"MGLCollisionBehaviorPre4_0"]`; it will override any value specified in the `Info.plist`.
+
+
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index 241499432b..84e9be89a7 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))
+* 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))
### Styles and rendering
diff --git a/platform/macos/app/Info.plist b/platform/macos/app/Info.plist
index 8bb225358c..21b86bfc75 100644
--- a/platform/macos/app/Info.plist
+++ b/platform/macos/app/Info.plist
@@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>MGLIdeographicFontFamilyName</key>
- <string>PingFang TC</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
diff --git a/platform/macos/docs/guides/Info.plist Keys.md b/platform/macos/docs/guides/Info.plist Keys.md
index fe4c87b0c0..bfea7f11e5 100644
--- a/platform/macos/docs/guides/Info.plist Keys.md
+++ b/platform/macos/docs/guides/Info.plist Keys.md
@@ -16,12 +16,20 @@ Use this key if you need to customize the API base URL used throughout the SDK.
The default value is `https://api.mapbox.com`.
-## MGLIdeographicFontFamilyName
+## MGLIdeographicFontFamilyName
-The name of the font family to use for client-side text rendering of CJK ideographs. Set this to the name of a font family which will be available at run time, e.g. `PingFang TC` (iOS 9+), `Heiti TC` (iOS 8+), another appropriate built-in font, or a font provided by your application. Note that if a non-existent font is specified, iOS will fall back to using Helvetica which is likely not to include support for the glyphs needed to render maps in your application.
+The name of the font family to use for client-side text rendering of CJK ideographs.
+
+Set MGLIdeographicFontFamilyName in your containing application's Info.plist to font family name(s) that will be available at run time, such as “PingFang TC” or “Marker Felt”. This plist key accepts:
+
+A string value of a single font family name.
+
+An array of font family names. Fonts will be used in the defined order, eventually falling back to default system font if none are available.
+
+A boolean value NO to disable client-side rendering of CJK glyphs — remote fonts specified in your style will be used instead.
## MGLCollisionBehaviorPre4_0
If this key is set to YES (`true`), collision detection is performed only between symbol style layers based on the same source, as in versions 0.1–0.7 of the Mapbox Maps SDK for iOS. In other words, symbols in an `MGLSymbolStyleLayer` based on one source (for example, an `MGLShapeSource`) may overlap with symbols in another layer that is based on a different source (such as the Mapbox Streets source). This is the case regardless of the `MGLSymbolStyleLayer.iconAllowsOverlap`, `MGLSymbolStyleLayer.iconIgnoresPlacement`, `MGLSymbolStyleLayer.textAllowsOverlap`, and `MGLSymbolStyleLayer.textIgnoresPlacement` properties.
-Beginning in version 0.7, the SDK also performs collision detection between style layers based on different sources by default. For the default behavior, omit the `MGLCollisionBehaviorPre4_0` key or set it to NO (`false`). This property is so named because version 0.7 of the Mapbox Maps SDK for macOS corresponds to version 4.0 of the Mapbox Maps SDK for iOS. \ No newline at end of file
+Beginning in version 0.7, the SDK also performs collision detection between style layers based on different sources by default. For the default behavior, omit the `MGLCollisionBehaviorPre4_0` key or set it to NO (`false`). This property is so named because version 0.7 of the Mapbox Maps SDK for macOS corresponds to version 4.0 of the Mapbox Maps SDK for iOS.