.NET MAUI app throws Java.Lang.RuntimeException with Font asset not found /data/user/0/app.xyz/cache/telerikfont.ttf

1 Answer 50 Views
General Discussions
Patrick
Top achievements
Rank 1
Patrick asked on 06 Dec 2024, 09:57 AM

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.

 

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 10 Dec 2024, 11:37 AM | edited on 10 Dec 2024, 11:38 AM

Hi Patrick,

I tested the scenario in a sample app and cannot reproduce the exception. Could you please send a sample in which the issue happens? 

Check whether you use the Telerik MAUI 8.0.0 version and let me know whether the issue happens in release or debug mode? Also delete bin and obj folders then build the app and test.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 1
Answers by
Didi
Telerik team
Share this question
or