diff --git a/src/Core/src/Fonts/FontManager.Windows.cs b/src/Core/src/Fonts/FontManager.Windows.cs index f1af4d246824..4cad39218e76 100644 --- a/src/Core/src/Fonts/FontManager.Windows.cs +++ b/src/Core/src/Fonts/FontManager.Windows.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -7,6 +6,7 @@ using Microsoft.Graphics.Canvas.Text; using Microsoft.Maui.ApplicationModel; using Microsoft.Maui.Storage; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; namespace Microsoft.Maui @@ -27,6 +27,12 @@ public class FontManager : IFontManager readonly IFontRegistrar _fontRegistrar; readonly IServiceProvider? _serviceProvider; + /// Value is cached to avoid the performance hit of accessing many times. + FontFamily? _defaultFontFamily; + + /// Value is cached to avoid the performance hit of accessing many times. + double? _defaultFontSize; + /// /// Creates a new instance. /// @@ -40,12 +46,24 @@ public FontManager(IFontRegistrar fontRegistrar, IServiceProvider? serviceProvid } /// - public FontFamily DefaultFontFamily => - (FontFamily)UI.Xaml.Application.Current.Resources[SystemFontFamily]; + public FontFamily DefaultFontFamily + { + get + { + _defaultFontFamily ??= (FontFamily)Application.Current.Resources[SystemFontFamily]; + return _defaultFontFamily; + } + } /// - public double DefaultFontSize => - (double)UI.Xaml.Application.Current.Resources[SystemFontSize]; + public double DefaultFontSize + { + get + { + _defaultFontSize ??= (double)Application.Current.Resources[SystemFontSize]; + return _defaultFontSize.Value; + } + } /// public FontFamily GetFontFamily(Font font) diff --git a/src/Essentials/src/AppInfo/AppInfo.shared.cs b/src/Essentials/src/AppInfo/AppInfo.shared.cs index badcde29d1c8..97ed62443c75 100644 --- a/src/Essentials/src/AppInfo/AppInfo.shared.cs +++ b/src/Essentials/src/AppInfo/AppInfo.shared.cs @@ -130,7 +130,7 @@ public enum AppPackagingModel /// The app is packaged and can be distributed through an MSIX or the store. Packaged, - /// The app is unpcakged and can be distributed as a collection of executable files. + /// The app is unpackaged and can be distributed as a collection of executable files. Unpackaged, } } diff --git a/src/Essentials/src/AppInfo/AppInfo.uwp.cs b/src/Essentials/src/AppInfo/AppInfo.uwp.cs index 21087fb3b9f4..14b849158533 100644 --- a/src/Essentials/src/AppInfo/AppInfo.uwp.cs +++ b/src/Essentials/src/AppInfo/AppInfo.uwp.cs @@ -18,7 +18,7 @@ class AppInfoImplementation : IAppInfo readonly ActiveWindowTracker _activeWindowTracker; /// - /// Intializes a new object with default values. + /// Initializes a new object with default values. /// public AppInfoImplementation() {