// If preload is disabled set display to 'swap' by default.
// If display is 'optional' and we don't preload, we will never fetch the font in time to display it, not even in dev.
display=preload?'optional':'swap',
display=preload?'optional':'swap',
axes,
axes,
fallback,
fallback,
...
@@ -48,13 +50,17 @@ export function validateData(
...
@@ -48,13 +50,17 @@ export function validateData(
nextFontError(`Unknown font \`${fontFamily}\``)
nextFontError(`Unknown font \`${fontFamily}\``)
}
}
constavailableSubsets=fontFamilyData.subsets
if(availableSubsets.length===0){
// If the font doesn't have any preloaded subsets, disable preload and set display to 'swap'
preload=false
display='swap'
}else{
if(preload&&!callSubsets&&!config?.subsets){
if(preload&&!callSubsets&&!config?.subsets){
nextFontError(
nextFontError(
`Missing selected subsets for font \`${fontFamily}\`. Please specify subsets in the function call or in your \`next.config.js\`. Read more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`
`Missing selected subsets for font \`${fontFamily}\`. Please specify subsets in the function call or in your \`next.config.js\`. Read more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`