Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
adjustsFontSizeToFit
for strings with a single character (#47082)
Summary: Fixes #47045 On Android `adjustsFontSizeToFit` relies on two metrics: - Text with line breaks results in more lines than `maximumNumberOfLines` - The overall height of the text is larger than the available height None of these two was fulfilled when a single-character string had a higher width than the available one (a single character will not be broken into multiple lines). This PR adds exactly that as a third option to trigger the scaling algorithm - a single-character string that has a higher width than the available one. On iOS `adjustsFontSizeToFit` relies on `truncatedGlyphRangeInLineFragmentForGlyphAtIndex` which seems to be returning `NSNotFound` when a single-character sting gets truncated. Similarly to Android, this PR adds an additional check to make sure that single-character strings actually fit inside the container. ## Changelog: [GENERAL] [FIXED] - Fixed `adjustsFontSizeToFit` not working for text with a single character Pull Request resolved: #47082 Test Plan: Tested on the code from the issue: |Android (old arch)|Android (new arch)|iOS (old arch)|iOS (new arch)| |-|-|-|-| |<img width="406" alt="android_old" src="https://github.com/user-attachments/assets/91b1af41-4ef7-46cc-bb04-374f860d93ac">|<img width="406" alt="android_new" src="https://github.com/user-attachments/assets/90e3cde1-e6c0-4b25-8325-c62a37773002">|<img width="546" alt="ios_old" src="https://github.com/user-attachments/assets/902b9c10-84e0-4372-bcc8-07cd1ef006f6">|<img width="546" alt="ios_new" src="https://github.com/user-attachments/assets/f4df4f0e-7649-47f3-9c81-e38f8665d9a2">| Reviewed By: javache Differential Revision: D64664351 Pulled By: NickGerleman fbshipit-source-id: b68f318a0fbd5ebed947a70d1e3fb0515b5fb409
- Loading branch information