Skip to content

Fix text decoration line thickness regression on Android#57111

Closed
cortinico wants to merge 1 commit into
react:mainfrom
cortinico:export-D107866867
Closed

Fix text decoration line thickness regression on Android#57111
cortinico wants to merge 1 commit into
react:mainfrom
cortinico:export-D107866867

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

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

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
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 8, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Jun 8, 2026
@meta-codesync

meta-codesync Bot commented Jun 8, 2026

Copy link
Copy Markdown

@cortinico has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107866867.

@meta-codesync meta-codesync Bot closed this in 9f20cde Jun 8, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Jun 8, 2026
@meta-codesync

meta-codesync Bot commented Jun 8, 2026

Copy link
Copy Markdown

This pull request has been merged in 9f20cde.

@react-native-bot

Copy link
Copy Markdown
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants