{"record":{"id":"609bdc1b5913daf9","repo":"d2lang/d2","slug":"v-is-not-a-valid-font-in-our-system","errorCode":null,"errorMessage":"\"%v\" is not a valid font in our system","messagePattern":"\"(.+?)\" is not a valid font in our system","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2graph/d2graph.go","lineNumber":409,"sourceCode":"\t\tif err != nil {\n\t\t\treturn errors.New(`expected \"3d\" to be true or false`)\n\t\t}\n\t\ts.ThreeDee.Value = value\n\tcase \"multiple\":\n\t\tif s.Multiple == nil {\n\t\t\tbreak\n\t\t}\n\t\t_, err := strconv.ParseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.New(`expected \"multiple\" to be true or false`)\n\t\t}\n\t\ts.Multiple.Value = value\n\tcase \"font\":\n\t\tif s.Font == nil {\n\t\t\tbreak\n\t\t}\n\t\tif _, ok := d2fonts.D2_FONT_TO_FAMILY[strings.ToLower(value)]; !ok {\n\t\t\treturn fmt.Errorf(`\"%v\" is not a valid font in our system`, value)\n\t\t}\n\t\ts.Font.Value = strings.ToLower(value)\n\tcase \"font-size\":\n\t\tif s.FontSize == nil {\n\t\t\tbreak\n\t\t}\n\t\tf, err := strconv.Atoi(value)\n\t\tif err != nil || (f < 8 || f > 100) {\n\t\t\treturn errors.New(`expected \"font-size\" to be a number between 8 and 100`)\n\t\t}\n\t\ts.FontSize.Value = value\n\tcase \"font-color\":\n\t\tif s.FontColor == nil {\n\t\t\tbreak\n\t\t}\n\t\tif !color.ValidColor(value) {\n\t\t\treturn errors.New(`expected \"font-color\" to be a valid named color (\"orange\"), a hex code (\"#f0ff3a\"), or a gradient (\"linear-gradient(red, blue)\")`)\n\t\t}","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2graph/d2graph.go#L391-L427","documentation":"The \"font\" style key must name a font family present in d2fonts.D2_FONT_TO_FAMILY. The value is checked case-insensitively; unknown names produce this error naming the offending value.","triggerScenarios":"Setting `style.font` on a shape/element to a value not in D2_FONT_TO_FAMILY — e.g. `font: Arial` or `font: Comic Sans` instead of built-in families like Source Sans Pro, Source Code Pro, or custom fonts loaded via loadFonts.","commonSituations":"Assuming any system-installed font works, forgetting to register a custom font family via the --font-* flags, or using a font name with wrong spacing/casing combined with missing registration.","solutions":["Use a built-in family name listed in d2fonts.D2_FONT_TO_FAMILY (lowercase matching)","Register a custom font by providing the TTF files via the font flags so the family becomes valid","Fix spelling/spacing of the font name"],"exampleFix":"// before\nx.style.font: Arial\n// after\nx.style.font: Source Sans Pro","handlingStrategy":"validation","validationCode":"if _, ok := d2fonts.D2_FONT_TO_FAMILY[strings.ToLower(fontName)]; !ok {\n\t// invalid font family — register via --font-* flags or pick a built-in\n}","typeGuard":"func validFontFamily(v string) bool {\n\t_, ok := d2fonts.D2_FONT_TO_FAMILY[strings.ToLower(v)]\n\treturn ok\n}","tryCatchPattern":"if err := obj.SetStyle(\"font\", v); err != nil {\n\treturn fmt.Errorf(\"font %q unavailable: %v\", v, err)\n}","preventionTips":["Use built-in family names from D2_FONT_TO_FAMILY","Register custom fonts with --font-regular etc. before using them in styles","Normalize names to lowercase with exact spacing"],"tags":["d2","style-validation","fonts"],"backgroundTag":"invalid-style-value","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}