Fix text decoration line thickness regression on Android#57111
Closed
cortinico wants to merge 1 commit into
Closed
Fix text decoration line thickness regression on Android#57111cortinico wants to merge 1 commit into
cortinico wants to merge 1 commit into
Conversation
Summary: D104680895 replaced the native Android `UnderlineSpan`/`StrikethroughSpan` with custom `CanvasEffectSpan` canvas drawing to support `textDecorationStyle`. The custom drawing enforces a minimum stroke thickness of `1.5f * density` (1.5dp), which is noticeably thicker than what the native framework spans produce. This diff removes the 1.5dp minimum for SOLID style so the decoration thickness matches the native `Paint.getUnderlineThickness()` value, restoring the pre-D104680895 visual behavior. The minimum is kept for all other styles (DOUBLE, DOTTED, DASHED, WAVY) since they need the thickness for their visual patterns to render correctly (dash intervals, dot sizes, bezier wavelength). **Remaining work:** the underline position (`baseline + thickness + 1f` in `ReactUnderlineSpan.kt`) also depends on thickness, so with a thinner SOLID stroke the underline sits closer to the text than before D104680895. The pre-D104680895 behavior used the native framework `UnderlineSpan` which positions the underline via `Paint.getUnderlinePosition()`. Attempted using `baseline + paint.underlinePosition + thickness / 2f` and `+ thickness` on API 29+ but neither matched the native positioning exactly. This needs further investigation to match the original vertical gap between text and underline. Differential Revision: D107866867
|
@cortinico has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107866867. |
|
This pull request has been merged in 9f20cde. |
Collaborator
|
This pull request was successfully merged by @cortinico in 9f20cde When will my fix make it into a release? | How to file a pick request? |
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.
Summary:
D104680895 replaced the native Android
UnderlineSpan/StrikethroughSpanwith customCanvasEffectSpancanvas drawing to supporttextDecorationStyle. The custom drawing enforces a minimum stroke thickness of1.5f * density(1.5dp), which is noticeably thicker than what the native framework spans produce.This diff removes the 1.5dp minimum for SOLID style so the decoration thickness matches the native
Paint.getUnderlineThickness()value, restoring the pre-D104680895 visual behavior. The minimum is kept for all other styles (DOUBLE, DOTTED, DASHED, WAVY) since they need the thickness for their visual patterns to render correctly (dash intervals, dot sizes, bezier wavelength).Remaining work: the underline position (
baseline + thickness + 1finReactUnderlineSpan.kt) also depends on thickness, so with a thinner SOLID stroke the underline sits closer to the text than before D104680895. The pre-D104680895 behavior used the native frameworkUnderlineSpanwhich positions the underline viaPaint.getUnderlinePosition(). Attempted usingbaseline + paint.underlinePosition + thickness / 2fand+ thicknesson API 29+ but neither matched the native positioning exactly. This needs further investigation to match the original vertical gap between text and underline.Differential Revision: D107866867