Skip to content

Conversation

janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Mar 19, 2024

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

analysis-bot commented Mar 19, 2024

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
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
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
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
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
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

Hello)
Any updates about this??

@cipolleschi
Copy link
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
Contributor Author

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

@DarkShtir
Copy link

@janicduplessis Any updates??

@conner1reimers
Copy link

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.

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.

7 participants