diff options
author | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2019-03-19 14:53:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-19 14:53:35 -0700 |
commit | 174c8fa7e4927ebf28a3d0e07c995d3e3d69de76 (patch) | |
tree | f503bdf15e24f9c744f634107fc04c6338d1c42d /platform/macos | |
parent | 10e1e63aee95f579f951e3c2001640a268d3d95c (diff) | |
download | qtlocation-mapboxgl-174c8fa7e4927ebf28a3d0e07c995d3e3d69de76.tar.gz |
[ios, macos] Add text-color support to format expressions. (#14146)
Added the possibility of overriding paint properties inside the format expression.
Added an example of how to create an MGLAttributedExpression object and documented the attributes keys and value types.
Fixed a bug that ignored the font names.
Diffstat (limited to 'platform/macos')
-rw-r--r-- | platform/macos/docs/guides/For Style Authors.md | 11 | ||||
-rw-r--r-- | platform/macos/src/NSColor+MGLAdditions.h | 1 | ||||
-rw-r--r-- | platform/macos/src/NSColor+MGLAdditions.mm | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md index 038ddf1f93..220ce3d50e 100644 --- a/platform/macos/docs/guides/For Style Authors.md +++ b/platform/macos/docs/guides/For Style Authors.md @@ -411,5 +411,16 @@ In style JSON | In the format string `["any", f0, …, fn]` | `p0 OR … OR pn` `["none", f0, …, fn]` | `NOT (p0 OR … OR pn)` +## Specifying the text format + +The following format attributes are defined as `NSString` constans that you +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` +`text-color` | `MGLFontColorAttribute` | `.fontColorAttribute` + See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for a full description of the supported operators and operand types. diff --git a/platform/macos/src/NSColor+MGLAdditions.h b/platform/macos/src/NSColor+MGLAdditions.h index 21c939fec6..a3c5aba63f 100644 --- a/platform/macos/src/NSColor+MGLAdditions.h +++ b/platform/macos/src/NSColor+MGLAdditions.h @@ -23,5 +23,6 @@ + (NSExpression *)mgl_expressionForRGBComponents:(NSArray<NSExpression *> *)components; + (NSExpression *)mgl_expressionForRGBAComponents:(NSArray<NSExpression *> *)components; ++ (NSColor *)mgl_colorWithRGBComponents:(NSArray<NSExpression *> *)componentExpressions; @end diff --git a/platform/macos/src/NSColor+MGLAdditions.mm b/platform/macos/src/NSColor+MGLAdditions.mm index c73c1a41b7..ea7d99f66d 100644 --- a/platform/macos/src/NSColor+MGLAdditions.mm +++ b/platform/macos/src/NSColor+MGLAdditions.mm @@ -37,7 +37,7 @@ @implementation NSExpression (MGLColorAdditions) + (NSExpression *)mgl_expressionForRGBComponents:(NSArray<NSExpression *> *)components { - if (NSColor *color = [self mgl_colorWithComponentExpressions:components]) { + if (NSColor *color = [self mgl_colorWithRGBComponents:components]) { return [NSExpression expressionForConstantValue:color]; } @@ -49,7 +49,7 @@ } + (NSExpression *)mgl_expressionForRGBAComponents:(NSArray<NSExpression *> *)components { - if (NSColor *color = [self mgl_colorWithComponentExpressions:components]) { + if (NSColor *color = [self mgl_colorWithRGBComponents:components]) { return [NSExpression expressionForConstantValue:color]; } @@ -62,7 +62,7 @@ /** Returns a color object corresponding to the given component expressions. */ -+ (NSColor *)mgl_colorWithComponentExpressions:(NSArray<NSExpression *> *)componentExpressions { ++ (NSColor *)mgl_colorWithRGBComponents:(NSArray<NSExpression *> *)componentExpressions { // Map the component expressions to constant components. If any component is // a non-constant expression, the components cannot be converted into a // constant color value. |