diff --git a/Libraries/Text/Text/RCTTextShadowView.m b/Libraries/Text/Text/RCTTextShadowView.m index 0024adcf57ba5c..850879aa4f9ae7 100644 --- a/Libraries/Text/Text/RCTTextShadowView.m +++ b/Libraries/Text/Text/RCTTextShadowView.m @@ -133,7 +133,7 @@ - (void)postprocessAttributedText:(NSMutableAttributedString *)attributedText return; } - [attributedText beginEditing]; + __block CGFloat maximumFontLineHeight = 0; [attributedText enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, attributedText.length) @@ -144,19 +144,21 @@ - (void)postprocessAttributedText:(NSMutableAttributedString *)attributedText return; } - if (maximumLineHeight <= font.lineHeight) { - return; + if (maximumFontLineHeight <= font.lineHeight) { + maximumFontLineHeight = font.lineHeight; } + } + ]; - CGFloat baseLineOffset = maximumLineHeight / 2.0 - font.lineHeight / 2.0; + if (maximumLineHeight < maximumFontLineHeight) { + return; + } - [attributedText addAttribute:NSBaselineOffsetAttributeName - value:@(baseLineOffset) - range:range]; - } - ]; + CGFloat baseLineOffset = maximumLineHeight / 2.0 - maximumFontLineHeight / 2.0; - [attributedText endEditing]; + [attributedText addAttribute:NSBaselineOffsetAttributeName + value:@(baseLineOffset) + range:NSMakeRange(0, attributedText.length)]; } - (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize:(CGSize)size