{"record":{"id":"750e3ae4dd887c3f","repo":"vercel/next.js","slug":"axes-can-only-be-defined-for-variable-fonts-when-t","errorCode":null,"errorMessage":"Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`.","messagePattern":"Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/next-core/src/next_font/google/options.rs","lineNumber":183,"sourceCode":"\n    if !ALLOWED_DISPLAY_VALUES.contains(&display.as_str()) {\n        anyhow::bail!(\n            \"Invalid display value {} for font {}.\\nAvailable display values: {}\",\n            display,\n            font_family,\n            ALLOWED_DISPLAY_VALUES.join(\", \")\n        )\n    }\n\n    if let Some(axes) = argument.axes.as_ref()\n        && !axes.is_empty()\n    {\n        if !supports_variable_weight {\n            anyhow::bail!(\"Axes can only be defined for variable fonts.\")\n        }\n\n        if weights != FontWeights::Variable {\n            anyhow::bail!(\n                \"Axes can only be defined for variable fonts when the weight property is \\\n                 nonexistent or set to `variable`.\"\n            )\n        }\n    }\n\n    Ok(NextFontGoogleOptions {\n        font_family,\n        weights,\n        styles,\n        display,\n        preload: argument.preload.unwrap_or(true),\n        selected_variable_axes: argument.axes,\n        fallback: argument.fallback,\n        adjust_font_fallback: argument.adjust_font_fallback.unwrap_or(true),\n        variable: argument.variable,\n        subsets: argument.subsets,\n    })","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/crates/next-core/src/next_font/google/options.rs#L165-L201","documentation":"Thrown by options_from_request() when `axes` is provided for a variable font but the resolved weights are not FontWeights::Variable — i.e. you set both explicit numeric weights and custom axes. Axes manipulate the variable axes of the font, which requires the weight axis itself to be in variable mode (weight absent or 'variable').","triggerScenarios":"Passing `weight: '400'` (or any fixed weight) together with an `axes` array to a variable font. The validator allows axes only when weights == FontWeights::Variable.","commonSituations":"Wanting a specific weight plus a custom optical-size axis; misunderstanding that fixing the weight disables the variable axis system.","solutions":["Remove the explicit `weight` (or set it to 'variable') so the font stays in variable mode, then keep `axes`.","If you need a fixed weight, drop `axes` and rely on the chosen weight only."],"exampleFix":"// before\nconst font = Inter({\n  subsets: ['latin'],\n  weight: '400',\n  axes: [{ tag: 'opsz', min: 14, max: 32 }],\n})\n// after\nconst font = Inter({\n  subsets: ['latin'],\n  weight: 'variable',\n  axes: [{ tag: 'opsz', min: 14, max: 32 }],\n})","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep weight as 'variable' (or absent) whenever you define axes.","Don't combine a fixed numeric weight with custom axes on the same font.","Decide per-font: either fixed weights OR variable mode + axes."],"tags":["next-font","google-font","font","axes","variable","weight","rust"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}