Skip to content
Discussion options

You must be logged in to vote

Been trying this out, I don't really feel comfortable documenting the pattern — as far as I can see, indeed, declarations does the trick:

// app/fonts.ts
import localFont from "next/font/local";

// Both calls write the same font-family, so the browser sees one family.
// Only this one is preloaded.
export const myFont = localFont({
  src: "./fonts/regular.woff2",
  weight: "400",
  variable: "--my-font",
  declarations: [{ prop: "font-family", value: "myFont" }],
});

// Same family, not preloaded. Importing it is enough; you never use its return value.
const myFontDeferred = localFont({
  src: "./fonts/bold.woff2",
  weight: "700",
  preload: false,
  adjustFontFallback: false,
  declar…

Replies: 10 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@stefanprobst
Comment options

@icyJoseph
Comment options

Answer selected by stefanprobst
@stefanprobst
Comment options

@icyJoseph
Comment options

@icyJoseph
Comment options

@stefanprobst
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet