Browse Source
Merge pull request #10579 from Gillibald/fixes/invalidFontCollectionUri
Only try to create embedded font collections for valid source Uris
pull/10582/head
Max Katz
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
13 additions and
2 deletions
-
src/Avalonia.Base/Media/FontManager.cs
-
src/Avalonia.Themes.Simple/Accents/Base.xaml
-
tests/Avalonia.Skia.UnitTests/Media/FontManagerImplTests.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); |
|
|
|
|
|
|
|
|
|
|
|
@ -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> |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|