-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
custom font weight not working #4307
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
Comments
Hey there, I had the same problem some weeks ago, installing the individual font families fixed this for me. I also had to remove 'fontWeight' property from all of my fonts' config. Example code below:
This way I set the fontWeight using the specific fontFamily I installed. I also tried using some variable fonts but it seems those aren't compatible yet. So I'd try removing fontWeight from your fonts' config, and setting it just with fontFamily. Here's another useful issue you could check: facebook/react-native#42116 |
thanks for your response.. i tried removing fontWeight but somehow its still not working .. |
Only other thing is I noticed you're importing |
My solution: create customs properties: /**
* @description Estilos base para los textos
*/
const fontWeights = {
light: '300',
normal: '400',
medium: '500',
bold: '700',
} as const;
const fontBold = {
fontFamily: 'Roboto-Bold',
fontWeight: fontWeights.bold,
};
const fontMedium = {
fontFamily: 'Roboto-Medium',
fontWeight: fontWeights.medium,
};
const fontRegular = {
fontFamily: 'Roboto',
fontWeight: fontWeights.normal,
};
const fontLight = {
fontFamily: 'Roboto-Light',
fontWeight: fontWeights.light,
};
const fontConfig = {
fontFamily: 'Roboto',
};
export default {
fontBold,
fontLight,
fontMedium,
fontConfig,
fontWeights,
fontRegular,
}; My config to export to the provider const theme = {
...DefaultTheme,
...light,
fonts: configureFonts({config: fonts.fontConfig}),
}; Usage in Stylesheet title: {
marginTop: 32,
marginBottom: 16,
...fonts.fontMedium, // <--- Trick
}, |
I am trying to install custom fonts to a react native paper theme. Looked at the example mentioned on #3325 on the snack expo https://snack.expo.dev/@react-native-paper/font-styles-variants
i have implemented the below code after which the components picks up the fontFamily but the fontWeight does not change unless I specify the font family in the StyleSheet.
Can someone suggest what is wrong here.
The text was updated successfully, but these errors were encountered: