From 75f8a3a237fbda40d923f4bd9dd26c1cb3b370df Mon Sep 17 00:00:00 2001 From: Harry Ng Date: Thu, 19 Sep 2019 12:25:58 +0800 Subject: [PATCH] Fix truncation text style after attributed string is changed Fixed in main repo (aad6e3f): https://github.com/TextureGroup/Texture/pull/1550 --- Source/ASTextNode2.mm | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index 46c49e6e4..c6ccc6e2e 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -164,7 +164,6 @@ @implementation ASTextNode { NSAttributedString *_attributedText; NSAttributedString *_truncationAttributedText; NSAttributedString *_additionalTruncationMessage; - NSAttributedString *_composedTruncationText; NSArray *_pointSizeScaleFactors; NSLineBreakMode _truncationMode; @@ -1232,22 +1231,20 @@ - (NSRange)_additionalTruncationMessageRangeWithVisibleRange:(NSRange)visibleRan - (NSAttributedString *)_locked_composedTruncationText { DISABLED_ASAssertLocked(__instanceLock__); - if (_composedTruncationText == nil) { - if (_truncationAttributedText != nil && _additionalTruncationMessage != nil) { - NSMutableAttributedString *newComposedTruncationString = [[NSMutableAttributedString alloc] initWithAttributedString:_truncationAttributedText]; - [newComposedTruncationString.mutableString appendString:@" "]; - [newComposedTruncationString appendAttributedString:_additionalTruncationMessage]; - _composedTruncationText = newComposedTruncationString; - } else if (_truncationAttributedText != nil) { - _composedTruncationText = _truncationAttributedText; - } else if (_additionalTruncationMessage != nil) { - _composedTruncationText = _additionalTruncationMessage; - } else { - _composedTruncationText = DefaultTruncationAttributedString(); - } - _composedTruncationText = [self _locked_prepareTruncationStringForDrawing:_composedTruncationText]; + NSAttributedString *composedTruncationText = nil; + if (_truncationAttributedText != nil && _additionalTruncationMessage != nil) { + NSMutableAttributedString *newComposedTruncationString = [[NSMutableAttributedString alloc] initWithAttributedString:_truncationAttributedText]; + [newComposedTruncationString.mutableString appendString:@" "]; + [newComposedTruncationString appendAttributedString:_additionalTruncationMessage]; + composedTruncationText = newComposedTruncationString; + } else if (_truncationAttributedText != nil) { + composedTruncationText = _truncationAttributedText; + } else if (_additionalTruncationMessage != nil) { + composedTruncationText = _additionalTruncationMessage; + } else { + composedTruncationText = DefaultTruncationAttributedString(); } - return _composedTruncationText; + return [self _locked_prepareTruncationStringForDrawing:composedTruncationText]; } /**