-
Notifications
You must be signed in to change notification settings - Fork 16
Fix text shadow cutoff on android #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e10841c to
11ead1c
Compare
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
ff956d7 to
9a5ad54
Compare
Flewp
left a comment
There was a problem hiding this 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.
…yleSpan These getters are not used anywhere in the codebase. Only getShadowRadius() and getShadowDx() are used by getShadowAdjustment().
Summary:
-Changes the shadow style span from a CharacterStyle to a
ReplacementSpanin 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: