Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix text baseline being moved up on iOS (#44932)
Summary: Fixes #44929 Moves calling `RCTApplyBaselineOffset` so it's called in similar way as on the old architecture: https://github.com/facebook/react-native/blob/726a4a1e5ef3bc8034a068145da2bb94ae3acfaa/packages/react-native/Libraries/Text/Text/RCTTextShadowView.mm#L229 https://github.com/facebook/react-native/blob/726a4a1e5ef3bc8034a068145da2bb94ae3acfaa/packages/react-native/Libraries/Text/Text/RCTTextShadowView.mm#L165-L167 I'm not exactly sure why (and Apple's docs aren't helping) but it looks like calling `NSTextStorage initWithAttributedString` results in an attributed string where emojis are separate fragments with Apple's emoji font set, which results in the correct baseline calculations. This is the way it happens on the old arch. The way it's currently implemented on the new architecture, `RCTApplyBaselineOffset` is called on ` newly created attributed string where emojis are in the same fragment as other parts of the text which alters the result of baseline calculations compared to what's later drawn on the screen. ## Changelog: [IOS] [FIXED] - Fixed text baseline being moved upwards in certain cases Pull Request resolved: #44932 Test Plan: <details> <summary>Check the following snipped</summary> ```jsx import React from 'react'; import { Text, View, } from 'react-native'; const App = () => { return ( <View style={{ paddingTop: 100, }}> <Text style={{fontSize: 15, lineHeight: 20, fontFamily: 'Arial', backgroundColor: 'gray'}}>A 😞😞😞 B</Text> </View> ); }; export default App; ``` </details> |Before|After| |-|-| |<img width="546" alt="new-broken" src="https://github.com/facebook/react-native/assets/21055725/cc0a3841-beb5-4afc-8abf-1124312fa6e0">|<img width="546" alt="new-fixed" src="https://github.com/facebook/react-native/assets/21055725/0ec2f6f1-3c62-4537-9a75-6abb840633f7">| Reviewed By: cipolleschi Differential Revision: D58589249 Pulled By: sammy-SC fbshipit-source-id: 1e0a730519a5c79ff8a35b0dfb16b68966a8dd9f
- Loading branch information