We recently discovered that our .NET MAUI APP (8.0.92) throws a Java.Lang.RuntimeException with Font asset not found /data/user/0/app.xyz/cache/telerikfont.ttf.
Here's the full exception detail:
Java.Lang.RuntimeException:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop, Version=7.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065)
at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (Java.Interop, Version=7.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065)
at Android.Graphics.Typeface.CreateFromAsset (Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065)
at Microsoft.Maui.FontManager.LoadTypefaceFromAsset (Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
We do have a "Font" folder in our Application, but in our understanding this shouldn't be a problem anymore.
We register those fonts, which are in the Fonts folder:
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("FontAwesomePro-Light-300.otf", "FontAwesomeLight");
fonts.AddFont("FontAwesomePro-Regular-400.otf", "FontAwesomeRegular");
fonts.AddFont("FontAwesomePro-Solid-900.otf", "FontAwesomeSolid");
});
In addition to that, we have a custom CustomFontsProvider for the fonts we use in the RadPdfProcessing lib for .NET MAUI. Those fonts are however in the RAW.
public class CustomFontsProvider : Telerik.Windows.Documents.Extensibility.FontsProviderBase
{
public override byte[] GetFontData(Telerik.Windows.Documents.Core.Fonts.FontProperties fontProperties)
{
string fontFileName = fontProperties.FontFamilyName + ".ttf";
if (fontProperties.FontFamilyName == "Verdana")
{
if (fontProperties.FontStyle == FontStyles.Normal && fontProperties.FontWeight == FontWeights.Normal)
{
fontFileName = $"Verdana.ttf";
}
elseif (fontProperties.FontWeight == FontWeights.Bold)
{
fontFileName = $"Verdana-Bold.ttf";
}
}
var fileStream = FileSystem.Current.OpenAppPackageFileAsync(fontFileName).GetAwaiter().GetResult();
var memoryStream = new MemoryStream();
fileStream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
}
How can we resolve this issue? Any support is appreciated.