diff --git a/src/Uno.UI/UI/Xaml/Extensions/FontHelper.Android.cs b/src/Uno.UI/UI/Xaml/Extensions/FontHelper.Android.cs index 34843d4c6c23..ea265afe1613 100644 --- a/src/Uno.UI/UI/Xaml/Extensions/FontHelper.Android.cs +++ b/src/Uno.UI/UI/Xaml/Extensions/FontHelper.Android.cs @@ -64,7 +64,8 @@ internal partial class FontHelper // with UWP. Keep this behavior for backward compatibility. var legacySource = source.TrimStart("/assets/", StringComparison.OrdinalIgnoreCase); - if (!TryLoadFromPath(style, legacySource, out typeface)) + // The path for AndroidAssets is not encoded, unlike assets processed by the RetargetAssets tool. + if (!TryLoadFromPath(style, legacySource, out typeface, encodePath: false)) { throw new InvalidOperationException($"Unable to find [{fontFamily.Source}] from the application's assets."); } @@ -99,7 +100,7 @@ internal partial class FontHelper } } - private static bool TryLoadFromPath(TypefaceStyle style, string source, out Typeface? typeface) + private static bool TryLoadFromPath(TypefaceStyle style, string source, out Typeface? typeface, bool encodePath = true) { source = FontFamilyHelper.RemoveHashFamilyName(source); @@ -108,7 +109,9 @@ private static bool TryLoadFromPath(TypefaceStyle style, string source, out Type typeof(FontHelper).Log().Debug($"Searching for font as asset [{source}]"); } - var encodedSource = AndroidResourceNameEncoder.EncodeFileSystemPath(source, prefix: ""); + var encodedSource = encodePath + ? AndroidResourceNameEncoder.EncodeFileSystemPath(source, prefix: "") + : source; // We need to lookup assets manually, as assets are stored this way by android, but windows // is case insensitive.