Open GabbereX opened 1 year ago
Same with Google fonts. Tried playing around with the options (preload: true, display: swap) and still happens
display: "block"
fixes this. Swap is meant to behave like you mentioned. I don't know why it is used in all examples as it's stupid and worst ever UX but whatever you prefer.
Basically:
I didn't try other settings of display.
- Swap tells the browser to replace the default font with the said one once it was loaded (jumping around)
Thanks for this. This was driving me crazy. Out of curiosity, do you also use this setting in production?
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Font optimization (next/font)
Link to the code that reproduces this issue or a replay of the bug
https://gitflic.ru/project/gabberex/portfolio-gabberex/file
To Reproduce
Install all dependencies, run the project in development mode. Refresh the page in the chromium browser. The check mark next to "Disable cache" is enabled.
Describe the Bug
layout.tsx
tailwind.config.js
Local font is loaded, path in public directory. Development mode. Disable cache in browser/network flag is set opposite. As a result, when the page is reloaded, the font jumps. That is, it is loaded again and it is noticeable. Optimization crashed. Rolled back to next 13.1.6, install @next/font 13.1.6 experimental: { appDir: true } - fonts are loaded without a jump.
Expected Behavior
Page reload, the font is loaded and does not jump
Which browser are you using? (if relevant)
Vivaldi 6.0.2979.25, Yandex Browser 23.5.1.71
How are you deploying your application? (if relevant)
npm run dev