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

fix: Improve text line height calculation to properly align text on iOS #46884

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f998a9a
improve text line height calculation on ios
ArekChr Oct 8, 2024
8168cf0
add comments
ArekChr Oct 9, 2024
164bf0c
add safeguards to prevent out-of-bounds crash when accessing text att…
ArekChr Oct 9, 2024
f79a614
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 9, 2024
b044af9
codegen feature flags
ArekChr Oct 9, 2024
4844731
Fix namespace for ReactNativeFeatureFlags in RCTTextView
ArekChr Oct 9, 2024
76faa56
refactor: separate feature flat per platform
ArekChr Oct 11, 2024
9e5ed70
fix: add React-featureflags pod for dynamic frameworks configuration
ArekChr Oct 11, 2024
09118be
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 14, 2024
193d804
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 16, 2024
a41f8c8
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 17, 2024
2ec676c
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 21, 2024
848e4b2
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 22, 2024
045ced9
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 28, 2024
c46a96f
update feature flags
ArekChr Oct 28, 2024
d4e44de
fix: feature flag import in rn-tester dynamic frameworks
ArekChr Oct 30, 2024
b950279
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Oct 30, 2024
3610212
fix: update feature flags
ArekChr Oct 30, 2024
ffc5503
Merge remote-tracking branch 'upstream/main' into improve-lineheight-…
ArekChr Nov 18, 2024
7fd5214
Merge remote-tracking branch 'upstream/main' into improve-lineheight-…
ArekChr Dec 17, 2024
4e35916
fix: add missing expectedReleaseValue to feature flags config
ArekChr Dec 17, 2024
81e560b
refactor: remove unused flag on android
ArekChr Dec 17, 2024
a52fb88
Merge remote-tracking branch 'upstream/main' into improve-lineheight-…
ArekChr Dec 20, 2024
3a13ddf
Merge branch 'main' into improve-lineheight-calc-ios
ArekChr Jan 7, 2025
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
48 changes: 46 additions & 2 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#import <React/RCTUtils.h>
#import <React/UIView+React.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>

Check failure on line 14 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester_dynamic_frameworks (JSC)

'react/featureflags/ReactNativeFeatureFlags.h' file not found

Check failure on line 14 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester_dynamic_frameworks (Hermes)

'react/featureflags/ReactNativeFeatureFlags.h' file not found

#import <React/RCTTextShadowView.h>

Expand Down Expand Up @@ -98,6 +99,42 @@
[self setNeedsDisplay];
}

- (CGPoint)calculateDrawingPointWithTextStorage:(NSTextStorage *)textStorage
contentFrame:(CGRect)contentFrame {
if ([textStorage length] == 0) {
return contentFrame.origin;
}

UIFont *font = [textStorage attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL];
if (!font) {
font = [UIFont systemFontOfSize:14];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn’t find systemFontSize used anywhere else in the repo, and the default font size of 14 has been hardcoded. Also, since systemFontSize is not available on tvOS, I’m not sure if it would be a suitable replacement. Let me know your thoughts on whether we should stick with the hardcoded value for consistency or if there’s a preferred approach.

}

NSParagraphStyle *paragraphStyle = [textStorage attribute:NSParagraphStyleAttributeName atIndex:0 effectiveRange:NULL];

CGFloat lineHeight = font.lineHeight;
if (paragraphStyle && paragraphStyle.minimumLineHeight > 0) {
lineHeight = paragraphStyle.minimumLineHeight;
}

CGFloat ascent = font.ascender;
CGFloat descent = fabs(font.descender);
CGFloat textHeight = ascent + descent;

CGFloat verticalOffset = 0;
// Adjust vertical offset to ensure text is vertically centered relative to the line height.
// Positive offset when text height exceeds line height, negative when line height exceeds text height.
if (textHeight > lineHeight) {
CGFloat difference = textHeight - lineHeight;
verticalOffset = difference / 2.0;
} else if (textHeight < lineHeight) {
CGFloat difference = lineHeight - textHeight;
verticalOffset = -(difference / 2.0);
}

return CGPointMake(contentFrame.origin.x, contentFrame.origin.y + verticalOffset);
}

- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
Expand All @@ -118,8 +155,15 @@
#endif

NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:_contentFrame.origin];
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:_contentFrame.origin];

if (ReactNativeFeatureFlags::enableLineHeightCentering()) {

Check failure on line 159 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (Hermes, OldArch)

use of undeclared identifier 'ReactNativeFeatureFlags'; did you mean 'facebook::react::ReactNativeFeatureFlags'?

Check failure on line 159 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (Hermes, NewArch)

use of undeclared identifier 'ReactNativeFeatureFlags'; did you mean 'facebook::react::ReactNativeFeatureFlags'?

Check failure on line 159 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester_ruby_3_2_0

use of undeclared identifier 'ReactNativeFeatureFlags'; did you mean 'facebook::react::ReactNativeFeatureFlags'?

Check failure on line 159 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (JSC, OldArch)

use of undeclared identifier 'ReactNativeFeatureFlags'; did you mean 'facebook::react::ReactNativeFeatureFlags'?

Check failure on line 159 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (JSC, NewArch)

use of undeclared identifier 'ReactNativeFeatureFlags'; did you mean 'facebook::react::ReactNativeFeatureFlags'?
CGPoint drawingPoint = [self calculateDrawingPointWithTextStorage:_textStorage contentFrame:_contentFrame];
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:drawingPoint];
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:drawingPoint];
} else {
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:_contentFrame.origin];
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:_contentFrame.origin];
}

__block UIBezierPath *highlightPath = nil;
NSRange characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
Expand Down Expand Up @@ -282,10 +326,10 @@
error:nil];

if (rtf) {
[item setObject:rtf forKey:(id)kUTTypeFlatRTFD];

Check warning on line 329 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (Hermes, OldArch)

'kUTTypeFlatRTFD' is deprecated: first deprecated in iOS 15.0 - Use UTTypeFlatRTFD or UTType.flatRTFD (swift) instead. [-Wdeprecated-declarations]

Check warning on line 329 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (Hermes, NewArch)

'kUTTypeFlatRTFD' is deprecated: first deprecated in iOS 15.0 - Use UTTypeFlatRTFD or UTType.flatRTFD (swift) instead. [-Wdeprecated-declarations]

Check warning on line 329 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester_ruby_3_2_0

'kUTTypeFlatRTFD' is deprecated: first deprecated in iOS 15.0 - Use UTTypeFlatRTFD or UTType.flatRTFD (swift) instead. [-Wdeprecated-declarations]

Check warning on line 329 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (JSC, OldArch)

'kUTTypeFlatRTFD' is deprecated: first deprecated in iOS 15.0 - Use UTTypeFlatRTFD or UTType.flatRTFD (swift) instead. [-Wdeprecated-declarations]

Check warning on line 329 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (JSC, NewArch)

'kUTTypeFlatRTFD' is deprecated: first deprecated in iOS 15.0 - Use UTTypeFlatRTFD or UTType.flatRTFD (swift) instead. [-Wdeprecated-declarations]
}

[item setObject:attributedText.string forKey:(id)kUTTypeUTF8PlainText];

Check warning on line 332 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (Hermes, OldArch)

'kUTTypeUTF8PlainText' is deprecated: first deprecated in iOS 15.0 - Use UTTypeUTF8PlainText or UTType.utf8PlainText (swift) instead. [-Wdeprecated-declarations]

Check warning on line 332 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (Hermes, NewArch)

'kUTTypeUTF8PlainText' is deprecated: first deprecated in iOS 15.0 - Use UTTypeUTF8PlainText or UTType.utf8PlainText (swift) instead. [-Wdeprecated-declarations]

Check warning on line 332 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester_ruby_3_2_0

'kUTTypeUTF8PlainText' is deprecated: first deprecated in iOS 15.0 - Use UTTypeUTF8PlainText or UTType.utf8PlainText (swift) instead. [-Wdeprecated-declarations]

Check warning on line 332 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (JSC, OldArch)

'kUTTypeUTF8PlainText' is deprecated: first deprecated in iOS 15.0 - Use UTTypeUTF8PlainText or UTType.utf8PlainText (swift) instead. [-Wdeprecated-declarations]

Check warning on line 332 in packages/react-native/Libraries/Text/Text/RCTTextView.mm

View workflow job for this annotation

GitHub Actions / test_ios_rntester (JSC, NewArch)

'kUTTypeUTF8PlainText' is deprecated: first deprecated in iOS 15.0 - Use UTTypeUTF8PlainText or UTType.utf8PlainText (swift) instead. [-Wdeprecated-declarations]

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.items = @[ item ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "RCTParagraphComponentAccessibilityProvider.h"

#import <MobileCoreServices/UTCoreTypes.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/renderer/components/text/ParagraphComponentDescriptor.h>
#import <react/renderer/components/text/ParagraphProps.h>
#import <react/renderer/components/text/ParagraphState.h>
Expand Down Expand Up @@ -326,6 +327,40 @@ @implementation RCTParagraphTextView {
CAShapeLayer *_highlightLayer;
}

- (CGRect)calculateCenteredFrameWithAttributedText:(NSAttributedString *)attributedText
frame:(CGRect)frame {
UIFont *font = [attributedText attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL];
if (!font) {
font = [UIFont systemFontOfSize:14];
}

NSParagraphStyle *paragraphStyle = [attributedText attribute:NSParagraphStyleAttributeName atIndex:0 effectiveRange:NULL];
CGFloat lineHeight = font.lineHeight;

if (paragraphStyle && paragraphStyle.minimumLineHeight > 0) {
lineHeight = paragraphStyle.minimumLineHeight;
}

CGFloat ascent = font.ascender;
CGFloat descent = fabs(font.descender);
CGFloat textHeight = ascent + descent;

CGFloat verticalOffset = 0;
// Adjust vertical offset to ensure text is vertically centered relative to the line height.
// Positive offset when text height exceeds line height, negative when line height exceeds text height.
if (textHeight > lineHeight) {
CGFloat difference = textHeight - lineHeight;
verticalOffset = difference / 2.0;
} else if (textHeight < lineHeight) {
CGFloat difference = lineHeight - textHeight;
verticalOffset = -(difference / 2.0);
}

frame.origin.y += verticalOffset;

return frame;
}

- (void)drawRect:(CGRect)rect
{
if (!_state) {
Expand All @@ -343,6 +378,11 @@ - (void)drawRect:(CGRect)rect

CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame());

if (ReactNativeFeatureFlags::enableLineHeightCentering()) {
NSAttributedString *attributedText = RCTNSAttributedStringFromAttributedString(_state->getData().attributedString);
frame = [self calculateCenteredFrameWithAttributedText:attributedText frame:frame];
}

[nativeTextLayoutManager drawAttributedString:_state->getData().attributedString
paragraphAttributes:_paragraphAttributes
frame:frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<405d53cd6aba78616b8690c26a0accad>>
* @generated SignedSource<<8c1e36bc5a0baac0def70ea35dcb9e59>>
*/

/**
Expand Down Expand Up @@ -58,12 +58,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableAlignItemsBaselineOnFabricIOS(): Boolean = accessor.enableAlignItemsBaselineOnFabricIOS()

/**
* When enabled, custom line height calculation will be centered from top to bottom.
*/
@JvmStatic
public fun enableAndroidLineHeightCentering(): Boolean = accessor.enableAndroidLineHeightCentering()

/**
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer.
*/
Expand Down Expand Up @@ -136,6 +130,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableLayoutAnimationsOnIOS(): Boolean = accessor.enableLayoutAnimationsOnIOS()

/**
* When enabled, custom line height calculation will be centered from top to bottom.
*/
@JvmStatic
public fun enableLineHeightCentering(): Boolean = accessor.enableLineHeightCentering()

/**
* Enables the reporting of long tasks through `PerformanceObserver`. Only works if the event loop is enabled.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<84ee754f916b48a7c55ea94e166510c7>>
* @generated SignedSource<<a958631ee6706d85d8cd7e0222873b44>>
*/

/**
Expand All @@ -25,7 +25,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var completeReactInstanceCreationOnBgThreadOnAndroidCache: Boolean? = null
private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null
private var enableAndroidLineHeightCenteringCache: Boolean? = null
private var enableBridgelessArchitectureCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableDeletionOfUnmountedViewsCache: Boolean? = null
Expand All @@ -38,6 +37,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
private var enableLayoutAnimationsOnAndroidCache: Boolean? = null
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
private var enableLineHeightCenteringCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enablePreciseSchedulingForPremountItemsOnAndroidCache: Boolean? = null
Expand Down Expand Up @@ -115,15 +115,6 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

override fun enableAndroidLineHeightCentering(): Boolean {
var cached = enableAndroidLineHeightCenteringCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableAndroidLineHeightCentering()
enableAndroidLineHeightCenteringCache = cached
}
return cached
}

override fun enableBridgelessArchitecture(): Boolean {
var cached = enableBridgelessArchitectureCache
if (cached == null) {
Expand Down Expand Up @@ -232,6 +223,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

override fun enableLineHeightCentering(): Boolean {
var cached = enableLineHeightCenteringCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableLineHeightCentering()
enableLineHeightCenteringCache = cached
}
return cached
}

override fun enableLongTaskAPI(): Boolean {
var cached = enableLongTaskAPICache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<eebeaa749dafac5d49d9d6b356f88817>>
* @generated SignedSource<<fef3e1f705f22d87e84eb406cf9b7805>>
*/

/**
Expand Down Expand Up @@ -38,8 +38,6 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun enableAlignItemsBaselineOnFabricIOS(): Boolean

@DoNotStrip @JvmStatic public external fun enableAndroidLineHeightCentering(): Boolean

@DoNotStrip @JvmStatic public external fun enableBridgelessArchitecture(): Boolean

@DoNotStrip @JvmStatic public external fun enableCleanTextInputYogaNode(): Boolean
Expand All @@ -64,6 +62,8 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun enableLayoutAnimationsOnIOS(): Boolean

@DoNotStrip @JvmStatic public external fun enableLineHeightCentering(): Boolean

@DoNotStrip @JvmStatic public external fun enableLongTaskAPI(): Boolean

@DoNotStrip @JvmStatic public external fun enableMicrotasks(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d44c7d51caea5eaa3074217361959b3a>>
* @generated SignedSource<<624e9e1c096417a3441a091dd74b0641>>
*/

/**
Expand Down Expand Up @@ -33,8 +33,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableAlignItemsBaselineOnFabricIOS(): Boolean = true

override fun enableAndroidLineHeightCentering(): Boolean = false

override fun enableBridgelessArchitecture(): Boolean = false

override fun enableCleanTextInputYogaNode(): Boolean = false
Expand All @@ -59,6 +57,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableLayoutAnimationsOnIOS(): Boolean = true

override fun enableLineHeightCentering(): Boolean = false

override fun enableLongTaskAPI(): Boolean = false

override fun enableMicrotasks(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<4dc2364f5bcd765d7b61dbcab0d9533d>>
* @generated SignedSource<<c6be21a8b82bb3c14f2c83ff0c95d275>>
*/

/**
Expand All @@ -29,7 +29,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var completeReactInstanceCreationOnBgThreadOnAndroidCache: Boolean? = null
private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null
private var enableAndroidLineHeightCenteringCache: Boolean? = null
private var enableBridgelessArchitectureCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableDeletionOfUnmountedViewsCache: Boolean? = null
Expand All @@ -42,6 +41,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
private var enableLayoutAnimationsOnAndroidCache: Boolean? = null
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
private var enableLineHeightCenteringCache: Boolean? = null
private var enableLongTaskAPICache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enablePreciseSchedulingForPremountItemsOnAndroidCache: Boolean? = null
Expand Down Expand Up @@ -124,16 +124,6 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun enableAndroidLineHeightCentering(): Boolean {
var cached = enableAndroidLineHeightCenteringCache
if (cached == null) {
cached = currentProvider.enableAndroidLineHeightCentering()
accessedFeatureFlags.add("enableAndroidLineHeightCentering")
enableAndroidLineHeightCenteringCache = cached
}
return cached
}

override fun enableBridgelessArchitecture(): Boolean {
var cached = enableBridgelessArchitectureCache
if (cached == null) {
Expand Down Expand Up @@ -254,6 +244,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun enableLineHeightCentering(): Boolean {
var cached = enableLineHeightCenteringCache
if (cached == null) {
cached = currentProvider.enableLineHeightCentering()
accessedFeatureFlags.add("enableLineHeightCentering")
enableLineHeightCenteringCache = cached
}
return cached
}

override fun enableLongTaskAPI(): Boolean {
var cached = enableLongTaskAPICache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<193bb7803261004003d9009b44810c2c>>
* @generated SignedSource<<efde0d209c0d923a625dffdc496beace>>
*/

/**
Expand Down Expand Up @@ -33,8 +33,6 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun enableAlignItemsBaselineOnFabricIOS(): Boolean

@DoNotStrip public fun enableAndroidLineHeightCentering(): Boolean

@DoNotStrip public fun enableBridgelessArchitecture(): Boolean

@DoNotStrip public fun enableCleanTextInputYogaNode(): Boolean
Expand All @@ -59,6 +57,8 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun enableLayoutAnimationsOnIOS(): Boolean

@DoNotStrip public fun enableLineHeightCentering(): Boolean

@DoNotStrip public fun enableLongTaskAPI(): Boolean

@DoNotStrip public fun enableMicrotasks(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class CustomLineHeightSpan(height: Float) : LineHeightSpan, ReactSpan {
v: Int,
fm: FontMetricsInt,
) {
if (ReactNativeFeatureFlags.enableAndroidLineHeightCentering()) chooseCenteredHeight(fm)
if (ReactNativeFeatureFlags.enableLineHeightCentering()) chooseCenteredHeight(fm)
else chooseOriginalHeight(fm)
}
}
Loading
Loading