Skip to content

Conversation

@amitkumar-source
Copy link

This PR refactors the font fallback logic in RCTFontUtils.mm to improve code clarity and maintainability. The changes simplify the conditional flow when handling font names that might be font families or specific font names (e.g., "Helvetica Light Oblique" vs "Helvetica").

Changes made:

Removed nested conditional checks and simplified the font fallback logic
Restructured the code to use a cleaner if-else pattern instead of separate conditional blocks
The logic now more clearly shows: if fontNames is empty, try to get font by name; if that fails, fall back to system font; otherwise, proceed with the existing font matching logic
This refactoring maintains the same behavior while making the code easier to read and understand.

Changelog:
[IOS] [CHANGED] - Refactored font fallback logic in RCTFontUtils for improved code clarity

Test Plan:
Existing functionality preserved: All existing font rendering should work exactly as before
Test with font family names: Verify that standard font families like "Helvetica", "Arial" continue to work
Test with specific font names: Verify that specific font names like "Helvetica Light Oblique" are handled correctly
Test fallback behavior: Verify that invalid font names correctly fall back to the system font
Run existing unit tests and integration tests to ensure no regressions
Test on various iOS versions to ensure compatibility
Manual testing:

Create a React Native app with various fontFamily props using both family names and specific font names
Verify text renders correctly in all cases
Verify that invalid font names gracefully fall back to system font without crashes

@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 Jan 7, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 7, 2026
@thomazcapra
Copy link

👀

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

3 participants