Browse Source

Only try to create embedded font collection for valid assets location

pull/10579/head
Benedikt Stebner 4 years ago
parent
commit
ef2a47bc95
  1. 2
      src/Avalonia.Base/Media/FontManager.cs
  2. 2
      src/Avalonia.Themes.Simple/Accents/Base.xaml
  3. 11
      tests/Avalonia.Skia.UnitTests/Media/FontManagerImplTests.cs

2
src/Avalonia.Base/Media/FontManager.cs

@ -107,7 +107,7 @@ namespace Avalonia.Media
source = new Uri(key.BaseUri, source);
}
if (!_fontCollections.TryGetValue(source, out var fontCollection))
if (!_fontCollections.TryGetValue(source, out var fontCollection) && (source.IsAbsoluteResm() || source.IsAvares()))
{
var embeddedFonts = new EmbeddedFontCollection(source, source);

2
src/Avalonia.Themes.Simple/Accents/Base.xaml

@ -76,7 +76,7 @@
<SolidColorBrush x:Key="RefreshVisualizerBackground" Color="Transparent" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<FontFamily x:Key="ContentControlThemeFontFamily">fonts://Inter#Inter, $Default</FontFamily>
<FontFamily x:Key="ContentControlThemeFontFamily">fonts:Inter#Inter, $Default</FontFamily>
<Color x:Key="ThemeAccentColor">#CC119EDA</Color>
<Color x:Key="ThemeAccentColor2">#99119EDA</Color>
<Color x:Key="ThemeAccentColor3">#66119EDA</Color>

11
tests/Avalonia.Skia.UnitTests/Media/FontManagerImplTests.cs

@ -76,5 +76,16 @@ namespace Avalonia.Skia.UnitTests.Media
Assert.Throws<InvalidOperationException>(() => new Typeface("resm:Avalonia.Skia.UnitTests.Assets?assembly=Avalonia.Skia.UnitTests#Unknown").GlyphTypeface);
}
}
[Fact]
public void Should_Return_False_For_Unregistered_FontCollection_Uri()
{
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface.With(fontManagerImpl: new FontManagerImpl())))
{
var result = FontManager.Current.TryGetGlyphTypeface(new Typeface("fonts:invalid#Something"), out _);
Assert.False(result);
}
}
}
}

Loading…
Cancel
Save