MockFontManagerImpl.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections.Generic;
  2. using System.Globalization;
  3. using Avalonia.Media;
  4. using Avalonia.Media.Fonts;
  5. using Avalonia.Platform;
  6. namespace Avalonia.UnitTests
  7. {
  8. public class MockFontManagerImpl : IFontManagerImpl
  9. {
  10. private readonly string _defaultFamilyName;
  11. public MockFontManagerImpl(string defaultFamilyName = "Default")
  12. {
  13. _defaultFamilyName = defaultFamilyName;
  14. }
  15. public string GetDefaultFontFamilyName()
  16. {
  17. return _defaultFamilyName;
  18. }
  19. public IEnumerable<string> GetInstalledFontFamilyNames(bool checkForUpdates = false)
  20. {
  21. return new[] { _defaultFamilyName };
  22. }
  23. public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight, FontFamily fontFamily,
  24. CultureInfo culture, out FontKey fontKey)
  25. {
  26. fontKey = default;
  27. return false;
  28. }
  29. public IGlyphTypefaceImpl CreateGlyphTypeface(Typeface typeface)
  30. {
  31. return new MockGlyphTypeface();
  32. }
  33. }
  34. }