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

@next/font fallback fonts order fix #43633

Merged
merged 4 commits into from Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Expand Up @@ -115,8 +115,8 @@ const postcssFontLoaderPlugn = ({
const isRange = (value: string) => value.trim().includes(' ')
const formattedFontFamilies = [
formatFamily(fontFamily),
...fallbackFonts,
...(adjustFontFallbackFamily ? [adjustFontFallbackFamily] : []),
...fallbackFonts,
].join(', ')
// Add class with family, weight and style
const classRule = new postcss.Rule({ selector: '.className' })
Expand Down
1 change: 1 addition & 0 deletions test/e2e/next-font/app/pages/with-fallback.js
Expand Up @@ -2,6 +2,7 @@ import { Open_Sans } from '@next/font/google'
const openSans = Open_Sans({
fallback: ['system-ui', 'Arial'],
variable: '--open-sans',
adjustFontFallback: false,
})

export default function WithFonts() {
Expand Down
14 changes: 4 additions & 10 deletions test/e2e/next-font/index.test.ts
Expand Up @@ -108,7 +108,7 @@ describe('@next/font/google', () => {
className: expect.stringMatching(/__className_.{6}/),
style: {
fontFamily: expect.stringMatching(
/^'__myFont1_.{6}', system-ui, '__myFont1_Fallback_.{6}'$/
/^'__myFont1_.{6}', '__myFont1_Fallback_.{6}', system-ui$/
),
fontStyle: 'italic',
fontWeight: 100,
Expand Down Expand Up @@ -275,27 +275,21 @@ describe('@next/font/google', () => {
await browser.eval(
'getComputedStyle(document.querySelector("#with-fallback-fonts-classname")).fontFamily'
)
).toMatch(
/^__Open_Sans_.{6}, system-ui, Arial, __Open_Sans_Fallback_.{6}$/
)
).toMatch(/^__Open_Sans_.{6}, system-ui, Arial$/)

// .style
expect(
await browser.eval(
'getComputedStyle(document.querySelector("#with-fallback-fonts-style")).fontFamily'
)
).toMatch(
/^__Open_Sans_.{6}, system-ui, Arial, __Open_Sans_Fallback_.{6}$/
)
).toMatch(/^__Open_Sans_.{6}, system-ui, Arial$/)

// .variable
expect(
await browser.eval(
'getComputedStyle(document.querySelector("#with-fallback-fonts-variable")).fontFamily'
)
).toMatch(
/^__Open_Sans_.{6}, system-ui, Arial, __Open_Sans_Fallback_.{6}$/
)
).toMatch(/^__Open_Sans_.{6}, system-ui, Arial$/)
})
})

Expand Down