diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs
index a86d311f4e..85c159467b 100644
--- a/samples/ControlCatalog.NetCore/Program.cs
+++ b/samples/ControlCatalog.NetCore/Program.cs
@@ -125,7 +125,7 @@ namespace ControlCatalog.NetCore
EnableIme = true
})
.UseSkia()
- .WithFonts(new InterFontCollection())
+ .WithInterFont()
.AfterSetup(builder =>
{
builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions()
diff --git a/src/Avalonia.Controls/AppBuilder.cs b/src/Avalonia.Controls/AppBuilder.cs
index 7e9fa1cab7..64bf92b7cd 100644
--- a/src/Avalonia.Controls/AppBuilder.cs
+++ b/src/Avalonia.Controls/AppBuilder.cs
@@ -208,23 +208,15 @@ namespace Avalonia
}
///
- /// Registers a custom font collection with the font manager.
+ /// Registers an action that is executed with the current font manager.
///
- /// The font collection.
+ /// The action.
/// An instance.
- ///
- public AppBuilder WithFonts(IFontCollection fontCollection)
+ public AppBuilder ConfigureFonts(Action action)
{
- if(fontCollection == null)
- {
- throw new ArgumentNullException(nameof(fontCollection), "Font collection can't be null.");
- }
-
return AfterSetup(appBuilder =>
{
- var fontManager = FontManager.Current;
-
- fontManager.AddFontCollection(fontCollection);
+ action?.Invoke(FontManager.Current);
});
}
diff --git a/src/Avalonia.Fonts.Inter/AppBuilderExtension.cs b/src/Avalonia.Fonts.Inter/AppBuilderExtension.cs
new file mode 100644
index 0000000000..842629c923
--- /dev/null
+++ b/src/Avalonia.Fonts.Inter/AppBuilderExtension.cs
@@ -0,0 +1,13 @@
+namespace Avalonia.Fonts.Inter
+{
+ public static class AppBuilderExtension
+ {
+ public static AppBuilder WithInterFont(this AppBuilder appBuilder)
+ {
+ return appBuilder.ConfigureFonts(fontManager =>
+ {
+ fontManager.AddFontCollection(new InterFontCollection());
+ });
+ }
+ }
+}
diff --git a/src/Avalonia.Fonts.Inter/Avalonia.Fonts.Inter.csproj b/src/Avalonia.Fonts.Inter/Avalonia.Fonts.Inter.csproj
index c81a13558c..c18c07d347 100644
--- a/src/Avalonia.Fonts.Inter/Avalonia.Fonts.Inter.csproj
+++ b/src/Avalonia.Fonts.Inter/Avalonia.Fonts.Inter.csproj
@@ -8,6 +8,7 @@
+