{"record":{"id":"cfbf053143ced1d0","repo":"withastro/astro","slug":"cannotdetermineweightandstylefromfontfile","errorCode":"CannotDetermineWeightAndStyleFromFontFile","errorMessage":"An error occurred while determining the `weight` and `style` from local family \"${family}\" font file: ${url}.","messagePattern":"An error occurred while determining the `weight` and `style` from local family \"(.+?)\" font file: (.+?)\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/fonts/infra/fontace-font-file-reader.ts","lineNumber":16,"sourceCode":"import { readFileSync } from 'node:fs';\nimport { fontace } from 'fontace';\nimport { AstroError, AstroErrorData } from '../../../core/errors/index.js';\nimport type { FontFileReader } from '../definitions.js';\nimport type { Style } from '../types.js';\n\nexport class FontaceFontFileReader implements FontFileReader {\n\textract({ family, url }: { family: string; url: string }): { weight: string; style: Style } {\n\t\ttry {\n\t\t\tconst data = fontace(readFileSync(url));\n\t\t\treturn {\n\t\t\t\tweight: data.weight,\n\t\t\t\tstyle: data.style as Style,\n\t\t\t};\n\t\t} catch (cause) {\n\t\t\tthrow new AstroError(\n\t\t\t\t{\n\t\t\t\t\t...AstroErrorData.CannotDetermineWeightAndStyleFromFontFile,\n\t\t\t\t\tmessage: AstroErrorData.CannotDetermineWeightAndStyleFromFontFile.message(family, url),\n\t\t\t\t},\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/assets/fonts/infra/fontace-font-file-reader.ts#L1-L26","documentation":"When a font family variant omits `weight`/`style`, the fonts pipeline tries to read them from the file itself using `fontace(readFileSync(url))` (packages/astro/src/assets/fonts/infra/fontace-font-file-reader.ts:16). If the file cannot be read or parsed (corrupt file, HTML error page saved with a font extension, unsupported table layout), the failure is wrapped as `CannotDetermineWeightAndStyleFromFontFile` with the parse error as `cause`.","triggerScenarios":"A `fonts` config entry without explicit `weight` and `style` whose `url` points to a file that fontace cannot parse — corrupt downloads, a CDN 404 page saved as .woff2, or an unusual/legacy font binary.","commonSituations":"Fonts downloaded via curl from redirecting CDNs; minimal system fonts with stripped tables; switching a family's files while keeping the old config.","solutions":["Set `weight` and `style` explicitly on that family/variant in the `fonts` config so Astro never needs to read them from the file.","Verify the file is a real font: `file my-font.woff2` or open it in a font tool; re-download or replace corrupt files.","Confirm the URL returns the font bytes (not an HTML error page) — check with `curl -L <url> | file -`."],"exampleFix":"// astro.config.mjs — before (weight/style inferred from the file)\n{ family: 'My Font', url: './fonts/my-font.woff2' }\n\n// astro.config.mjs — after (declared explicitly)\n{ family: 'My Font', url: './fonts/my-font.woff2', weight: 400, style: 'normal' }","handlingStrategy":"validation","validationCode":"// always declare weight/style in the fonts config so the file is never parsed for them\nconst family = {\n  family: 'My Font',\n  variants: [{ weight: 400, style: 'normal', url: './fonts/my-font-400.woff2' }],\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat weight/style as required fields in your fonts config, even when they could be inferred.","Verify downloads with `file *.woff2` before committing.","Keep a font lint step that opens each file with a parser (e.g. fontkit) in CI."],"tags":["fonts","build","font-metadata"],"backgroundTag":"font-metadata-parse-failed","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}