-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.Maui.FontManager: Warning: Unable to load font 'sans-serif-medium' from assets. #13239
Comments
Hi @yangbocheng. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
So I see that you have both Would you mind try:
Just trying to see which one of these is the culprit, although it almost has to be the .NET MAUI Toolkit I think... Thanks! |
Hi @yangbocheng. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
EDIT: Never mind, the error still occurs at runtime on Android despite the below fix. The below fix does fix the compiler error at build time, though. Looking at your reproduction sample, you need to fix a typo in You need to include the file extension when using . Current (Bug)fonts.AddFont("Font Awesome 6 Free-Solid-900", "f6"); // Missing `.otf` file extension Fixedfonts.AddFont("Font Awesome 6 Free-Solid-900.otf", "f6"); // Includes `.otf` file extension MauiProgram.CreateMauiApp()public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("Font Awesome 6 Free-Solid-900.otf", "f6"); // Includes `.otf` file extension
});
registerViewAndVM(builder.Services);
RegisterEssentials(builder.Services);
#if DEBUG
builder.Logging.AddDebug();
#endif
var z = builder.Build();
ServiceLocater.Init(z.Services);
return z;
} |
hello, i have updated this repo but this font error <ItemGroup>
<!--<PackageReference Include="CommunityToolkit.Maui" Version="4.0.0" />-->
<!--<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />-->
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.141-beta" />
</ItemGroup> |
Change the file name: |
i have changed the font file name as what has suggested, but the problem just stay the same here is updated git example |
Try to include font extension ".ttf".
To:
|
i have added in repos |
Hi have a similar error when porting a Xamarin.forms app to MAUI and test in iOS. //Joacim |
I was encountering this error, which had the added issue that I was then unable to hit breakpoints that I placed in my code for debugging in Visual Studio. The app would continue to run, but it was no longer possible to check on the state of the application to debug after the error was thrown! Workaround:
[...]
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
// Default fonts
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-SemiBold.ttf", "OpenSansSemiBold");
// Font added to address issue: https://github.com/dotnet/maui/issues/13239
// fonts.AddFont("OpenSans-Medium.ttf", "OpenSansMedium"); !! Still throws error !!
// Alias set to match error string
fonts.AddFont("OpenSans-Medium.ttf", "sans-serif-medium");
});
[...]
}
} For me, on the Android Emulator, the error was no longer thrown after adding this font with the With the error no longer being thrown, I could hit my breakpoints again without issue! |
I ran into the same error in my MAUI app, when running on an older Android device (OnePlus 3T running OxygenOS 9). It seems this phone does not have a built-in font with the name |
I am just now recently getting a similar error when debugging to android device. This had been working fine on previous versions on the same phone. Started happening on version 7.0.86. OpenSans-Semibold.tff is in the Fonts folder and the property Update: seems like it was case sensitive. Changing: |
For me, neither After updating to version
BUT(!), I no longer had the breakpoint issue (I can now hit breakpoints even after encountering the error; I am not even sure if these were actually related issues to begin with) I still need the alias to match the error string to resolve the error (as mentioned in my comment above): fonts.AddFont("OpenSans-Medium.ttf", "sans-serif-medium"); FYI |
I don't know if it's related, but I'm noticing right now that when built in |
From what I can tell this is fixed by #15759, please try again when that is released. If you still see any weird behavior then, feel free to open a new issue. Thanks! |
Description
There are no changes about fonts of project,
when start debuging a simple program just has added communitytoolkit.mvvm and use class:ObservableObject attr: [ObservableProperty] attr:[RelayCommand]
then font warning is appeared
how to slove it?
Steps to Reproduce
above all
Link to public reproduction project repository
above all
Version with bug
7.0 (current)
Last version that worked well
7.0 (current)
Affected platforms
Android
Affected platform versions
Pixel 5 - API 30 Android 11.0
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: