LykosAI/StabilityMatrix · critical · ApplicationException

Font NotoSansJP not found

Error message

Font NotoSansJP not found

What it means

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.

Solutions

  1. Ensure App.axaml (or a merged dictionary loaded before Initialize) defines <FontFamily x:Key="NotoSansJP">...</FontFamily>
  2. Verify the resource key spelling matches 'NotoSansJP' exactly (case-sensitive)
  3. Confirm the merged dictionary containing the font is included in the build and loaded before Cultures.Current is set to ja-JP
  4. Wrap the lookup with Resources.TryGetResource and fall back to a default font family

Example fix

// before
return Resources["NotoSansJP"] as FontFamily
    ?? throw new ApplicationException("Font NotoSansJP not found");
// after
if (Resources.TryGetResource("NotoSansJP", null, out var res) && res is FontFamily jp)
    return jp;
return FontFamily.Default;
Defensive patterns

Strategy: fallback

Validate before calling

if (!App.Resources.Contains("NotoSansJP"))
    Console.Warn("NotoSansJP resource missing; using default font");

Type guard

bool HasJapaneseFont(App app) => app.Resources["NotoSansJP"] is FontFamily;

Try / catch

try { return (FontFamily)Resources["NotoSansJP"]; }
catch (ApplicationException) { return FontFamily.Default; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/d880dd32c49eab10. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Avalonia/App.axaml.cs:305

    /// </summary>
    private void SetFontFamily(FontFamily fontFamily)
    {
        Resources["ContentControlThemeFontFamily"] = fontFamily;
    }

    /// <summary>
    /// Get the default font family for the current platform and language.
    /// </summary>
    public FontFamily GetPlatformDefaultFontFamily()
    {
        try
        {
            var fonts = new List<string>();

            if (Cultures.Current?.Name == "ja-JP")
            {
                return Resources["NotoSansJP"] as FontFamily
                    ?? throw new ApplicationException("Font NotoSansJP not found");
            }

            if (Compat.IsWindows)
            {
                fonts.Add(OSVersionHelper.IsWindows11() ? "Segoe UI Variable Text" : "Segoe UI");
            }
            else if (Compat.IsMacOS)
            {
                // Use Segoe fonts if installed, but we can't distribute them
                fonts.Add("Segoe UI Variable");
                fonts.Add("Segoe UI");

                fonts.Add("San Francisco");
                fonts.Add("Helvetica Neue");
                fonts.Add("Helvetica");
            }
            else if (Compat.IsLinux)
            {

View on GitHub (pinned to af93d6ef57)