CSharpShellApp icon indicating copy to clipboard operation
CSharpShellApp copied to clipboard

Resource not found

Open PeterKaa1 opened this issue 2 years ago • 3 comments

Resource "Resources/Fonts/LilitaOne-Regular.ttf" not found.

Why?? The path is correct.

PeterKaa1 avatar Nov 07 '23 19:11 PeterKaa1

i assume that we apply new font to a Label. First, in mauiprogram register your font to the app builder by the builder's ConfigureFont extension method:

var builder = MauiApp.CreateBuilder();
    builder.UseMauiApp<App>()
    .UseMauiCommunityToolkit()
    .ConfigureFonts(fonts =>{
        .fonts.AddFont("Resources/Fonts/Aquire-Bold.otf", "Aquire");
    });

the app will automatically search the font in the local project directory, you can then consume it like so:<Label Text="Aquire in Bold" FontFamily="Aquire"/>. This works on me you could try it huhu😅

noubiex avatar Nov 08 '23 02:11 noubiex

but after doing so try exporing it as apk.

noubiex avatar Nov 08 '23 03:11 noubiex

To clarify, fonts work in an independent APK but not inside C# Shell? Is replacing

fonts.AddFont("Resources/Fonts/Aquire-Bold.otf", "Aquire");

with

fonts.AddEmbeddedResourceFont(System.Reflection.Assembly.GetExecutingAssembly(), "Resources/Fonts/Aquire-Bold.otf", "Aquire");

a workaround here?

Edit: Also try changing "Resources/Fonts/Aquire-Bold.otf" to only "Aquire-Bold.otf"

radimitrov avatar Nov 10 '23 11:11 radimitrov