{"record":{"id":"db338345b07e8ee0","repo":"siyuan-note/siyuan","slug":"export-custom-font-failed-response-status","errorCode":null,"errorMessage":"export custom font failed: ${response.status}","messagePattern":"export custom font failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/util/customFont.ts","lineNumber":120,"sourceCode":"        console.warn(\"load custom font failed\", error);\n    }\n};\n\nexport const ensureSelectedCustomFonts = async (fonts: Array<{ family: string; weight: number }>) => {\n    await Promise.all(fonts.map((font) => ensureSelectedCustomFont(font.family, font.weight)));\n};\n\nexport const getExportCustomFontStyle = async (fonts: Array<{family: string}>) => {\n    const families = new Set(fonts.map((font) => font.family).filter((family) =>\n        family.startsWith(CUSTOM_FONT_FAMILY_PREFIX)));\n    if (window.siyuan.config.system.safeMode || families.size === 0) {\n        return \"\";\n    }\n    const customFonts = (await loadCustomFonts()).filter((font) => isValidCustomFont(font) && families.has(font.family));\n    const styles = await Promise.all(customFonts.map(async (font) => {\n        const response = await fetch(`/custom-fonts/${font.id}`);\n        if (!response.ok) {\n            throw new Error(`export custom font failed: ${response.status}`);\n        }\n        const blob = await response.blob();\n        const dataURL = await new Promise<string>((resolve, reject) => {\n            const reader = new FileReader();\n            reader.onload = () => resolve(reader.result as string);\n            reader.onerror = () => reject(reader.error);\n            reader.readAsDataURL(blob);\n        });\n        return `@font-face { font-family: \"${font.family}\"; src: url(\"${dataURL}\"); font-style: normal; font-weight: ${Math.max(1, Math.min(1000, font.weight || 400))}; }`;\n    }));\n    return styles.join(\"\\n\");\n};\n\nconst setCustomFontStyle = (font: ICustomFont) => {\n    let styleElement = document.getElementById(`customFontStyle-${font.id}`) as HTMLStyleElement;\n    if (!styleElement) {\n        styleElement = document.createElement(\"style\");\n        styleElement.id = `customFontStyle-${font.id}`;","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/src/util/customFont.ts#L102-L138","documentation":"In getExportCustomFontStyle, the kernel request to export/fetch a custom font returned a non-success HTTP status; the logged/thrown message includes the status code. The custom font CSS for export could not be produced, and safe mode or font absence is excluded before this point.","triggerScenarios":"Thrown at app/src/util/customFont.ts:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the kernel log for the failed font export request","Verify the custom font files still exist under the workspace","Retry after confirming kernel availability; export without custom fonts as a fallback"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}