Unverified Commit df3c1b82 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

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

If multiple weights or styles are requested, e.g. `Open_Sans({ weight: ['300', '400']})` or `Open_Sans({ style: ['normal', 'italic']})`, don't insert css rules for those properties.

Prior behavior was to insert the first ('300' or 'normal' in the above cases), which did not match webpack's behavior.


Closes WEB-1645
parent 1d86a092
...@@ -356,9 +356,21 @@ async fn get_font_css_properties( ...@@ -356,9 +356,21 @@ async fn get_font_css_properties(
font_family: Vc::cell(font_families.join(", ")), font_family: Vc::cell(font_families.join(", ")),
weight: Vc::cell(match &options.weights { weight: Vc::cell(match &options.weights {
FontWeights::Variable => None, 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()), variable: Vc::cell(options.variable.clone()),
})) }))
} }
......
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