Fix for iOS text truncation issues on stroked text. - #19
Merged
Conversation
Extract the duplicated RCTTruncatedAttributedStringForStroke helper out of
RCTTextView.mm and RCTTextLayoutManager.mm into a single shared unit in
React-Core (React/Base/RCTTextStroke.{h,mm}), which both the legacy
(React-RCTText) and Fabric (React-FabricComponents) text pods depend on.
Also document that the helper only supports tail truncation (the mode used
by stroke effects); clip returns the string unchanged and head/middle would
need mode-specific ellipsis placement.
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 88efe6b)
(cherry picked from commit 6837fe7)
andrewkunkel
force-pushed
the
akunkel/ios-truncation
branch
from
July 31, 2026 22:21
66ec16f to
2db533f
Compare
andrewkunkel
marked this pull request as ready for review
August 3, 2026 16:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://app.asana.com/1/236888843494340/project/1210546020714549/task/1216428483548702
Before (Android -> iOS)
After (Android -> iOS)
Tested this for all effects on iOS, and on multiple nameplate surfaces (You Bar, edit preview, member list).
In Claude's words:
Summary
Fixes iOS text truncation being dropped entirely when a text stroke is applied, on Fabric.
Our fork renders stroked text (
RCTTextStrokeWidth/RCTTextStrokeColor) through atwo-pass Core Text path in
RCTTextLayoutManager— pass 1 strokes the outline withkCGTextStroke, pass 2 fills on top — instead of the usualNSLayoutManager drawGlyphsForGlyphRange:. That path was handingCTFramesetterCreateFramethe entire
textStorage.The problem
Core Text does its own line breaking and ignores the
NSTextContainer'smaximumNumberOfLinesand truncatinglineBreakMode. TextKit had already measured and laidout the text under the line limit, truncating the tail and drawing an ellipsis, and the draw
frameis sized to that clamped layout. Core Text, given the full string and a path rect offrame.size, re-wrapped the overflowing trailing word onto a line that does not fit insidethat clamped rect — so it dropped the word completely, and Core Text draws no ellipsis of its
own.
The visible result:
numberOfLines-limited text that should render asvisible prefix…insteadlost its last word with no ellipsis, but only when a stroke was set. The non-stroke path was
always correct, because it just draws the glyphs NSLayoutManager already laid out and truncated.
The fix
Added
getTruncatedAttributedStringForStroke(), which asks TextKit what it actually madevisible and rebuilds a string Core Text renders identically. Both Core Text passes now use that
string, and the stroke pass applies the stroke color over the rebuilt string's range rather than
the original character range (the rebuilt string has a different length).