diff --git a/Source/ASTextNode.mm b/Source/ASTextNode.mm index e2a594b05f..522ebabedd 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -177,6 +177,7 @@ static ASTextKitRenderer *rendererForAttributes(ASTextKitAttributes attributes, NSArray *_exclusionPaths; NSAttributedString *_attributedText; + NSAttributedString *_truncationAttributedText; NSAttributedString *_composedTruncationText; NSString *_highlightedLinkAttributeName; @@ -1189,6 +1190,12 @@ static NSAttributedString *DefaultTruncationAttributedString() return defaultTruncationAttributedString; } +- (NSAttributedString *)truncationAttributedText +{ + ASDN::MutexLocker l(__instanceLock__); + return _truncationAttributedText; +} + - (void)setTruncationAttributedText:(NSAttributedString *)truncationAttributedText { { diff --git a/Tests/ASTextNodeSnapshotTests.m b/Tests/ASTextNodeSnapshotTests.m index 0d86a7274f..c81f5241a3 100644 --- a/Tests/ASTextNodeSnapshotTests.m +++ b/Tests/ASTextNodeSnapshotTests.m @@ -120,4 +120,21 @@ ASSnapshotVerifyNode(textNode, nil); } +/** + * https://github.com/TextureGroup/Texture/issues/822 + */ +- (void)DISABLED_testThatTruncationTokenAttributesPrecedeThoseInheritedFromTextWhenTruncateTailMode +{ + ASTextNode *textNode = [[ASTextNode alloc] init]; + textNode.style.maxSize = CGSizeMake(20, 80); + NSMutableAttributedString *mas = [[NSMutableAttributedString alloc] initWithString:@"Quality is an important "]; + [mas appendAttributedString:[[NSAttributedString alloc] initWithString:@"thing" attributes:@{ NSBackgroundColorAttributeName : UIColor.yellowColor}]]; + textNode.attributedText = mas; + textNode.truncationMode = NSLineBreakByTruncatingTail; + + textNode.truncationAttributedText = [[NSAttributedString alloc] initWithString:@"\u2026" attributes:@{ NSBackgroundColorAttributeName: UIColor.greenColor }]; + ASDisplayNodeSizeToFitSizeRange(textNode, ASSizeRangeMake(CGSizeZero, CGSizeMake(INFINITY, INFINITY))); + ASSnapshotVerifyNode(textNode, nil); +} + @end diff --git a/Tests/ReferenceImages_iOS_10/ASTextNodeSnapshotTests/testThatTruncationTokenAttributesPrecedeThoseInheritedFromTextWhenTruncateTailMode@2x.png b/Tests/ReferenceImages_iOS_10/ASTextNodeSnapshotTests/testThatTruncationTokenAttributesPrecedeThoseInheritedFromTextWhenTruncateTailMode@2x.png new file mode 100644 index 0000000000..40351ad62b Binary files /dev/null and b/Tests/ReferenceImages_iOS_10/ASTextNodeSnapshotTests/testThatTruncationTokenAttributesPrecedeThoseInheritedFromTextWhenTruncateTailMode@2x.png differ