From 64bcd95c0aaf307460587f1458b11c724ccf5cd5 Mon Sep 17 00:00:00 2001 From: ernestmama <43187788+ernestmama@users.noreply.github.com> Date: Wed, 31 Oct 2018 17:06:48 -0700 Subject: [PATCH] ASTextNode2 to consider both width and height when determining if it is calculating an instrinsic size (#1196) --- Source/ASTextNode2.mm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index b0c39bd58..9feb18afd 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -340,12 +340,9 @@ - (CGSize)calculateSizeThatFits:(CGSize)constrainedSize [self _ensureTruncationText]; // If the constrained size has a max/inf value on the text's forward direction, the text node is calculating its intrinsic size. - BOOL isCalculatingIntrinsicSize; - if (_textContainer.isVerticalForm) { - isCalculatingIntrinsicSize = (_textContainer.size.height >= ASTextContainerMaxSize.height); - } else { - isCalculatingIntrinsicSize = (_textContainer.size.width >= ASTextContainerMaxSize.width); - } + // Need to consider both width and height when determining if it is calculating instrinsic size. Even the constrained width is provided, the height can be inf + // it may provide a text that is longer than the width and require a wordWrapping line break mode and looking for the height to be calculated. + BOOL isCalculatingIntrinsicSize = (_textContainer.size.width >= ASTextContainerMaxSize.width) || (_textContainer.size.height >= ASTextContainerMaxSize.height); NSMutableAttributedString *mutableText = [_attributedText mutableCopy]; [self prepareAttributedString:mutableText isForIntrinsicSize:isCalculatingIntrinsicSize];