diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-js-UIExplorerApp.ios/testTextExample_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-js-UIExplorerApp.ios/testTextExample_1@2x.png index 41970dbac17737..cc42c3edc7ab67 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-js-UIExplorerApp.ios/testTextExample_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-js-UIExplorerApp.ios/testTextExample_1@2x.png differ diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index 15f33ddef91430..00abb11fd01a7e 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -339,7 +339,9 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily [self _addAttribute:NSFontAttributeName withValue:font toAttributedString:attributedString]; [self _addAttribute:NSKernAttributeName withValue:letterSpacing toAttributedString:attributedString]; [self _addAttribute:RCTReactTagAttributeName withValue:self.reactTag toAttributedString:attributedString]; - [self _setParagraphStyleOnAttributedString:attributedString heightOfTallestSubview:heightOfTallestSubview]; + [self _setParagraphStyleOnAttributedString:attributedString + fontLineHeight:font.lineHeight + heightOfTallestSubview:heightOfTallestSubview]; // create a non-mutable attributedString for use by the Text system which avoids copies down the line _cachedAttributedString = [[NSAttributedString alloc] initWithAttributedString:attributedString]; @@ -362,6 +364,7 @@ - (void)_addAttribute:(NSString *)attribute withValue:(id)attributeValue toAttri * varying lineHeights, we simply take the max. */ - (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attributedString + fontLineHeight:(CGFloat)fontLineHeight heightOfTallestSubview:(CGFloat)heightOfTallestSubview { // check if we have lineHeight set on self @@ -431,6 +434,12 @@ - (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attrib [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:(NSRange){0, attributedString.length}]; + + if (lineHeight > fontLineHeight) { + [attributedString addAttribute:NSBaselineOffsetAttributeName + value:@(lineHeight / 2 - fontLineHeight / 2) + range:(NSRange){0, attributedString.length}]; + } } // Text decoration