-
Notifications
You must be signed in to change notification settings - Fork 11
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
Local fonts with multiple weights but same name #22
Comments
Have you tried creating |
Thanks Dan. Yeah I did, unfortunately it wasn't picked up in the way above |
Someone also reports an issue on discord with the following config: const fontPrefix = '/fonts/montserrat-font/Montserrat';
export default defineNuxtConfig({
devtools: { enabled: true },
modules: [
'@nuxt/image',
"@nuxt/fonts"
],
image: {
quality: 80,
format: ['webp']
},
fonts: {
families: [
{ name: 'Montserrat', weight: '900', src: fontPrefix + 'Black.ttf' },
{ name: 'Montserrat', weight: '800', src: fontPrefix + 'ExtraBold.ttf' },
{ name: 'Montserrat', weight: '700', src: fontPrefix + 'Bold.ttf' },
{ name: 'Montserrat', weight: '600', src: fontPrefix + 'SemiBold.ttf' },
{ name: 'Montserrat', weight: '400', src: fontPrefix + 'Regular.ttf' },
{ name: 'Montserrat', weight: '500', src: fontPrefix + 'Medium.ttf' },
{ name: 'Montserrat', weight: '300', src: fontPrefix + 'Light.ttf' },
{ name: 'Montserrat', weight: '200', src: fontPrefix + 'ExtraLight.ttf' },
{ name: 'Montserrat', weight: '100', src: fontPrefix + 'Thin.ttf' },
],
defaults: {
weights: [400],
styles: ['normal']
},
providers: {
google: false,
bunny: false,
fontshare: false,
}
},
}); |
I would expect all of those to be registered, if you have specified all those weights in your options. Are you on the latest version? Can you prepare a reproduction if so? |
Ah okay... so it doesn't auto register? I was under the impression that it would register from scanning our files? So I'll have to do this? #22 (comment) |
It does auto register but by default only 400 weight. You can specify additional weights in |
Worked perfectly! Thank you for your prompt response. Love the work you and your team is doing! ❤️ Waiting with bated breath on nuxt/assets and nuxt/scripts, whenever you're planning on rolling those out! |
I can't see it mentioned in the README how this use case would be handled, so I thought I'd open an issue to get it clarified, then I can submit a PR for the docs.
For font faces that have the same name but multiple font-weights, how would we handle the configuration for this?
E.G.
This has 3 font files for Tenon, but all under the
font-family: 'Tenon'
. Changing thefont-weight
lets the browser choose the right font file automatically.Just wondering how we'd set this up, as well as get the local fallbacks.
Out of the box I just get the 400 weight font files, and no local fallback
The text was updated successfully, but these errors were encountered: