{"record":{"id":"dd60bef599d1dda4","repo":"siyuan-note/siyuan","slug":"parse-font-metadata-failed-w","errorCode":null,"errorMessage":"parse font metadata failed: %w","messagePattern":"parse font metadata failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/custom_font.go","lineNumber":333,"sourceCode":"\t}\n\treturn hex.EncodeToString(hash.Sum(nil)), nil\n}\n\nfunc parseCustomFontFile(fontFile *os.File) (ret *Font, err error) {\n\tdefer func() {\n\t\tif recovered := recover(); recovered != nil {\n\t\t\tret = nil\n\t\t\terr = fmt.Errorf(\"parse font failed: %v\", recovered)\n\t\t}\n\t}()\n\n\tparsed, err := sfnt.Parse(fontFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parse font failed: %w\", err)\n\t}\n\tret, err = parseFontInfo(parsed)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parse font metadata failed: %w\", err)\n\t}\n\treturn ret, nil\n}\n\nfunc validCustomFontID(id string) bool {\n\tif len(id) != sha256.Size*2 || strings.ToLower(id) != id {\n\t\treturn false\n\t}\n\tdecoded, err := hex.DecodeString(id)\n\treturn err == nil && len(decoded) == sha256.Size\n}\n\nfunc newCustomFont(id, fontPath string, font *Font) *CustomFont {\n\tweight := font.Weight\n\tif weight < 1 || 1000 < weight {\n\t\tweight = 400\n\t}\n\treturn &CustomFont{","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/custom_font.go#L315-L351","documentation":"Returned by parseCustomFontFile when parseFontInfo (font.go) fails after sfnt.Parse succeeded. The wrapped cause is typically 'font family is empty' (errorIndex 1092) — i.e. the font's name table has no usable Family entry — or a name-table read error. The %w wrap preserves the underlying error.","triggerScenarios":"InstallCustomFont or loadCustomFontsLocked passes a font that parses structurally but whose name table cannot be read or yields no family name (family empty or starting with '.').","commonSituations":"A stripped or subsetted font whose name table was removed to save space; a font with only non-Latin name entries that the selection logic skips; a font whose only family name begins with '.' (some legacy Mac fonts).","solutions":["Unwrap the error to confirm the cause — if it is 'font family is empty', the font is missing a usable Family name.","Re-export the font with a valid Family name (nameID 1 or 16) using fonttools or FontForge.","Use the original un-subsetted font instead of a stripped variant."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, _, err := util.InstallCustomFont(tempPath); err != nil {\n    if strings.Contains(err.Error(), \"parse font metadata failed\") {\n        // font is missing a usable name table — request a non-subsetted copy\n    }\n}","preventionTips":["Install full fonts rather than subsetted/stripped variants.","If subsetting, keep nameIDs 1 and 16 in the output."],"tags":["fonts","parsing","metadata","sfnt"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}