I'm trying to use different fonts for different font weights in ReactJS, but having tried two different import methods in our global stylesheet, I can only load either the first or last imported font.
Is this possible in ReactJS? I've never had a problem using the same sort of method elsewhere.
This only loads the first font:
css.global(
'@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraLight} )`,
fontWeight: 'lighter',
fontStyle: 'normal',
},
'@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraRegular} )`,
fontWeight: 'normal',
fontStyle: 'normal',
},
'@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraMedium} )`,
fontWeight: 'bold',
fontStyle: 'normal',
},
'@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraBold} )`,
fontWeight: 'bolder',
fontStyle: 'normal',
}
);
css.global('html', {
color: '#231e21',
fontFamily: 'ModernEra, sans-serif',
userSelect: 'none',
fontWeight: 'bold',
});
And this only loads the last (I can see why):
css.global('@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraLight} )`,
fontWeight: 'lighter',
fontStyle: 'normal',
});
css.global('@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraRegular} )`,
fontWeight: 'normal',
fontStyle: 'normal',
});
css.global('@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraMedium} )`,
fontWeight: 'bold',
fontStyle: 'normal',
});
css.global('@font-face', {
fontFamily: 'ModernEra',
src: `url( ${ModernEraBold} )`,
fontWeight: 'bolder',
fontStyle: 'normal',
});
css.global('html', {
color: '#231e21',
fontFamily: 'ModernEra, sans-serif',
userSelect: 'none',
fontWeight: 'bold',
});
I'd like to be able to define the font with either 'lighter', 'normal', 'bold' or 'bolder'. Has anyone come up against the same issue, or have a solution?
Thanks.