diff --git a/src/Avalonia.Base/Media/FontManager.cs b/src/Avalonia.Base/Media/FontManager.cs index dfce362297..c8d8042e83 100644 --- a/src/Avalonia.Base/Media/FontManager.cs +++ b/src/Avalonia.Base/Media/FontManager.cs @@ -163,7 +163,7 @@ namespace Avalonia.Media } //Nothing was found so use the default - return TryGetGlyphTypeface(new Typeface(FontFamily.DefaultFontFamilyName, typeface.Style, typeface.Weight, typeface.Stretch), out glyphTypeface); + return TryGetGlyphTypeface(new Typeface(DefaultFontFamily, typeface.Style, typeface.Weight, typeface.Stretch), out glyphTypeface); FontFamily GetMappedFontFamily(FontFamily fontFamily) { @@ -380,6 +380,12 @@ namespace Avalonia.Media "Default font family name can't be null or empty."); } + if (defaultFontFamilyName == FontFamily.DefaultFontFamilyName) + { + throw new InvalidOperationException( + $"'{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."); + } + return defaultFontFamilyName; }