Skip to content

Conversation

@insacc
Copy link

@insacc insacc commented Nov 28, 2025

Summary:

-Changes the shadow style span from a CharacterStyle to a ReplacementSpan in order the fix the issue on android where the shadow is cut off even with added padding as the characterStyle doesnt account for the shadow.

This accounts for the shadow but also moves the text back to its original position so on the UI there wouldn't be any shifts when the shadow is applied.

  • Updates the gradient span to make sure that it matches the ios implementation

  • Updates the strokeWidth for the text stroke span to make sure that it matches the ios implementation

Test Plan:

  • Tested locally on android with different states to make sure that it works as expected
Before After
cut-off-v1 cut-off-fixed-v1

@insacc insacc force-pushed the fix/text-shadow-android-cutoff branch from e10841c to 11ead1c Compare December 3, 2025 19:52
Attemp to fix text shadow cutoff

Update the text shadow on android to prevent cutoff

Expand the shadow on if padding is provided

Add the missing import

Add some logging

Make shadow span use padding

Attempt to fix text shadow cutoff on android

Another attempt at fixing the text shadow cutoff

Another attempt at fixing the text shadow cutoff issue on Android.

Add more logging

Add more logs

Add more and more logs

Implement shadow offset compensation in ReactTextView

Make sure to keep the text position stable when the shadow is added.

Update linear gradient span to match iOS behavior.

Address gradient issues

Another attempt to fix the text stroke width

Revert some of the gradient changes

Update shader mode

Update the implementation once more

Revert to width expansion approach - shadow cutoff confirmed without it

Add more logging to the ReactTextView

Remove debug logging

Remove remaining debug logs from text rendering files

Remove unused padding parameters from ShadowStyleSpan

- Remove padding constructor parameters that were never used in getSize() or draw()
- Remove updatePadding() method that was never called
- Remove padding retrieval code from ReactBaseTextShadowNode
- Both old and new architectures now consistently use 4-parameter constructor

Align new arch (Fabric) shadow handling with old arch (Paper)

- Remove shadowTopOffset from PreparedLayoutTextView
- Vertical shadow space is already handled via font metrics adjustment
- Both architectures now only compensate horizontally
- Matches old arch behavior and comment: 'vertical doesn't need compensation'

Remove unused getShadowDy() method and min import

- getShadowDy() was only used for vertical compensation which we removed
- kotlin.math.min import is not used anywhere in the file
@insacc insacc force-pushed the fix/text-shadow-android-cutoff branch from ff956d7 to 9a5ad54 Compare December 5, 2025 22:55
@insacc insacc marked this pull request as ready for review December 5, 2025 22:58
@insacc insacc changed the title Fix/text shadow android cutoff Fix text shadow cutoff on android Dec 5, 2025
@insacc insacc requested a review from Flewp December 5, 2025 23:01
Copy link

@Flewp Flewp left a comment

Choose a reason for hiding this comment

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

Unless we plan on upstreaming this functionality to react-native, I would suggest putting as much of this feature code as possible internally. For example, making ShadowStyleSpan an open class and implementing our own internally, or providing callbacks to shim logic in the fork where the actual business logic exists internally.

These kinds of changes, especially feature + followup style, cause non-trivial overhead when we're trying to bump React Native versions and reapply every single change on top of the new version. They also destabilize features like this over time - if upstream makes API changes or migrates files from Java to Kotlin (I see ReactTextView is still Java), these merges can be error prone.

All being said, if you need to merge as is, go for it. But it would be valuable to refactor to minimize our changes to react native as a fast follow.

@insacc insacc requested a review from Flewp December 9, 2025 00:02
@insacc insacc merged commit 8f42f81 into 0.81.4-discord Dec 9, 2025
53 of 66 checks passed
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.

3 participants