Skip to content

Fix adjustsFontSizeToFit on new arch#43543

Open
janicduplessis wants to merge 3 commits into
react:mainfrom
janicduplessis:@janic/fix-afstf
Open

Fix adjustsFontSizeToFit on new arch#43543
janicduplessis wants to merge 3 commits into
react:mainfrom
janicduplessis:@janic/fix-afstf

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Mar 19, 2024

Copy link
Copy Markdown
Contributor

Summary:

When using adjustsFontSizeToFit on Fabric the behavior is different from the old renderer. The text will grow bigger than the current font size while on the old renderer it won't. The minimumFontScale is also not implemented. The code currently uses minimumFontSize and maximumFontSize but those props do not actually exist.

This brings the behavior closer to the old renderer by removing the wrong props and implementing minimumFontScale instead. From what I understand in the old renderer it would use the font size of the outermost text, but since we don't easily have access to that in Fabric I use the maximum font size of the attributed string.

Changelog:

[IOS] [FIXED] - Fix adjustsFontSizeToFit on iOS Fabric

Test Plan:

This adds some example of the different behavior in RNTester

  • You can see that on iOS fabric the line It doesn't grow grows bigger than its original font size
  • You can see that on iOS and Android fabric the line Can limit how small the text becomes with minimumFontScale does not respect the minimumFontScale.

Before

Old renderer iOS:

image

Old renderer Android

image

Fabric iOS:

image

Fabric Android

image

After

Fabric iOS:

image

Fabric Android:

image

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Mar 19, 2024
@analysis-bot

analysis-bot commented Mar 19, 2024

Copy link
Copy Markdown
Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 20,365,665 -96,525
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 23,569,723 -90,354
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 51e464f
Branch: main

@janicduplessis

Copy link
Copy Markdown
Contributor Author

@sammy-SC Could you have a look at this?

@janicduplessis janicduplessis changed the title Fix adjustsFontSizeToFit on iOS Fabric Fix adjustsFontSizeToFit on new arch Jun 19, 2024
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 17, 2024
@janicduplessis

Copy link
Copy Markdown
Contributor Author

Can anyone look at this? Pretty sure this is still needed.

@react-native-bot react-native-bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 18, 2024
@cipolleschi

Copy link
Copy Markdown
Contributor

Could you rebase on main and retest on a recent version?
Many things have changed since March... I'd also summon @NickGerleman which has far more context on text than myself.

@janicduplessis

Copy link
Copy Markdown
Contributor Author

Sounds good, I do have a rebased version of this for 0.76 so afaik it might not have changed much since.

@DarkShtir

Copy link
Copy Markdown

Hello)
Any updates about this??

@cipolleschi

Copy link
Copy Markdown
Contributor

@janicduplessis do you mind rebasing this PR? We can't import it the PR is not updated.
Or do you rather abandon this and open a new one, if that's ready?

@janicduplessis

Copy link
Copy Markdown
Contributor Author

Hey @cipolleschi, I am currently on vacation, I will have a look when back to revive this pr.

@DarkShtir

Copy link
Copy Markdown

@janicduplessis Any updates??

@conner1reimers

Copy link
Copy Markdown

Thanks for your work @janicduplessis. I've opened a partial replacement PR that attempts to address the issue of minimumFontScale not being respected on iOS when used with adjustsFontSizeToFit: #54072.

@BasixKOR

Copy link
Copy Markdown

Sorry for the ping but it's been 10 months since the last update and I would appreciate if we could move forward with this PR or supersed this with another one.

@andveloper

Copy link
Copy Markdown

We would also be grateful if this could be resolved 🙏

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. Contributor A React Native contributor. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants