google / google/fonts

Lato font has a bad rendering in NextJS

Open
#8,377 2 comments 0 reactions 0 assignees View on GitHub
-- Needs Eng team opinion I Font Bug
Dominant language
HTML
Stars
20.5k
Forks
2.9k
Avg merge
1d 21h
Merged PRs (30d)
95

Description

I use the _Lato_ font with a font weight 400, on the framework NextJS, with the [font component](https://nextjs.org/docs/pages/api-reference/components/font), and I see a bad rendering of some characters.

Thanks a lot for your help :)

**Describe the bug**

On display, with the specified font-weight, the font isn't rendered correctly. I have tested with Roboto a font like Lato, and I don't have the same problem.

**To Reproduce**

On the _NextJS_ framework, use the _Lato_ font like this, font example in a `src/common/styled/app/base/fontFace.ts` file. By the way, I use _Styled Components_:

```
import { Lato } from 'next/font/google'
import { css } from 'styled-components'

const lato = Lato({
weight: ['400', '700', '900'],
subsets: ['latin'],
variable: '--font-lato',
})

const fontsFace = () => css`
:root {
--font-lato: ${lato.style.fontFamily};
}
`

export default fontsFace
```

After, I use the CSS variable like this:

```
body {
font-family: var(--font-lato);
font-weight: 400;
}
```

**Expected behavior**

Like another fonts, I expect to have a good rendering, and not the bad rendering that you can see on the first 2 screenshots below.

**Screenshots**

![Image](https://github.com/user-attachments/assets/e133f3d0-5ce3-412e-a952-044de58a32c0)
![Image](https://github.com/user-attachments/assets/29f9d881-1b27-4e8d-98f3-88b00e523970)

Test with the _Roboto_ font with `font-weight: 400`:
![Image](https://github.com/user-attachments/assets/4192e8c8-8740-4d19-8235-1254a86c1fe3)
![Image](https://github.com/user-attachments/assets/da83d73c-3565-4666-bb10-57c1670915a3)

**Additional context**

Windows 10, Chrome 129.0.6668.101, Firefox 128.3.1esr (64 bits)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.