Skip to content

fix(android): Prevent text cut-off by clamping lineHeight to font height#56864

Open
aswinandro wants to merge 1 commit into
facebook:mainfrom
aswinandro:fix-56402/android-text-cutoff-lineheight
Open

fix(android): Prevent text cut-off by clamping lineHeight to font height#56864
aswinandro wants to merge 1 commit into
facebook:mainfrom
aswinandro:fix-56402/android-text-cutoff-lineheight

Conversation

@aswinandro
Copy link
Copy Markdown
Contributor

@aswinandro aswinandro commented May 17, 2026

Summary

On Android 15 & 16, text was being cut off when lineHeight was set smaller than the font’s ascent + descent, due to changes in the platform’s text rendering.
This patch updates CustomLineHeightSpan to always ensure the line box is at least as large as the font’s required height, and sets fm.top/fm.bottom to match the adjusted ascent/descent for all lines.
This prevents descenders and ascenders from being clipped, matching native TextView and web behavior, and does not affect other text features or layouts.
Fixes #56402, #53286, #56402

Changelog:

[Android] [Fixed] - Prevent text cut-off when lineHeight is less than font size by clamping line height to font metrics in CustomLineHeightSpan. This ensures text is never clipped on Android 15 & 16 and matches native TextView/web behavior. Fixes #56402, #53286, 56402

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Test Plan

  • Render text with various combinations of fontSize and lineHeight, including cases where lineHeight < fontSize.
  • Verify that no text is clipped on Android 15 & 16, especially for characters with descenders (e.g., “g”, “y”, “p”).
  • Confirm that text renders correctly on older Android versions and that layouts are unaffected for normal line heights.
  • Run existing text rendering tests and visual regression tests to ensure no regressions.

Example test code:

<Text style={{fontSize: 24, lineHeight: 8, borderWidth: 1, borderColor: 'red'}}>
  gyqp
</Text>

On Android 15 & 16, text was being cut off when lineHeight was set smaller than the font’s ascent + descent, due to changes in the platform’s text rendering.
This patch updates CustomLineHeightSpan to always ensure the line box is at least as large as the font’s required height, and sets fm.top/fm.bottom to match the adjusted ascent/descent for all lines.
This prevents descenders and ascenders from being clipped, matching native TextView and web behavior, and does not affect other text features or layouts.
Fixes facebook#56402, facebook#53286.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 17, 2026
@aswinandro aswinandro closed this May 17, 2026
@aswinandro aswinandro reopened this May 17, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text rendering cut off on Android 15 & 16

1 participant