Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASTextNode2 to consider both width and height when determining if it is calculating an intrinsic size #1196

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down