{"record":{"id":"0710195c30d7cd67","repo":"siyuan-note/siyuan","slug":"font-family-is-empty","errorCode":null,"errorMessage":"font family is empty","messagePattern":"font family is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/util/font.go","lineNumber":313,"sourceCode":"\tlocalizedFamily := selectLocalizedFontName(entries, sfnt.NamePreferredFamily, sfnt.NameFontFamily)\n\tlocalizedSubfamily := selectLocalizedFontName(entries, sfnt.NamePreferredSubfamily, sfnt.NameFontSubfamily)\n\tif \"\" == localizedFamily {\n\t\tlocalizedFamily = family\n\t}\n\tif \"\" == localizedSubfamily {\n\t\tlocalizedSubfamily = subfamily\n\t}\n\n\tweight := 400\n\tos2, err := font.OS2Table()\n\tif nil == err {\n\t\tweight = int(os2.USWeightClass)\n\t}\n\n\tweight = inferFontWeight(weight, subfamily)\n\n\tif family == \"\" || strings.HasPrefix(family, \".\") {\n\t\treturn nil, errors.New(\"font family is empty\")\n\t}\n\n\tdisplayName := localizedFamily\n\tif subfamily != \"\" && !strings.EqualFold(subfamily, \"Regular\") {\n\t\tdisplayName = localizedFamily + \" \" + localizedSubfamily\n\t}\n\taliases := collectFontAliases(entries,\n\t\tsfnt.NamePreferredFamily, sfnt.NameFontFamily, sfnt.NameWWSFamily,\n\t\tsfnt.NamePreferredSubfamily, sfnt.NameFontSubfamily, sfnt.NameWWSSubfamily,\n\t\tsfnt.NameFull, sfnt.NameCompatibleFull, sfnt.NamePostscript)\n\n\treturn &Font{\n\t\tnonNormalStyle: isNonNormalFontStyle(subfamily),\n\t\tFamily:         family,\n\t\tWeight:         weight,\n\t\tDisplayName:    displayName,\n\t\tAliases:        aliases,\n\t\tSpacing:        detectFontSpacing(font),","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/font.go#L295-L331","documentation":"parseFontInfo extracts font metadata (family, subfamily, weight) from a parsed font file. The family name is mandatory for registering a custom font; a missing family or one starting with a period (hidden/internal fonts like '.AppleSystemUIFont') is rejected and the font file is skipped.","triggerScenarios":"parseFont, parseCustomFontFile, or TestParseBundledFontLocalizedName encounter a font whose name table yields an empty family, or whose family begins with '.' (system-internal hidden fonts).","commonSituations":"User imports a broken/corrupt custom font; scanning system font directories containing internal dot-prefixed Apple/Windows fonts; a truncated TTF/OTF missing its name-table records.","solutions":["Remove the offending font file from the custom fonts directory and re-import a valid TTF/OTF/WOFF","Check the font with fonttools/FontForge to confirm it has a family name (name ID 1/16)","Skip dot-prefixed fonts explicitly when scanning system font folders","Re-download the font from a trusted source if the file is truncated"],"exampleFix":"// before: scanning all files in the fonts dir\nfor _, f := range files { parseFont(f) }\n// after: skip hidden/internal fonts\nif strings.HasPrefix(f.Name(), \".\") { continue }","handlingStrategy":"validation","validationCode":"if family == \"\" || strings.HasPrefix(family, \".\") {\n    return fmt.Errorf(\"skipping font %q: no usable family name\", path)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only import fonts from trusted sources with complete name tables","Skip dot-prefixed system fonts when scanning font directories","Validate fonts with fonttools/FontForge before distribution","Check file size/integrity after download before importing"],"tags":["fonts","parsing","validation"],"backgroundTag":"empty-required-field","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}