Unverified Commit 5e4a54ea authored by Ethan (Taehoon) Lee's avatar Ethan (Taehoon) Lee Committed by GitHub

docs(localFont): enhance details about using the localFont function (#88189)

### What?
Enhance the documentation about how to use the `localFont` function.

### Why?
The Next.js documentation about [local
fonts](https://nextjs.org/docs/app/getting-started/fonts#local-fonts)
has insufficient information about where to store the font files and how
to reference them with the `localFont` function. The lack of detail
causes confusion like this issue:
https://github.com/vercel/next.js/issues/76573.

### How?
I created a [demo](https://nextjs-localfont-demo.vercel.app/) to
investigate the behavior of the `localFont` function (source:
https://github.com/ethn1ee/nextjs-localfont-demo). I confirmed that the
font files can be located anywhere inside the project, including at
root, the `src` directory, the `app` directory, and the `public`
directory, and that they must all be referenced using relative paths.

Fixes #76573

---------
Co-authored-by: 's avatarEthan Lee <48551278+ethn1ee@users.noreply.github.com>
Co-authored-by: 's avatarJoseph <sephxd1234@gmail.com>
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 762bff65
...@@ -305,7 +305,7 @@ export default function MyApp({ Component, pageProps }) { ...@@ -305,7 +305,7 @@ export default function MyApp({ Component, pageProps }) {
<AppOnly> <AppOnly>
To use a local font, import your font from `next/font/local` and specify the [`src`](/docs/app/api-reference/components/font#src) of your local font file. Fonts can be stored in the [`public`](/docs/app/api-reference/file-conventions/public-folder) folder or co-located inside the `app` folder. For example: To use a local font, import the `localFont` function from `next/font/local` and specify the [`src`](/docs/app/api-reference/components/font#src) of your local font file. The path is resolved relative to the file where `localFont` is called. Fonts can be stored anywhere in the project, including the [`public`](/docs/app/api-reference/file-conventions/public-folder) folder or co-located inside the `app` folder. For example, to use a font stored in `app/fonts/`:
```tsx filename="app/layout.tsx" switcher ```tsx filename="app/layout.tsx" switcher
import localFont from 'next/font/local' import localFont from 'next/font/local'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment