diff --git a/src/Core/src/ImageSources/FontImageSourceService/FontImageSourceService.Windows.cs b/src/Core/src/ImageSources/FontImageSourceService/FontImageSourceService.Windows.cs index 56567b43cbf7..91dbff0e08cc 100644 --- a/src/Core/src/ImageSources/FontImageSourceService/FontImageSourceService.Windows.cs +++ b/src/Core/src/ImageSources/FontImageSourceService/FontImageSourceService.Windows.cs @@ -6,8 +6,10 @@ using Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas.Text; using Microsoft.Graphics.Canvas.UI.Xaml; +using Microsoft.Maui.ApplicationModel; using Microsoft.Maui.Devices; using Microsoft.Maui.Graphics; +using Microsoft.Maui.Storage; using WImageSource = Microsoft.UI.Xaml.Media.ImageSource; namespace Microsoft.Maui @@ -122,6 +124,18 @@ string GetFontSource(IFontImageSource imageSource) } } + // unpackaged apps can't load files using packaged schemes + if (!AppInfoUtils.IsPackagedApp) + { + var fontUri = new Uri(fontSource, UriKind.RelativeOrAbsolute); + + var path = fontUri.AbsolutePath.TrimStart('/'); + if (FileSystemUtils.TryGetAppPackageFileUri(path, out var uri)) + { + fontSource = uri + fontUri.Fragment; + } + } + return fontSource; } }