{"record":{"id":"affed7464235cc97","repo":"AvaloniaUI/Avalonia","slug":"fontfamily-defaultfontfamilyname-is-a-placehol","errorCode":null,"errorMessage":"'{FontFamily.DefaultFontFamilyName}' is a placeholder and cannot be used as the default font family name. Provide a concrete font family name via {nameof(FontManagerOptions)} or the platform implementation.","messagePattern":"'(.+?)' is a placeholder and cannot be used as the default font family name\\. Provide a concrete font family name via (.+?) or the platform implementation\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/FontManager.cs","lineNumber":456,"sourceCode":"        private string GetDefaultFontFamilyName(FontManagerOptions? options)\n        {\n            var defaultFontFamilyName = options?.DefaultFamilyName\n                ?? PlatformImpl.GetDefaultFontFamilyName();\n\n            if (string.IsNullOrEmpty(defaultFontFamilyName) && SystemFonts.Count > 0)\n            {\n                defaultFontFamilyName = SystemFonts[0].Name;\n            }\n\n            if (string.IsNullOrEmpty(defaultFontFamilyName))\n            {\n                throw new InvalidOperationException(\n                    \"Default font family name can't be null or empty.\");\n            }\n\n            if (defaultFontFamilyName == FontFamily.DefaultFontFamilyName)\n            {\n                throw new InvalidOperationException(\n                    $\"'{FontFamily.DefaultFontFamilyName}' is a placeholder and cannot be used as the default font family name. Provide a concrete font family name via {nameof(FontManagerOptions)} or the platform implementation.\");\n            }\n\n            return defaultFontFamilyName;\n        }\n\n        void IDisposable.Dispose()\n        {\n            foreach (var pair in _fontCollections)\n                pair.Value.Dispose();\n\n            _fontCollections.Clear();\n            (PlatformImpl as IDisposable)?.Dispose();\n        }\n    }\n}\n","sourceCodeStart":438,"sourceCodeEnd":473,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/FontManager.cs#L438-L473","documentation":"GetDefaultFontFamilyName throws InvalidOperationException when the resolved default font family name equals the placeholder constant FontFamily.DefaultFontFamilyName (which is \"$Default\"). \"$Default\" is a sentinel meaning 'use the system default'; using it as the concrete default would cause infinite recursion/unresolved resolution, so it is explicitly rejected. A real font name must be supplied via FontManagerOptions or the platform.","triggerScenarios":"FontManagerOptions.DefaultFamilyName (or the platform implementation) returns the literal string \"$Default\". This happens when config or a binding forwards the sentinel placeholder instead of a concrete family name.","commonSituations":"Setting DefaultFamilyName = FontFamily.DefaultFontFamilyName in options (thinking it means 'default'). A platform impl incorrectly returning the sentinel. Copying a XAML/theme value that used the placeholder into the options.","solutions":["Set FontManagerOptions.DefaultFamilyName to a concrete, installed font family name (e.g. \"Segoe UI\", \"Inter\", \"DejaVu Sans\").","Leave DefaultFamilyName null so the platform impl and SystemFonts fallback resolve a real font.","Never use \"$Default\" (FontFamily.DefaultFontFamilyName) as the options value."],"exampleFix":"// before\nservices.AddSingleton<FontManagerOptions>(_ => new FontManagerOptions\n{\n    DefaultFamilyName = FontFamily.DefaultFontFamilyName // \"$Default\"\n});\n\n// after\nservices.AddSingleton<FontManagerOptions>(_ => new FontManagerOptions\n{\n    DefaultFamilyName = \"Inter\"\n});","handlingStrategy":"validation","validationCode":"if (defaultFamilyName == FontFamily.DefaultFontFamilyName) // \"$Default\"\n    defaultFamilyName = \"Inter\"; // concrete fallback\nvar opts = new FontManagerOptions { DefaultFamilyName = defaultFamilyName };","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set DefaultFamilyName to FontFamily.DefaultFontFamilyName (\"$Default\").","Leave it null to let the platform/SystemFonts resolve, or set a concrete name.","Add a startup guard that rejects the placeholder in config."],"tags":["font-manager","configuration","media","fonts","placeholder"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}