diff --git a/src/Avalonia.Base/Media/Fonts/EmbeddedFontCollection.cs b/src/Avalonia.Base/Media/Fonts/EmbeddedFontCollection.cs
index c242ed18db..80f47cee3b 100644
--- a/src/Avalonia.Base/Media/Fonts/EmbeddedFontCollection.cs
+++ b/src/Avalonia.Base/Media/Fonts/EmbeddedFontCollection.cs
@@ -23,11 +23,6 @@ namespace Avalonia.Media.Fonts
{
_key = key;
- if(!source.IsAvares() && !source.IsAbsoluteResm())
- {
- throw new ArgumentOutOfRangeException(nameof(source), "Specified source uri does not follow the resm: or avares: scheme.");
- }
-
_source = source;
}
diff --git a/src/Avalonia.Base/Media/Fonts/FontFamilyLoader.cs b/src/Avalonia.Base/Media/Fonts/FontFamilyLoader.cs
index 39e80415fb..37992c895e 100644
--- a/src/Avalonia.Base/Media/Fonts/FontFamilyLoader.cs
+++ b/src/Avalonia.Base/Media/Fonts/FontFamilyLoader.cs
@@ -13,10 +13,18 @@ namespace Avalonia.Media.Fonts
///
///
///
- public static IEnumerable LoadFontAssets(Uri source) =>
- IsFontTtfOrOtf(source) ?
- GetFontAssetsByExpression(source) :
- GetFontAssetsBySource(source);
+ public static IEnumerable LoadFontAssets(Uri source)
+ {
+ if (source.IsAvares() || source.IsAbsoluteResm())
+ {
+ return IsFontTtfOrOtf(source) ?
+ GetFontAssetsByExpression(source) :
+ GetFontAssetsBySource(source);
+ }
+
+ return Enumerable.Empty();
+ }
+
///
/// Searches for font assets at a given location and returns a quantity of found assets
diff --git a/src/Avalonia.Themes.Simple/Accents/Base.xaml b/src/Avalonia.Themes.Simple/Accents/Base.xaml
index 0a06927034..38b122d8b2 100644
--- a/src/Avalonia.Themes.Simple/Accents/Base.xaml
+++ b/src/Avalonia.Themes.Simple/Accents/Base.xaml
@@ -76,7 +76,7 @@
- avares://Avalonia.Fonts.Inter/Assets#Inter, $Default
+ fonts://Inter#Inter, $Default
#CC119EDA
#99119EDA
#66119EDA
diff --git a/tests/Avalonia.Skia.UnitTests/Media/EmbeddedFontCollectionTests.cs b/tests/Avalonia.Skia.UnitTests/Media/EmbeddedFontCollectionTests.cs
index 8e7ed8b1d2..006abe9278 100644
--- a/tests/Avalonia.Skia.UnitTests/Media/EmbeddedFontCollectionTests.cs
+++ b/tests/Avalonia.Skia.UnitTests/Media/EmbeddedFontCollectionTests.cs
@@ -17,9 +17,13 @@ namespace Avalonia.Skia.UnitTests.Media
[Theory]
public void Should_Get_Near_Matching_Typeface(FontWeight fontWeight, FontStyle fontStyle)
{
- using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface.With(fontManagerImpl: new CustomFontManagerImpl())))
+ using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
{
- var fontCollection = new EmbeddedFontCollection(FontManager.Current, new Uri(s_notoMono));
+ var source = new Uri(s_notoMono, UriKind.Absolute);
+
+ var fontCollection = new EmbeddedFontCollection(source, source);
+
+ fontCollection.Initialize(new CustomFontManagerImpl());
Assert.True(fontCollection.TryGetGlyphTypeface("Noto Mono", fontStyle, fontWeight, FontStretch.Normal, out var glyphTypeface));
@@ -32,9 +36,13 @@ namespace Avalonia.Skia.UnitTests.Media
[Fact]
public void Should_Not_Get_Typeface_For_Invalid_FamilyName()
{
- using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface.With(fontManagerImpl: new CustomFontManagerImpl())))
+ using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
{
- var fontCollection = new EmbeddedFontCollection(FontManager.Current, new Uri(s_notoMono));
+ var source = new Uri(s_notoMono, UriKind.Absolute);
+
+ var fontCollection = new EmbeddedFontCollection(source, source);
+
+ fontCollection.Initialize(new CustomFontManagerImpl());
Assert.False(fontCollection.TryGetGlyphTypeface("ABC", FontStyle.Normal, FontWeight.Normal, FontStretch.Normal, out var glyphTypeface));
}
@@ -43,11 +51,13 @@ namespace Avalonia.Skia.UnitTests.Media
[Fact]
public void Should_Get_Typeface_For_Partial_FamilyName()
{
- using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface.With(fontManagerImpl: new CustomFontManagerImpl())))
+ using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
{
var source = new Uri("resm:Avalonia.Skia.UnitTests.Assets?assembly=Avalonia.Skia.UnitTests#T", UriKind.Absolute);
- var fontCollection = new EmbeddedFontCollection(FontManager.Current, source);
+ var fontCollection = new EmbeddedFontCollection(source, source);
+
+ fontCollection.Initialize(new CustomFontManagerImpl());
Assert.True(fontCollection.TryGetGlyphTypeface("T", FontStyle.Normal, FontWeight.Normal, FontStretch.Normal, out var glyphTypeface));