diff --git a/code/frameworks/nextjs/src/font/webpack/loader/local/get-font-face-declarations.ts b/code/frameworks/nextjs/src/font/webpack/loader/local/get-font-face-declarations.ts index daf37993926f..c3db70d9e705 100644 --- a/code/frameworks/nextjs/src/font/webpack/loader/local/get-font-face-declarations.ts +++ b/code/frameworks/nextjs/src/font/webpack/loader/local/get-font-face-declarations.ts @@ -46,6 +46,8 @@ export async function getFontFaceDeclarations( return `@font-face { font-family: ${id}; src: url(.${localFontPath}); + ${weight ? `font-weight: ${weight};` : ''} + ${style ? `font-style: ${style};` : ''} ${fontDeclarations} }`; } diff --git a/code/frameworks/nextjs/src/font/webpack/loader/utils/get-css-meta.ts b/code/frameworks/nextjs/src/font/webpack/loader/utils/get-css-meta.ts index 0fe376d7e152..f12fb1df9a45 100644 --- a/code/frameworks/nextjs/src/font/webpack/loader/utils/get-css-meta.ts +++ b/code/frameworks/nextjs/src/font/webpack/loader/utils/get-css-meta.ts @@ -15,7 +15,11 @@ export function getCSSMeta(options: Options) { .${className} { font-family: ${options.fontFamily}; ${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ''} - ${isNextCSSPropertyValid(options.weights) ? `font-weight: ${options.weights[0]};` : ''} + ${ + isNextCSSPropertyValid(options.weights) && !options.weights[0]?.includes(' ') + ? `font-weight: ${options.weights[0]};` + : '' + } } ${ @@ -39,8 +43,7 @@ export function getCSSMeta(options: Options) { function getClassName({ styles, weights, fontFamily }: Options) { const font = fontFamily.replaceAll(' ', '-').toLowerCase(); const style = isNextCSSPropertyValid(styles) ? styles[0] : null; - const weight = isNextCSSPropertyValid(weights) ? weights[0] : null; - + const weight = isNextCSSPropertyValid(weights) ? weights[0]?.replaceAll(' ', '-') : null; return `${font}${style ? `-${style}` : ''}${weight ? `-${weight}` : ''}`; }