Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update font links and add missing error #41910

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions errors/google-fonts-missing-subsets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Missing specified subset for a `@next/font/google` font

#### Why This Error Occurred

Preload is enabled for a font that is missing a specified subset.

#### Possible Ways to Fix It

Specify which subsets to preload for that font.

- On a font per font basis by adding it to the function call

```js
const inter = Inter({ subsets: ['latin'] })
```

- Globally for all your fonts

```js
// next.config.js
module.exports = {
experimental: {
fontLoaders: [
{ loader: '@next/font/google', options: { subsets: ['latin'] } },
],
},
}
```

If both are configured, the subset in the function call is used.

### Useful Links

[Specifying a subset](https://beta.nextjs.org/docs/optimizing/fonts#specifying-a-subset)
4 changes: 4 additions & 0 deletions errors/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@
{
"title": "babel-font-loader-conflict",
"path": "/errors/babel-font-loader-conflict.md"
},
{
"title": "google-fonts-missing-subsets",
"path": "/errors/google-fonts-missing-subsets.md"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/font/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

This new font system also allows you to conveniently use all Google Fonts with performance and privacy in mind. CSS and font files are downloaded at build time and self-hosted with the rest of your static assets. No requests are sent to Google by the browser.

[Read more](https://nextjs.org/docs/optimizing/fonts)
[Read more](https://beta.nextjs.org/docs/optimizing/fonts)
2 changes: 1 addition & 1 deletion packages/font/src/google/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const downloadGoogleFonts: FontLoader = async ({
fontFamily
)} has no selected subsets. Please specify subsets in the function call or in your ${chalk.bold(
'next.config.js'
)}, otherwise no fonts will be preloaded. Read more: https://nextjs.org/docs/api-reference/components/font#nextfontgoogle`
)}, otherwise no fonts will be preloaded. Read more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`
)
}

Expand Down