Skip to content

Fix for iOS text truncation issues on stroked text. - #19

Merged
andrewkunkel merged 4 commits into
0.86.0-discordfrom
akunkel/ios-truncation
Aug 5, 2026
Merged

Fix for iOS text truncation issues on stroked text.#19
andrewkunkel merged 4 commits into
0.86.0-discordfrom
akunkel/ios-truncation

Conversation

@andrewkunkel

@andrewkunkel andrewkunkel commented Jul 22, 2026

Copy link
Copy Markdown

https://app.asana.com/1/236888843494340/project/1210546020714549/task/1216428483548702

Before (Android -> iOS)

image

After (Android -> iOS)

image

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 a
two-pass Core Text path in RCTTextLayoutManager — pass 1 strokes the outline with
kCGTextStroke, pass 2 fills on top — instead of the usual
NSLayoutManager drawGlyphsForGlyphRange:. That path was handing CTFramesetterCreateFrame
the entire textStorage.

The problem

Core Text does its own line breaking and ignores the NSTextContainer's
maximumNumberOfLines and truncating lineBreakMode. TextKit had already measured and laid
out the text under the line limit, truncating the tail and drawing an ellipsis, and the draw
frame is sized to that clamped layout. Core Text, given the full string and a path rect of
frame.size, re-wrapped the overflowing trailing word onto a line that does not fit inside
that 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 as visible prefix… instead
lost 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 made
visible 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).

@andrewkunkel andrewkunkel changed the title Fix for iOS text truncation issues. Fix for iOS text truncation issues. (0.86.0 branch) Jul 23, 2026
andrewkunkel and others added 4 commits July 31, 2026 15:17
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>
@andrewkunkel
andrewkunkel force-pushed the akunkel/ios-truncation branch from 66ec16f to 2db533f Compare July 31, 2026 22:21
@andrewkunkel
andrewkunkel requested a review from insacc August 3, 2026 16:38
@andrewkunkel
andrewkunkel marked this pull request as ready for review August 3, 2026 16:38
@andrewkunkel andrewkunkel changed the title Fix for iOS text truncation issues. (0.86.0 branch) Fix for iOS text truncation issues on stroked text. Aug 4, 2026

@insacc insacc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!!

@andrewkunkel
andrewkunkel merged commit 251d947 into 0.86.0-discord Aug 5, 2026
44 checks passed
@andrewkunkel
andrewkunkel deleted the akunkel/ios-truncation branch August 5, 2026 18:56
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.

2 participants