Skip to content

Commit

Permalink
Merge branch 'main' into feature/update-vue-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Nov 20, 2023
2 parents 4a5c2c9 + 750e88a commit cbfae82
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,18 @@ - (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attrib
heightOfTallestSubview:(CGFloat)heightOfTallestSubview
isNestedText:(BOOL)isNestedText {
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString];
if (fabs(_lineHeight - 0) < DBL_EPSILON) {
_lineHeight = fontLineHeight;
BOOL hasSetLineHeight = NO;
if (fabs(self.lineHeight - 0) < DBL_EPSILON) {
// If no fixed lineHeight is set, fontLineHeight is used.
self.lineHeight = fontLineHeight;
} else if (!self.adjustsFontSizeToFit) {
// Only when adjustsFontSizeToFit is not set, the fixed lineHeight can be used.
hasSetLineHeight = YES;
}

// check if we have lineHeight set on self
__block BOOL hasParagraphStyle = NO;
if (_lineHeight || _textAlignSet || 1.f != _lineHeightMultiple) {
if (hasSetLineHeight || _textAlignSet || 1.0 != _lineHeightMultiple) {
hasParagraphStyle = YES;
}

Expand All @@ -644,8 +649,7 @@ - (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attrib
self.lineHeight = newLineHeight;
}

__block CGFloat maximumFontLineHeight = 0;

__block CGFloat maximumFontLineHeight = 0.0;
[textStorage enumerateAttribute:NSFontAttributeName
inRange:NSMakeRange(0, attributedString.length)
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
Expand All @@ -671,7 +675,7 @@ - (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attrib
paragraphStyle.lineHeightMultiple = _lineHeightMultiple;
maxHeight = MAX(maxHeight, maximumFontLineHeight);
paragraphStyle.minimumLineHeight = lineHeight;
paragraphStyle.maximumLineHeight = maxHeight;
paragraphStyle.maximumLineHeight = hasSetLineHeight ? self.lineHeight : maxHeight;
[attributedString addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle
range:(NSRange) { 0, attributedString.length }];
Expand Down

0 comments on commit cbfae82

Please sign in to comment.