Skip to content

Commit

Permalink
Update font links and add missing error (#41910)
Browse files Browse the repository at this point in the history
Adds an error that was missing. Link to beta until the changes are live.

closes #41900

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
  • Loading branch information
Hannes Bornö committed Oct 27, 2022
1 parent edba939 commit e64bf98
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
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

0 comments on commit e64bf98

Please sign in to comment.