{"record":{"id":"04aaef394f7d92f3","repo":"siyuan-note/siyuan","slug":"font-file-is-too-large","errorCode":null,"errorMessage":"font file is too large","messagePattern":"font file is too large","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/custom_font.go","lineNumber":106,"sourceCode":"\tdefer customFontsLock.Unlock()\n\n\tloadCustomFontsLocked()\n\treturn cloneCustomFonts(customFonts)\n}\n\nfunc InstallCustomFont(tempPath string) (*CustomFont, bool, error) {\n\tcustomFontsLock.Lock()\n\tdefer customFontsLock.Unlock()\n\n\tinfo, err := os.Stat(tempPath)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tif !info.Mode().IsRegular() || info.Size() < 1 {\n\t\treturn nil, false, errors.New(\"font file is empty\")\n\t}\n\tif MaxCustomFontSize < info.Size() {\n\t\treturn nil, false, errors.New(\"font file is too large\")\n\t}\n\n\tfontFile, err := os.Open(tempPath)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\n\textension, err := detectCustomFontExtension(fontFile)\n\tif err != nil {\n\t\tfontFile.Close()\n\t\treturn nil, false, err\n\t}\n\tif _, err = fontFile.Seek(0, io.SeekStart); err != nil {\n\t\tfontFile.Close()\n\t\treturn nil, false, err\n\t}\n\n\tid, err := customFontHash(fontFile)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/custom_font.go#L88-L124","documentation":"Returned by InstallCustomFont when the uploaded font file's size exceeds MaxCustomFontSize (64 MiB, defined in custom_font.go:35). The guard runs before opening or hashing the file, so it is a hard cap intended to prevent oversized uploads from being parsed or stored.","triggerScenarios":"Calling util.InstallCustomFont(tempPath) where the temp file is larger than 64 MiB (67108864 bytes).","commonSituations":"A user uploaded a font family archive or a multi-weight 'super' font instead of a single TTF/OTF; a non-font binary (video, image) mistakenly routed to the font endpoint; an extraordinarily large legitimate font.","solutions":["Upload a single regular TTF/OTF file under 64 MiB; install other weights separately.","If the file is not actually a font, route it to the correct upload endpoint.","Only raise MaxCustomFileSize if you have reviewed the parsing cost and storage impact — it is a deliberate cap."],"exampleFix":"// before\nfont, _, err := util.InstallCustomFont(tempPath)\n\n// after\nconst maxFont = 64 * 1024 * 1024\nif info, _ := os.Stat(tempPath); info.Size() > maxFont {\n    return fmt.Errorf(\"font exceeds %d bytes; split the family\", maxFont)\n}\nfont, _, err := util.InstallCustomFont(tempPath)","handlingStrategy":"validation","validationCode":"const maxFont = 64 * 1024 * 1024 // keep in sync with util.MaxCustomFontSize\nfunc fontWithinLimit(tempPath string) bool {\n    info, err := os.Stat(tempPath)\n    return err == nil && info.Size() <= maxFont\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce the 64 MiB cap in the upload handler so the user is told before parsing starts.","Install one weight at a time rather than a multi-weight family bundle."],"tags":["fonts","validation","size-limit","upload"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}