Using multiple files for a single local font in Next.js
Figuring this out honestly shouldn’t have taken me this long.
The solution is actually pretty simple: just use the scr prop in localFont to configure different styles and weights like so:
import localFont from "next/font/local";
const roboto = localFont({
src: [
{
path: "./Roboto-Regular.woff2",
weight: "400",
style: "normal",
},
{
path: "./Roboto-Italic.woff2",
weight: "400",
style: "italic",
},
{
path: "./Roboto-Bold.woff2",
weight: "700",
style: "normal",
},
{
path: "./Roboto-BoldItalic.woff2",
weight: "700",
style: "italic",
},
],
});
You can find more details in the official Nextjs Documentation.
87 words