fix: font rendering issues by updating font preloader to preload all custom font files#21199
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| document.fonts.load('italic 400 16px "Geist Regular Italic"'), | ||
| document.fonts.load('italic 500 16px "Geist Medium Italic"'), | ||
| document.fonts.load('italic 700 16px "Geist Bold Italic"'), | ||
| document.fonts.load('400 16px "MM Poly Regular"'), | ||
| document.fonts.load('400 16px "MM Sans Regular"'), | ||
| document.fonts.load('500 16px "MM Sans Medium"'), | ||
| document.fonts.load('700 16px "MM Sans Bold"'), |
There was a problem hiding this comment.
Should we store these strings in a const?
davibroc
left a comment
There was a problem hiding this comment.
I tested the fix and it's looking good now
georgewrmarshall
left a comment
There was a problem hiding this comment.
Nice work! Do we have a planned follow-up to make these changes more maintainable? Defining fontFamily: 'Geist Regular' for each input that isn't working doesn't seem very scalable. Is there a way to set this globally, or should we replace these inputs with design system versions instead? What are your thoughts?
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the FontPreloader to comprehensively preload all custom font files rather than maintaining a manual list of TextVariant enums, improving font rendering consistency and preventing FOIT/FOUT issues across the app.
- Replaces variant-based font preloading with direct font family preloading for all Geist and MM font variations
- Adds explicit font family declarations to input fields for consistent rendering
- Cleans up Input component styles by removing redundant fontWeight and fixing lineHeight formatting
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/core/FontPreloader/FontPreloader.ts | Refactored to preload all 10 custom font families directly instead of using TextVariant mappings |
| app/components/Views/RevealPrivateCredential/styles.ts | Added explicit Geist Regular font family to input styles |
| app/components/Views/MultichainAccounts/PrivateKeyList/styles.ts | Added explicit Geist Regular font family to input styles |
| app/components/Views/EnterPasswordSimple/index.js | Added explicit Geist Regular font family to input styles |
| app/component-library/components/Form/TextField/foundation/Input/Input.styles.ts | Fixed lineHeight formatting and removed redundant fontWeight property |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| span.style.fontFamily = fontFamily; | ||
| span.textContent = 'Font preload test'; | ||
| preloadContainer.appendChild(span); | ||
| }); |
There was a problem hiding this comment.
The web font preloading logic creates DOM elements but doesn't set fontWeight, which may not fully exercise all font variations. Consider adding fontWeight extraction from the fontFamily name (e.g., 'Medium' -> '500', 'Bold' -> '700') to ensure proper font loading.
5bf2017
5bf2017 to
2987622
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
c8c1280
b9cbdc8 to
c8c1280
Compare
| @@ -1,12 +1,155 @@ | |||
| import FontPreloader from '../FontPreloader'; | |||
| import { Platform } from 'react-native'; | |||
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
app/core/FontPreloader/tests/FontPreloader.test.ts:1
- This pattern of adding promisify to mock setTimeout is duplicated across multiple helper functions (lines 27, 50, 305, 373, 404, 427). Consider extracting this into a shared utility function within the test utilities to reduce duplication.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| paddingVertical: Platform.OS === 'ios' ? 2 : 1, | ||
| // Ensure consistent line height for custom font baseline alignment lineHeight: Platform.OS === 'ios' ? 20 : 22, | ||
| // Ensure consistent line height for custom font baseline alignment | ||
| lineHeight: Platform.OS === 'ios' ? 20 : 22, | ||
| fontFamily: getFontFamily(textVariant), |
There was a problem hiding this comment.
The lineHeight values (20 for iOS, 22 for Android) should be documented or extracted as named constants to clarify why different platforms require different values for custom font baseline alignment.
|






Description
This PR improves font rendering consistency across the entire app by enhancing the FontPreloader implementation to prevent font-related rendering issues.
What is the reason for the change?
The existing FontPreloader used a variant-based approach that maintained a manual list of TextVariant enums to preload. This approach was prone to:
What is the improvement/solution?
Refactored the FontPreloader to load all available font files directly instead of maintaining a variant-based list. The new approach:
Changelog
CHANGELOG entry: Improved font rendering consistency by preloading all available font files
Related issues
Fixes: #15115 #19485 #20001
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Refactors FontPreloader to preload all Geist/MM fonts across web/native, standardizes text input typography (adds fontFamily, sets lineHeight, removes fontWeight), and updates tests/snapshots accordingly.
extractFontProperties; improve logging and error handling; return consistent loading promise.fontFamily: 'Geist Regular'inViews/EnterPasswordSimple,Views/RevealPrivateCredential,MultichainAccounts/PrivateKeyList; enforcelineHeightand removefontWeightfrom input styles.fontWeightand addedlineHeight/fontFamily.Written by Cursor Bugbot for commit 1652c65. This will update automatically on new commits. Configure here.