summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2019-03-22 13:45:39 -0700
committerFabian Guerra Soto <fabian.guerra@mapbox.com>2019-03-22 15:08:58 -0700
commit79582487aa69569933e38cadc0faf5ea04711303 (patch)
tree7f44ae7c6654171fd58faaafd6bfd3ab7e9306aa
parentbe46a707f992ce48e65163353924e0d7be25c722 (diff)
downloadqtlocation-mapboxgl-79582487aa69569933e38cadc0faf5ea04711303.tar.gz
[ios, macos] Support expressions in formatting parameters. (#14198)
Modified MGLAttributedExpression object to support NSExpressions as formatting attributes only. This aligns with GL and Android implementation and specification. Modified the documentation accordingly, and changed MGLFontSizeAttribute to MGLFontScaleAttribute to clarify the true function of the formatting parameter.
-rw-r--r--platform/darwin/docs/guides/For Style Authors.md.ejs2
-rw-r--r--platform/darwin/docs/guides/Predicates and Expressions.md6
-rw-r--r--platform/darwin/src/MGLAttributedExpression.h40
-rw-r--r--platform/darwin/src/MGLAttributedExpression.m14
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.mm27
-rw-r--r--platform/darwin/test/MGLDocumentationExampleTests.swift8
-rw-r--r--platform/darwin/test/MGLExpressionTests.mm52
-rw-r--r--platform/ios/docs/guides/For Style Authors.md2
-rw-r--r--platform/macos/docs/guides/For Style Authors.md2
9 files changed, 75 insertions, 78 deletions
diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs
index cff6e2f41c..8df541d0f7 100644
--- a/platform/darwin/docs/guides/For Style Authors.md.ejs
+++ b/platform/darwin/docs/guides/For Style Authors.md.ejs
@@ -439,7 +439,7 @@ can use to update the formatting of `MGLSymbolStyleLayer.text` property.
In style JSON | In Objective-C | In Swift
--------------|-----------------------|---------
`text-font` | `MGLFontNamesAttribute` | `.fontNamesAttribute`
-`font-scale` | `MGLFontSizeAttribute` | `.fontSizeAttribute`
+`font-scale` | `MGLFontScaleAttribute` | `.fontScaleAttribute`
`text-color` | `MGLFontColorAttribute` | `.fontColorAttribute`
See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for
diff --git a/platform/darwin/docs/guides/Predicates and Expressions.md b/platform/darwin/docs/guides/Predicates and Expressions.md
index 51617c8508..b2e01b94db 100644
--- a/platform/darwin/docs/guides/Predicates and Expressions.md
+++ b/platform/darwin/docs/guides/Predicates and Expressions.md
@@ -550,9 +550,9 @@ with the `MGLSymbolStyleLayer.text` property.
Key | Value Type
--- | ---
- `MGLFontNamesAttribute` | `NSArray<NSString *>*`
- `MGLFontSizeAttribute` | `NSNumber`
- `MGLFontColorAttribute` | `UIColor` or `NSColor` on macos
+ `MGLFontNamesAttribute` | An `NSExpression` evaluating to an `NSString` array.
+ `MGLFontScaleAttribute` | An `NSExpression` evaluating to an `NSNumber` value.
+ `MGLFontColorAttribute` | An `NSExpression` evaluating to an `UIColor` (iOS) or `NSColor` (macOS).
This function corresponds to the
[`format`](https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-types-format)
diff --git a/platform/darwin/src/MGLAttributedExpression.h b/platform/darwin/src/MGLAttributedExpression.h
index 32f1a96dae..ea298c7a44 100644
--- a/platform/darwin/src/MGLAttributedExpression.h
+++ b/platform/darwin/src/MGLAttributedExpression.h
@@ -2,10 +2,16 @@
NS_ASSUME_NONNULL_BEGIN
-typedef NSString * MGLAttributedExpressionKey NS_EXTENSIBLE_STRING_ENUM;
+/** Options for `MGLAttributedExpression.attributes`. */
+typedef NSString * MGLAttributedExpressionKey NS_TYPED_ENUM;
+/** The font name string array expression used to format the text. */
FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontNamesAttribute;
-FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontSizeAttribute;
+
+/** The font scale number expression relative to `MGLSymbolStyleLayer.textFontSize` used to format the text. */
+FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontScaleAttribute;
+
+/** The font color expression used to format the text. */
FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontColorAttribute;
/**
@@ -16,10 +22,10 @@ FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontColorAttrib
```swift
let redColor = UIColor.red
let expression = NSExpression(forConstantValue: "Foo")
- let attributes: Dictionary<MGLAttributedExpressionKey, Any> = [.fontNamesAttribute : ["DIN Offc Pro Italic",
- "Arial Unicode MS Regular"],
- .fontSizeAttribute: 1.2,
- .fontColorAttribute: redColor]
+ let attributes: [MGLAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : NSExpression(forConstantValue: ["DIN Offc Pro Italic",
+ "Arial Unicode MS Regular"]),
+ .fontScaleAttribute: NSExpression(forConstantValue: 1.2),
+ .fontColorAttribute: NSExpression(forConstantValue: redColor)]
let attributedExpression = MGLAttributedExpression(expression, attributes:attributes)
```
@@ -37,22 +43,22 @@ MGL_EXPORT
The formatting attributes dictionary.
Key | Value Type
--- | ---
- `MGLFontNamesAttribute` | `NSArray<NSString *>*`
- `MGLFontSizeAttribute` | `NSNumber`
- `MGLFontColorAttribute` | `UIColor`
+ `MGLFontNamesAttribute` | An `NSExpression` evaluating to an `NSString` array.
+ `MGLFontScaleAttribute` | An `NSExpression` evaluating to an `NSNumber` value.
+ `MGLFontColorAttribute` | An `NSExpression` evaluating to an `UIColor`.
*/
-@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, id> *attributes;
+@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, NSExpression *> *attributes;
#else
/**
The formatting attributes dictionary.
Key | Value Type
--- | ---
- `MGLFontNamesAttribute` | `NSArray<NSString *>*`
- `MGLFontSizeAttribute` | `NSNumber`
- `MGLFontColorAttribute` | `NSColor`
+ `MGLFontNamesAttribute` | An `NSExpression` evaluating to an `NSString` array.
+ `MGLFontScaleAttribute` | An `NSExpression` evaluating to an `NSNumber` value.
+ `MGLFontColorAttribute` | An `NSExpression` evaluating to an `NSColor` on macos.
*/
-@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, id> *attributes;
+@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, NSExpression *> *attributes;
#endif
@@ -64,17 +70,17 @@ MGL_EXPORT
/**
Returns an `MGLAttributedExpression` object initialized with an expression and text format attributes.
*/
-- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, id> *)attrs;
+- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, NSExpression *> *)attrs;
/**
Creates an `MGLAttributedExpression` object initialized with an expression and the format attributes for font names and font size.
*/
-+ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontSize:(nullable NSNumber *)fontSize;
++ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontScale:(nullable NSNumber *)fontScale;
/**
Creates an `MGLAttributedExpression` object initialized with an expression and the format attributes dictionary.
*/
-+ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, id> *)attrs;
++ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary <MGLAttributedExpressionKey, NSExpression *> *)attrs;
@end
diff --git a/platform/darwin/src/MGLAttributedExpression.m b/platform/darwin/src/MGLAttributedExpression.m
index 000701f7cf..a34480a957 100644
--- a/platform/darwin/src/MGLAttributedExpression.m
+++ b/platform/darwin/src/MGLAttributedExpression.m
@@ -2,7 +2,7 @@
#import "MGLLoggingConfiguration_Private.h"
const MGLAttributedExpressionKey MGLFontNamesAttribute = @"text-font";
-const MGLAttributedExpressionKey MGLFontSizeAttribute = @"font-scale";
+const MGLAttributedExpressionKey MGLFontScaleAttribute = @"font-scale";
const MGLAttributedExpressionKey MGLFontColorAttribute = @"text-color";
@implementation MGLAttributedExpression
@@ -12,24 +12,24 @@ const MGLAttributedExpressionKey MGLFontColorAttribute = @"text-color";
return self;
}
-+ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString *> *)fontNames fontSize:(nullable NSNumber *)fontSize {
++ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString *> *)fontNames fontScale:(nullable NSNumber *)fontScale {
MGLAttributedExpression *attributedExpression;
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
if (fontNames && fontNames.count > 0) {
- attrs[MGLFontNamesAttribute] = fontNames;
+ attrs[MGLFontNamesAttribute] = [NSExpression expressionForConstantValue:fontNames];
}
- if (fontSize) {
- attrs[MGLFontSizeAttribute] = fontSize;
+ if (fontScale) {
+ attrs[MGLFontScaleAttribute] = [NSExpression expressionForConstantValue:fontScale];
}
attributedExpression = [[self alloc] initWithExpression:expression attributes:attrs];
return attributedExpression;
}
-+ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary<MGLAttributedExpressionKey,id> *)attrs {
++ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary<MGLAttributedExpressionKey, NSExpression *> *)attrs {
MGLAttributedExpression *attributedExpression;
attributedExpression = [[self alloc] initWithExpression:expression attributes:attrs];
@@ -37,7 +37,7 @@ const MGLAttributedExpressionKey MGLFontColorAttribute = @"text-color";
return attributedExpression;
}
-- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary<MGLAttributedExpressionKey,id> *)attrs {
+- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary<MGLAttributedExpressionKey, NSExpression *> *)attrs {
if (self = [super init])
{
MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class]));
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm
index b509c12172..4b1fdb818e 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.mm
+++ b/platform/darwin/src/NSExpression+MGLAdditions.mm
@@ -882,19 +882,8 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
attrs = [NSMutableDictionary dictionaryWithDictionary:argumentObjects[index + 1]];
}
- if (attrs.count) {
- if (NSArray *fontNames = MGL_OBJC_DYNAMIC_CAST(attrs[MGLFontNamesAttribute], NSArray)) {
- attrs[MGLFontNamesAttribute] = fontNames[1];
- }
- if (NSArray *colorArray = MGL_OBJC_DYNAMIC_CAST(attrs[MGLFontColorAttribute], NSArray)) {
- if ([colorArray[0] isEqualToString:@"rgb"] || [colorArray[0] isEqualToString:@"rgba"]) {
- NSArray *colorArguments = [colorArray subarrayWithRange:NSMakeRange(1, colorArray.count - 1)];
- NSArray *subexpressions = MGLSubexpressionsWithJSONObjects(colorArguments);
- MGLColor *color = [NSExpression mgl_colorWithRGBComponents:subexpressions];
-
- attrs[MGLFontColorAttribute] = color;
- }
- }
+ for (NSString *key in attrs.allKeys) {
+ attrs[key] = [NSExpression expressionWithMGLJSONObject:attrs[key]];
}
MGLAttributedExpression *attributedExpression = [[MGLAttributedExpression alloc] initWithExpression:expression attributes:attrs];
@@ -1016,17 +1005,15 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
if ([constantValue isKindOfClass:[MGLAttributedExpression class]]) {
MGLAttributedExpression *attributedExpression = (MGLAttributedExpression *)constantValue;
id jsonObject = attributedExpression.expression.mgl_jsonExpressionObject;
- NSMutableDictionary *attributedDictionary = [NSMutableDictionary dictionary];
+ NSMutableDictionary<MGLAttributedExpressionKey, NSExpression *> *attributedDictionary = [NSMutableDictionary dictionary];
if (attributedExpression.attributes) {
attributedDictionary = [NSMutableDictionary dictionaryWithDictionary:attributedExpression.attributes];
- if (attributedDictionary[MGLFontNamesAttribute]) {
- attributedDictionary[MGLFontNamesAttribute] = @[@"literal", attributedDictionary[MGLFontNamesAttribute]];
- }
- if (attributedDictionary[MGLFontColorAttribute] && [attributedDictionary[MGLFontColorAttribute] isKindOfClass:[MGLColor class]]) {
- MGLColor *color = attributedDictionary[MGLFontColorAttribute];
- attributedDictionary[MGLFontColorAttribute] = color.mgl_jsonExpressionObject;
+
+ for (NSString *key in attributedExpression.attributes.allKeys) {
+ attributedDictionary[key] = attributedExpression.attributes[key].mgl_jsonExpressionObject;
}
+
}
return @[jsonObject, attributedDictionary];
}
diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift
index 45efe4c591..2a64fbc601 100644
--- a/platform/darwin/test/MGLDocumentationExampleTests.swift
+++ b/platform/darwin/test/MGLDocumentationExampleTests.swift
@@ -550,10 +550,10 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate {
let redColor = UIColor.red
#endif
let expression = NSExpression(forConstantValue: "Foo")
- let attributes: Dictionary<MGLAttributedExpressionKey, Any> = [.fontNamesAttribute : ["DIN Offc Pro Italic",
- "Arial Unicode MS Regular"],
- .fontSizeAttribute: 1.2,
- .fontColorAttribute: redColor]
+ let attributes: [MGLAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : NSExpression(forConstantValue: ["DIN Offc Pro Italic",
+ "Arial Unicode MS Regular"]),
+ .fontScaleAttribute: NSExpression(forConstantValue: 1.2),
+ .fontColorAttribute: NSExpression(forConstantValue: redColor)]
let attributedExpression = MGLAttributedExpression(expression, attributes:attributes)
//#-end-example-code
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm
index 2a4d40b4c5..68806e38f6 100644
--- a/platform/darwin/test/MGLExpressionTests.mm
+++ b/platform/darwin/test/MGLExpressionTests.mm
@@ -992,16 +992,16 @@ using namespace std::string_literals;
{
MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
fontNames:nil
- fontSize:@(1.2)];
+ fontScale:@(1.2)];
MGLAttributedExpression *attribute2 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"biz"]
fontNames:nil
- fontSize:@(1.0)];
+ fontScale:@(1.0)];
MGLAttributedExpression *attribute3 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"bar"]
fontNames:nil
- fontSize:@(0.8)];
+ fontScale:@(0.8)];
MGLAttributedExpression *attribute4 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\r"]
fontNames:@[]
- fontSize:nil];
+ fontScale:nil];
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@, %@, %@, %@)",
MGLConstantExpression(attribute1),
MGLConstantExpression(attribute4),
@@ -1014,16 +1014,16 @@ using namespace std::string_literals;
{
MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
fontNames:nil
- fontSize:@(1.2)];
+ fontScale:@(1.2)];
MGLAttributedExpression *attribute2 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"biz"]
fontNames:nil
- fontSize:@(1.0)];
+ fontScale:@(1.0)];
MGLAttributedExpression *attribute3 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"bar"]
fontNames:nil
- fontSize:@(0.8)];
+ fontScale:@(0.8)];
MGLAttributedExpression *attribute4 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\n"]
fontNames:@[]
- fontSize:nil];
+ fontScale:nil];
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@, %@, %@, %@)",
MGLConstantExpression(attribute1),
MGLConstantExpression(attribute4),
@@ -1036,7 +1036,7 @@ using namespace std::string_literals;
{
MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
fontNames:nil
- fontSize:@(1.2)];
+ fontScale:@(1.2)];
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
NSExpression *compatibilityExpression = [NSExpression expressionForFunction:@"mgl_attributed:" arguments:@[MGLConstantExpression(attribute1)]];
@@ -1048,8 +1048,8 @@ using namespace std::string_literals;
}
{
MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]
- attributes:@{ MGLFontSizeAttribute: @(1.2),
- MGLFontColorAttribute: @"yellow"}] ;
+ attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
+ MGLFontColorAttribute: MGLConstantExpression(@"yellow") }] ;
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
NSExpression *compatibilityExpression = [NSExpression expressionForFunction:@"mgl_attributed:" arguments:@[MGLConstantExpression(attribute1)]];
@@ -1068,22 +1068,25 @@ using namespace std::string_literals;
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
+ NSExpression *fontNames = [NSExpression expressionForAggregate:@[ MGLConstantExpression(@"DIN Offc Pro Bold"), MGLConstantExpression(@"Arial Unicode MS Bold") ]];
MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]
- attributes:@{ MGLFontSizeAttribute: @(1.2),
- MGLFontColorAttribute: @"yellow",
- MGLFontNamesAttribute: @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]
+ attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
+ MGLFontColorAttribute: MGLConstantExpression(@"yellow"),
+ MGLFontNamesAttribute: fontNames
}] ;
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
NSArray *jsonExpression = @[ @"format", @"foo", @{ @"font-scale": @1.2, @"text-color": @"yellow" , @"text-font" : @[ @"literal", @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]]} ];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
+ NSExpression *exp = [NSExpression expressionWithMGLJSONObject:jsonExpression];
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
+ NSExpression *fontNames = [NSExpression expressionForAggregate:@[ MGLConstantExpression(@"DIN Offc Pro Bold"), MGLConstantExpression(@"Arial Unicode MS Bold") ]];
MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionForConstantValue:@"foo"]
- attributes:@{ MGLFontSizeAttribute: @(1.2),
- MGLFontColorAttribute: [MGLColor redColor],
- MGLFontNamesAttribute: @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]
+ attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
+ MGLFontColorAttribute: MGLConstantExpression([MGLColor redColor]),
+ MGLFontNamesAttribute: fontNames
}] ;
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
@@ -1092,10 +1095,11 @@ using namespace std::string_literals;
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
+ NSExpression *fontNames = [NSExpression expressionForAggregate:@[ MGLConstantExpression(@"DIN Offc Pro Bold"), MGLConstantExpression(@"Arial Unicode MS Bold") ]];
MGLAttributedExpression *attribute1 = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"CAST(x, 'NSString')"]
- attributes:@{ MGLFontSizeAttribute: @(1.2),
- MGLFontColorAttribute: [MGLColor redColor],
- MGLFontNamesAttribute: @[ @"DIN Offc Pro Bold", @"Arial Unicode MS Bold" ]
+ attributes:@{ MGLFontScaleAttribute: MGLConstantExpression(@(1.2)),
+ MGLFontColorAttribute: MGLConstantExpression([MGLColor redColor]),
+ MGLFontNamesAttribute: fontNames
}] ;
NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@)", MGLConstantExpression(attribute1)];
@@ -1106,16 +1110,16 @@ using namespace std::string_literals;
{
MGLAttributedExpression *attribute1 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"foo"]
fontNames:nil
- fontSize:@(1.2)];
+ fontScale:@(1.2)];
MGLAttributedExpression *attribute2 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"biz"]
fontNames:nil
- fontSize:@(1.0)];
+ fontScale:@(1.0)];
MGLAttributedExpression *attribute3 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"bar"]
fontNames:nil
- fontSize:@(0.8)];
+ fontScale:@(0.8)];
MGLAttributedExpression *attribute4 = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\n"]
fontNames:@[]
- fontSize:nil];
+ fontScale:nil];
NSExpression *expression = [NSExpression mgl_expressionForAttributedExpressions:@[MGLConstantExpression(attribute1),
MGLConstantExpression(attribute4),
MGLConstantExpression(attribute2),
diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md
index 44d5e47262..1acf587cda 100644
--- a/platform/ios/docs/guides/For Style Authors.md
+++ b/platform/ios/docs/guides/For Style Authors.md
@@ -426,7 +426,7 @@ can use to update the formatting of `MGLSymbolStyleLayer.text` property.
In style JSON | In Objective-C | In Swift
--------------|-----------------------|---------
`text-font` | `MGLFontNamesAttribute` | `.fontNamesAttribute`
-`font-scale` | `MGLFontSizeAttribute` | `.fontSizeAttribute`
+`font-scale` | `MGLFontScaleAttribute` | `.fontScaleAttribute`
`text-color` | `MGLFontColorAttribute` | `.fontColorAttribute`
See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for
diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md
index 220ce3d50e..5a81eb3593 100644
--- a/platform/macos/docs/guides/For Style Authors.md
+++ b/platform/macos/docs/guides/For Style Authors.md
@@ -419,7 +419,7 @@ can use to update the formatting of `MGLSymbolStyleLayer.text` property.
In style JSON | In Objective-C | In Swift
--------------|-----------------------|---------
`text-font` | `MGLFontNamesAttribute` | `.fontNamesAttribute`
-`font-scale` | `MGLFontSizeAttribute` | `.fontSizeAttribute`
+`font-scale` | `MGLFontScaleAttribute` | `.fontScaleAttribute`
`text-color` | `MGLFontColorAttribute` | `.fontColorAttribute`
See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for