Skip to content

Commit

Permalink
ASTextNode2 to consider both width and height when determining if it …
Browse files Browse the repository at this point in the history
…is calculating an instrinsic size (#1196)
  • Loading branch information
ernestmama authored and nguyenhuy committed Nov 1, 2018
1 parent 393ca81 commit 4b46df3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,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];
Expand Down

0 comments on commit 4b46df3

Please sign in to comment.