question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow multiple font weights with @next/font

See original GitHub issue

Describe the feature you’d like to request

With a <link> to Google Foots, it is possible to request multiple weights for a single font:

<link
  href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap"
  rel="stylesheet"
/>

It seems like the @next/font, in version 13.0.0, doesn’t allow multiple weights, it takes a single value.

Describe the solution you’d like

Something like this would be great for instance:

export const roboto = Roboto({ display: 'swap', weight: ['400', '700'] })

Describe alternatives you’ve considered

<link> still works in the meantime.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
hanneslundcommented, Nov 1, 2022

Multiple weights and styles are now available in 13.0.1. Docs are being worked on to reflect the latest updates.

// google
const fira = Fira_Code({ weight: ["400", "700"] })

// local files
const inter = localFont({
  src: [
    {
      path: './inter/Inter-Regular.ttf',
      weight: '400',
    },
    {
      path: './inter/Inter-Bold.ttf',
      weight: '700',
    },
  ],
})

3reactions
hanneslundcommented, Oct 27, 2022

If available use a variable font instead. E.g. Roboto Flex.

import { Roboto_Flex } from '@next/font/google'
const roboto = Roboto_Flex({ subsets: ['latin'] })

Support for multiple weights for non variable fonts is coming soon. In the meantime you could use one const per weight.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to optimize custom fonts with @next/font - larsmagnus
When using localFont from @next/font/local you can load multiple font-families or font weights by passing in an array of items to src ....
Read more >
@next/font | Next.js
The font weight with the following possibilities: A string with possible values of the weights available for the specific font or a range...
Read more >
Multiple font-weights, one @font-face query - Stack Overflow
Here's an example using the same font-family name with different styles and weights associated with different fonts:
Read more >
How to use Font Optimization in Nextjs 13? - Medium
To enable font optimization in nextjs, you need to download the @next/font package ... How many fonts are used with the @next/font package?...
Read more >
Font families with multiple font weights (Bold font is less bold ...
Do you want to request a feature or report a bug? Bug What is the current behavior? I am trying to install additional...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found