Skip to content

fix: disable usesFontLeading on UITextView's layoutManager#45

Draft
haileyok wants to merge 1 commit into
mainfrom
worktree-fix-cutoff-custom-font
Draft

fix: disable usesFontLeading on UITextView's layoutManager#45
haileyok wants to merge 1 commit into
mainfrom
worktree-fix-cutoff-custom-font

Conversation

@haileyok
Copy link
Copy Markdown
Member

@haileyok haileyok commented May 9, 2026

Summary

Fixes #42.

RCTTextLayoutManager — which the shadow node calls in measureContent to size the view — measures with usesFontLeading = NO. UITextView's NSLayoutManager defaults to usesFontLeading = YES. When a custom font with non-zero natural leading is used, UITextView renders each line slightly taller than RN measured. The shortfall accumulates over many lines and the last line(s) of the paragraph fall outside the view's clip bounds.

The fix is one line: explicitly set usesFontLeading = NO on the textView's layout manager so rendering matches measurement.

System fonts have ~zero leading, which is why the bug doesn't show up without a custom fontFamily.

Test plan

  • Run the example app on a device with a bundled custom font (e.g. Inter, Roboto) and verify a long paragraph using <UITextView selectable uiTextView style={{fontFamily: 'Inter'}}> is no longer cut off at the bottom.
  • Verify selection, press, and onTextLayout still work.
  • Verify the numberOfLines truncation cases in the example app are unchanged.
  • Verify default (system font) text still lays out the same.

🤖 Generated with Claude Code

UITextView's NSLayoutManager defaults to usesFontLeading = YES, while
RCTTextLayoutManager (used in measureContent) measures with NO. Custom
fonts with non-zero leading then render taller per line than RN
measured, accumulating into bottom-of-view cutoff for paragraphs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content gets cut off when using selectable and a custom FontFamily

1 participant