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

Turbopack next/font/google: don't insert css rules for multiple weights or styles #55852

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Changes from all 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
16 changes: 14 additions & 2 deletions packages/next-swc/crates/next-core/src/next_font/google/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,21 @@ async fn get_font_css_properties(
font_family: Vc::cell(font_families.join(", ")),
weight: Vc::cell(match &options.weights {
FontWeights::Variable => None,
FontWeights::Fixed(weights) => weights.first().map(|w| w.to_string()),
FontWeights::Fixed(weights) => {
if weights.len() > 1 {
// Don't set a rule for weight if multiple are requested
None
} else {
weights.first().map(|w| w.to_string())
}
}
}),
style: Vc::cell(if options.styles.len() > 1 {
// Don't set a rule for style if multiple are requested
None
} else {
options.styles.first().cloned()
}),
style: Vc::cell(options.styles.first().cloned()),
variable: Vc::cell(options.variable.clone()),
}))
}
Expand Down