Julien Lebosquain
6 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
18 additions and
3 deletions
-
src/Avalonia.Base/Media/FontManager.cs
-
tests/Avalonia.Skia.UnitTests/Media/CustomFontManagerImpl.cs
-
tests/Avalonia.UnitTests/UnitTestApplication.cs
|
|
|
@ -15,7 +15,7 @@ namespace Avalonia.Media |
|
|
|
/// The font manager is used to query the system's installed fonts and is responsible for caching loaded fonts.
|
|
|
|
/// It is also responsible for the font fallback.
|
|
|
|
/// </summary>
|
|
|
|
public sealed class FontManager |
|
|
|
public sealed class FontManager : IDisposable |
|
|
|
{ |
|
|
|
internal static Uri SystemFontsKey = new Uri("fonts:SystemFonts", UriKind.Absolute); |
|
|
|
|
|
|
|
@ -368,5 +368,14 @@ namespace Avalonia.Media |
|
|
|
|
|
|
|
return defaultFontFamilyName; |
|
|
|
} |
|
|
|
|
|
|
|
void IDisposable.Dispose() |
|
|
|
{ |
|
|
|
foreach (var pair in _fontCollections) |
|
|
|
pair.Value.Dispose(); |
|
|
|
|
|
|
|
_fontCollections.Clear(); |
|
|
|
(PlatformImpl as IDisposable)?.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -10,7 +10,7 @@ using System.IO; |
|
|
|
|
|
|
|
namespace Avalonia.Skia.UnitTests.Media |
|
|
|
{ |
|
|
|
public class CustomFontManagerImpl : IFontManagerImpl |
|
|
|
public class CustomFontManagerImpl : IFontManagerImpl, IDisposable |
|
|
|
{ |
|
|
|
private readonly string _defaultFamilyName; |
|
|
|
private readonly IFontCollection _customFonts; |
|
|
|
@ -94,5 +94,10 @@ namespace Avalonia.Skia.UnitTests.Media |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
_customFonts.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -51,7 +51,8 @@ namespace Avalonia.UnitTests |
|
|
|
} |
|
|
|
|
|
|
|
((ToolTipService)AvaloniaLocator.Current.GetService<IToolTipService>())?.Dispose(); |
|
|
|
|
|
|
|
(AvaloniaLocator.Current.GetService<FontManager>() as IDisposable)?.Dispose(); |
|
|
|
|
|
|
|
Dispatcher.ResetForUnitTests(); |
|
|
|
scope.Dispose(); |
|
|
|
Dispatcher.ResetBeforeUnitTests(); |
|
|
|
|