diff --git a/AsyncDisplayKit/ASTextNode+Beta.h b/AsyncDisplayKit/ASTextNode+Beta.h index b4d3b88982..38059aa7c3 100644 --- a/AsyncDisplayKit/ASTextNode+Beta.h +++ b/AsyncDisplayKit/ASTextNode+Beta.h @@ -15,9 +15,4 @@ */ @property (nonatomic, copy) NSArray *pointSizeScaleFactors; -/** - @abstract The currently applied scale factor, or 0 if the text node is not being scaled. - */ -@property (nonatomic, assign, readonly) CGFloat currentScaleFactor; - @end \ No newline at end of file diff --git a/AsyncDisplayKit/ASTextNode.mm b/AsyncDisplayKit/ASTextNode.mm index 3cc4e7ccbd..118e22a3cb 100644 --- a/AsyncDisplayKit/ASTextNode.mm +++ b/AsyncDisplayKit/ASTextNode.mm @@ -244,7 +244,6 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; .maximumNumberOfLines = _maximumNumberOfLines, .exclusionPaths = _exclusionPaths, .pointSizeScaleFactors = _pointSizeScaleFactors, - .currentScaleFactor = self.currentScaleFactor, .layoutManagerCreationBlock = self.layoutManagerCreationBlock, .textStorageCreationBlock = self.textStorageCreationBlock, }; @@ -338,10 +337,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; [self setNeedsDisplay]; - CGSize size = [[self _renderer] size]; - // the renderer computes the current scale factor during sizing, so let's grab it here - _currentScaleFactor = _renderer.currentScaleFactor; - return size; + return [[self _renderer] size]; } #pragma mark - Modifying User Text @@ -380,8 +376,6 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; self.isAccessibilityElement = YES; } - // reset the scale factor if we get a new string. - _currentScaleFactor = 0; if (attributedString.length > 0) { CGFloat screenScale = ASScreenScale(); self.ascender = round([[attributedString attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL] ascender] * screenScale)/screenScale; diff --git a/AsyncDisplayKit/TextKit/ASTextKitAttributes.h b/AsyncDisplayKit/TextKit/ASTextKitAttributes.h index fab9cdf7cc..b765deaca1 100755 --- a/AsyncDisplayKit/TextKit/ASTextKitAttributes.h +++ b/AsyncDisplayKit/TextKit/ASTextKitAttributes.h @@ -86,10 +86,6 @@ struct ASTextKitAttributes { An array of scale factors in descending order to apply to the text to try to make it fit into a constrained size. */ NSArray *pointSizeScaleFactors; - /** - The currently applied scale factor. Only valid if pointSizeScaleFactors are provided. Defaults to 0 (no scaling) - */ - CGFloat currentScaleFactor; /** An optional block that returns a custom layout manager subclass. If nil, defaults to NSLayoutManager. */ @@ -123,7 +119,6 @@ struct ASTextKitAttributes { shadowOpacity, shadowRadius, pointSizeScaleFactors, - currentScaleFactor, layoutManagerCreationBlock, layoutManagerDelegate, textStorageCreationBlock, @@ -138,7 +133,6 @@ struct ASTextKitAttributes { && shadowOpacity == other.shadowOpacity && shadowRadius == other.shadowRadius && [pointSizeScaleFactors isEqualToArray:other.pointSizeScaleFactors] - && currentScaleFactor == currentScaleFactor && layoutManagerCreationBlock == other.layoutManagerCreationBlock && textStorageCreationBlock == other.textStorageCreationBlock && CGSizeEqualToSize(shadowOffset, other.shadowOffset) diff --git a/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm b/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm index 5ad0e302d3..8bbe70ae2b 100755 --- a/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm +++ b/AsyncDisplayKit/TextKit/ASTextKitRenderer.mm @@ -49,9 +49,6 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet() _constrainedSize = constrainedSize; _attributes = attributes; _sizeIsCalculated = NO; - if ([attributes.pointSizeScaleFactors count] > 0) { - _currentScaleFactor = attributes.currentScaleFactor; - } } return self; } @@ -141,7 +138,8 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet() - (void)_calculateSize { [self truncater]; - if ([_attributes.pointSizeScaleFactors count] > 0) { + // if we have no scale factors or an unconstrained width, there is no reason to try to adjust the font size + if ([_attributes.pointSizeScaleFactors count] > 0 && isinf(_constrainedSize.width) == NO) { _currentScaleFactor = [[self fontSizeAdjuster] scaleFactor]; } @@ -174,6 +172,11 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet() { // We add an assertion so we can track the rare conditions where a graphics context is not present ASDisplayNodeAssertNotNil(context, @"This is no good without a context."); + + // This renderer may not be the one that did the sizing. If that is the case its _currentScaleFactor will not be set, so we should compute it now + if ([_attributes.pointSizeScaleFactors count] > 0 && isinf(_constrainedSize.width) == NO && _sizeIsCalculated == NO) { + _currentScaleFactor = [[self fontSizeAdjuster] scaleFactor]; + } CGRect shadowInsetBounds = [[self shadower] insetRectWithConstrainedRect:bounds];