{"record":{"id":"d880dd32c49eab10","repo":"LykosAI/StabilityMatrix","slug":"font-notosansjp-not-found","errorCode":null,"errorMessage":"Font NotoSansJP not found","messagePattern":"Font NotoSansJP not found","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"critical","filePath":"StabilityMatrix.Avalonia/App.axaml.cs","lineNumber":305,"sourceCode":"    /// </summary>\n    private void SetFontFamily(FontFamily fontFamily)\n    {\n        Resources[\"ContentControlThemeFontFamily\"] = fontFamily;\n    }\n\n    /// <summary>\n    /// Get the default font family for the current platform and language.\n    /// </summary>\n    public FontFamily GetPlatformDefaultFontFamily()\n    {\n        try\n        {\n            var fonts = new List<string>();\n\n            if (Cultures.Current?.Name == \"ja-JP\")\n            {\n                return Resources[\"NotoSansJP\"] as FontFamily\n                    ?? throw new ApplicationException(\"Font NotoSansJP not found\");\n            }\n\n            if (Compat.IsWindows)\n            {\n                fonts.Add(OSVersionHelper.IsWindows11() ? \"Segoe UI Variable Text\" : \"Segoe UI\");\n            }\n            else if (Compat.IsMacOS)\n            {\n                // Use Segoe fonts if installed, but we can't distribute them\n                fonts.Add(\"Segoe UI Variable\");\n                fonts.Add(\"Segoe UI\");\n\n                fonts.Add(\"San Francisco\");\n                fonts.Add(\"Helvetica Neue\");\n                fonts.Add(\"Helvetica\");\n            }\n            else if (Compat.IsLinux)\n            {","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/App.axaml.cs#L287-L323","documentation":"GetPlatformDefaultFontFamily looks up a merged ResourceDictionary entry named 'NotoSansJP' and casts it to FontFamily. When the current culture is ja-JP but the resource is missing (or is not a FontFamily), the app throws ApplicationException('Font NotoSansJP not found') at startup, crashing Initialize/Setup before the window renders.","triggerScenarios":"Current culture is 'ja-JP' AND App.Resources contains no 'NotoSansJP' resource, or the resource exists under a different key/type (e.g. merged dictionary not loaded, resource file excluded from build, XAML typo).","commonSituations":"Removing or renaming the NotoSansJP resource in App.axaml or a merged dictionary; localization changes setting CultureInfo to ja-JP in tests or headless environments where resources weren't initialized; renaming the font family string without updating the resource key.","solutions":["Ensure App.axaml (or a merged dictionary loaded before Initialize) defines <FontFamily x:Key=\"NotoSansJP\">...</FontFamily>","Verify the resource key spelling matches 'NotoSansJP' exactly (case-sensitive)","Confirm the merged dictionary containing the font is included in the build and loaded before Cultures.Current is set to ja-JP","Wrap the lookup with Resources.TryGetResource and fall back to a default font family"],"exampleFix":"// before\nreturn Resources[\"NotoSansJP\"] as FontFamily\n    ?? throw new ApplicationException(\"Font NotoSansJP not found\");\n// after\nif (Resources.TryGetResource(\"NotoSansJP\", null, out var res) && res is FontFamily jp)\n    return jp;\nreturn FontFamily.Default;","handlingStrategy":"fallback","validationCode":"if (!App.Resources.Contains(\"NotoSansJP\"))\n    Console.Warn(\"NotoSansJP resource missing; using default font\");","typeGuard":"bool HasJapaneseFont(App app) => app.Resources[\"NotoSansJP\"] is FontFamily;","tryCatchPattern":"try { return (FontFamily)Resources[\"NotoSansJP\"]; }\ncatch (ApplicationException) { return FontFamily.Default; }","preventionTips":["Define the NotoSansJP FontFamily resource in App.axaml before any culture-dependent code runs","Add a startup smoke test asserting required resources exist","Use TryGetResource instead of indexer + throw"],"tags":["avalonia","fonts","localization","xaml-resources","startup"],"backgroundTag":"resource-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}