Browse Source

Added guards in TryGetGlyphTypeface so the $Default placeholder stops… (#19891)

* Added guards in TryGetGlyphTypeface so the $Default placeholder stops recursing once the concrete default family cannot be resolved

* Throw if $Default is used as the default family name

* Stripped the redundant $Default guard/continue blocks

---------

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
release/11.3.8
Wiesław Šoltés 4 months ago
committed by Julien Lebosquain
parent
commit
14837efafa
  1. 8
      src/Avalonia.Base/Media/FontManager.cs

8
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;
}

Loading…
Cancel
Save