I'm attempting to implement the "next" method for adding fonts, but I find the process described quite complex just to preload a font.
I experimented with exporting a function to create the font and then using a variable tag to generate a CSS variable. However, this approach was unsuccessful even after importing the font into my page.js file. I exported a constant function to create the font with the variable:
import { Oxygen } from "next/font/google";
export const oxygen = Oxygen({
display: 'swap',
variable: '--font-oxygen',
subsets: ['latin'],
})
Subsequently, I attempted to apply it in the linked CSS style sheet by setting the font family to the precise variable like so:
font-family: var(--font-oxygen);
My exploration of Nextjs is becoming discouraging due to this issue. The font doesn't seem to load properly, and I am hesitant to assign the class name of my HTML attributes to the font's class name unless I am misunderstanding something.