-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix font display on Android #5776
Conversation
|
src/alf/fonts.ts
Outdated
export function DO_NOT_USE() { | ||
return useFonts({ | ||
InterVariable: require('../../assets/fonts/inter/InterVariable.ttf'), | ||
'InterVariable-Italic': require('../../assets/fonts/inter/InterVariable-Italic.ttf'), | ||
}) | ||
return useFonts( | ||
isAndroid | ||
? { | ||
'Inter-Regular': require('../../assets/fonts/inter/Inter-Regular.otf'), | ||
'Inter-Italic': require('../../assets/fonts/inter/Inter-Italic.otf'), | ||
'Inter-Bold': require('../../assets/fonts/inter/Inter-SemiBold.otf'), | ||
'Inter-BoldItalic': require('../../assets/fonts/inter/Inter-SemiBoldItalic.otf'), | ||
'Inter-Black': require('../../assets/fonts/inter/Inter-ExtraBold.otf'), | ||
'Inter-BlackItalic': require('../../assets/fonts/inter/Inter-ExtraBoldItalic.otf'), | ||
} | ||
: { | ||
InterVariable: require('../../assets/fonts/inter/InterVariable.ttf'), | ||
'InterVariable-Italic': require('../../assets/fonts/inter/InterVariable-Italic.ttf'), | ||
}, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we platform split this? Pretty sure this will bloat our bundle sizes on web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Yeah the bot here was reporting totally assets, but those fonts wouldn't have actually loaded. Much better now though, thanks for the bump 👍
60bccd2
to
e72171d
Compare
After a thorough investigation and a few hints here and there like this one, it would appear that RN for Android doesn't support
fontWeight
orfontStyle
for custom fonts, and so in turn does not support variable fonts.So the solve for this is to load separate font files for Android-only, and map weights and styles to the separate font files.
Android still appears to be using alternate glyphs for some characters, such as lowercase
a
(it's usinga.1
), but I haven't been able to determine how to turn those off on Android, and iOS and web still work correctly. So maybe that's an investigation for another time, since this seems to work fine otherwise and Inter technically supports these character alternates i.e. this shouldn't break anything afaik.