diff options
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 26 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle_Private.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 1e0a2e02b7..8c72c19e42 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -743,6 +743,32 @@ static NSURL *MGLStyleURL_emerald; self.localizedLayersByIdentifier = [NSMutableDictionary dictionary]; } + [self setPreferredContentSize:nil]; +} + +- (void)setPreferredContentSize:(UIContentSizeCategory)preferredContentSize +{ + for (MGLSymbolStyleLayer *layer in self.layers) { + if (![layer isKindOfClass:[MGLSymbolStyleLayer class]]) { + continue; + } + + MGLVectorSource *source = (MGLVectorSource *)[self sourceWithIdentifier:layer.sourceIdentifier]; + if (![source isKindOfClass:[MGLVectorSource class]] || !source.mapboxStreets) { + continue; + } + + if ([layer.textFontSize isKindOfClass:[MGLConstantStyleValue class]]) { + NSNumber *textFontSize = [(MGLConstantStyleValue<NSNumber *> *)layer.textFontSize rawValue]; + textFontSize = [NSNumber numberWithFloat:(textFontSize.floatValue * [self sizeForContentSizeCategory:preferredContentSize])]; + layer.textFontSize = [MGLStyleValue<NSNumber *> valueWithRawValue:textFontSize]; + } + } +} + +- (CGFloat)sizeForContentSizeCategory:(UIContentSizeCategory)preferredContentSize +{ + return 1.3; } @end diff --git a/platform/darwin/src/MGLStyle_Private.h b/platform/darwin/src/MGLStyle_Private.h index 23ce8fbee0..6b96540272 100644 --- a/platform/darwin/src/MGLStyle_Private.h +++ b/platform/darwin/src/MGLStyle_Private.h @@ -1,4 +1,5 @@ #import "MGLStyle.h" +#import <UIKit/UIContentSizeCategory.h> #import "MGLStyleLayer.h" #import "MGLFillStyleLayer.h" @@ -21,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)setStyleClasses:(NS_ARRAY_OF(NSString *) *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration; +- (void)setPreferredContentSize:(UIContentSizeCategory)preferredContentSize; + @end NS_ASSUME_NONNULL_END |