Skip to content

fix(text): account for fontSize when measuring text - #2034

Open
minwookshin wants to merge 1 commit into
airbnb:masterfrom
minwookshin:fix/text-font-size-measurement
Open

minwookshin wants to merge 1 commit into
airbnb:masterfrom
minwookshin:fix/text-font-size-measurement

Conversation

@minwookshin

Copy link
Copy Markdown

Text measures words using style but ignores the fontSize prop, so scaling and wrapping use the wrong widths. Include the effective font size in measurement and memoization, preserve inline-style precedence, and clear a previous measurement size when the prop is removed. Apply relative font sizes only on the text element so values such as 2em do not compound on the wrapper SVG.

Fixes #1737.

Validation: 23 text tests passed, including regressions that failed before the fix. Package typecheck, CJS/ESM builds, and changed-source lint passed. A real Chrome check covered seven size/override/rerender cases; rendered text matched a 100px target within 0.2px.

Measure the effective font size for scaling and wrapping, update measurements on fontSize changes, and apply relative font sizes once instead of compounding them on the wrapper SVG.

Fixes airbnb#1737

This branch has not been deployed

No deployments
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.

Prop scaleToFit on the Text component still overflows

1 participant