Repository navigation
Commit 5c062e6
authored
Position iOS inline views from their line's actual baseline (#59921)
Summary:
Fixes an issue where inline views in text on iOS are not properly positioned from their actual baseline, resulting in situations where the view/image appears lower than expected or with less padding from the previous line.
### Root Cause
After TextKit lays out the text, RCTTextLayoutManager tries to position an inline view's frame on the baseline. It does so by using `glyphRect.origin.y + glyphRect.size.height` to calculate the line bottom, then adding `font.descender` to derive the baseline. However, this fails in two cases. First, when a line only contains an attachment, the baseline should be the line bottom, but the current formula still adds `font.descender` which positions the view too high and clips into the previous line. Second, when `lineHeight` is set, text is lifted by an `NSBaselineOffset` to center it. The current formula fails to account for this offset, so inline views appear placed below the actual text baseline.
### This PR
Modify RCTTextLayoutManager so that instead of manually computing the baseline, we ask TextKit for the baseline used on that line.
Changelog: [iOS][Fixed] - Fix inline views on iOS being misaligned from the baseline
Reviewed By: vzaidman
Differential Revision: D127932169
Pull Request resolved: #599211 parent c2aa91a commit 5c062e6
1 file changed
Lines changed: 6 additions & 9 deletions
File tree
- packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
714 | 711 | | |
715 | 712 | | |
716 | 713 | | |
| |||
0 commit comments