Skip to content
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

Unable to load font 'monospace' #11422

Closed
tranb3r opened this issue Nov 16, 2022 · 9 comments · Fixed by #15010
Closed

Unable to load font 'monospace' #11422

tranb3r opened this issue Nov 16, 2022 · 9 comments · Fixed by #15010
Assignees
Labels
area-fonts Custom fonts and Font related API's fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/android 🤖 t/bug Something isn't working

Comments

@tranb3r
Copy link

tranb3r commented Nov 16, 2022

Description

I'm using the 'monospace' font in my xamarin forms app.
When migrating to maui, it looks like it does not work anymore

Steps to Reproduce

  1. Create a maui app for android
  2. Create a label using the 'monospace' font
  3. Run the app

<Label FontFamily="monospace" Text="Hello world" />

Link to public reproduction project repository

...

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

...

Did you find any workaround?

No response

Relevant log output

[Microsoft.Maui.FontManager] [Warning] Unable to load font 'monospace' from assets.Java.Lang.RuntimeException: Font asset not found monospace
[Microsoft.Maui.FontManager]    at Java.Interop.JniEnvironment.StaticMethods.CallStaticObjectMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:line 12890
[Microsoft.Maui.FontManager]    at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeObjectMethod(String encodedMember, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:line 95
[Microsoft.Maui.FontManager]    at Android.Graphics.Typeface.CreateFromAsset(AssetManager mgr, String path) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-33/mcw/Android.Graphics.Typeface.cs:line 613
[Microsoft.Maui.FontManager]    at Microsoft.Maui.FontManager.LoadTypefaceFromAsset(String fontfamily, Boolean warning) in D:\a\_work\1\s\src\Core\src\Fonts\FontManager.Android.cs:line 122
[Microsoft.Maui.FontManager]   --- End of managed Java.Lang.RuntimeException stack trace ---
[Microsoft.Maui.FontManager] java.lang.RuntimeException: Font asset not found monospace
[Microsoft.Maui.FontManager] 	at android.graphics.Typeface.createFromAsset(Typeface.java:1044)
[Microsoft.Maui.FontManager] 	at crc6452ffdc5b34af3a0f.NavigationViewFragment.n_onCreateView(Native Method)
[Microsoft.Maui.FontManager] 	at crc6452ffdc5b34af3a0f.NavigationViewFragment.onCreateView(NavigationViewFragment.java:39)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1764)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
[Microsoft.Maui.FontManager] 	at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
[Microsoft.Maui.FontManager] 	at android.os.Handler.handleCallback(Handler.java:942)
[Microsoft.Maui.FontManager] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[Microsoft.Maui.FontManager] 	at android.os.Looper.loopOnce(Looper.java:201)
[Microsoft.Maui.FontManager] 	at android.os.Looper.loop(Looper.java:288)
[Microsoft.Maui.FontManager] 	at android.app.ActivityThread.main(ActivityThread.java:7898)
[Microsoft.Maui.FontManager] 	at java.lang.reflect.Method.invoke(Native Method)
[Microsoft.Maui.FontManager] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
[Microsoft.Maui.FontManager] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
@tranb3r tranb3r added the t/bug Something isn't working label Nov 16, 2022
@jsuarezruiz jsuarezruiz added area-fonts Custom fonts and Font related API's platform/android 🤖 labels Nov 17, 2022
@jsuarezruiz
Copy link
Contributor

Are you trying in a specific device or also emulators?

@tranb3r
Copy link
Author

tranb3r commented Nov 17, 2022

Emulator for now

@ehoward0018
Copy link

Happening on Windows 10 as well:

`Microsoft.Maui.FontRegistrar: Warning: Unable to load font 'Roboto'.

System.IO.FileNotFoundException: Native font with the name Roboto-Black.tff was not found.
at Microsoft.Maui.FontRegistrar.LoadNativeAppFont(String font, String filename, String alias)
at Microsoft.Maui.FontRegistrar.GetFont(String font)`

@rachelkang rachelkang added the s/needs-repro Attach a solution or code which reproduces the issue label Nov 23, 2022
@ghost
Copy link

ghost commented Nov 23, 2022

Hi @tranb3r. 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.

@ehoward0018
Copy link

This happens to the base .net MAUI 7 project. Add any font to the base fonts folder, add it to the MauiProgram.cs file and it fails.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Nov 23, 2022
@tranb3r
Copy link
Author

tranb3r commented Nov 23, 2022

Here is a repro : https://github.com/tranb3r/Issues/tree/main/MauiAppFontMonospace
Please note that there is an exception, but the label is actually displayed correctly with the correct font.

@jsuarezruiz jsuarezruiz removed the s/needs-attention Issue has more information and needs another look label Nov 24, 2022
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Nov 24, 2022
@dotnet dotnet deleted a comment Nov 24, 2022
@jsuarezruiz
Copy link
Contributor

Here is a repro : https://github.com/tranb3r/Issues/tree/main/MauiAppFontMonospace
Please note that there is an exception, but the label is actually displayed correctly with the correct font.

Could you share the Exception StackTrace?

@jsuarezruiz jsuarezruiz added the s/needs-info Issue needs more info from the author label Nov 24, 2022
@ghost
Copy link

ghost commented Nov 24, 2022

Hi @tranb3r. 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.

@tranb3r
Copy link
Author

tranb3r commented Nov 24, 2022

@jsuarezruiz The stack trace is in the description of this issue.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Nov 24, 2022
@jsuarezruiz jsuarezruiz self-assigned this May 9, 2023
@jsuarezruiz jsuarezruiz removed the s/needs-attention Issue has more information and needs another look label May 9, 2023
@jsuarezruiz jsuarezruiz moved this to In Progress in MAUI SDK Ongoing May 11, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing May 19, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 May 24, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Jun 21, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-fonts Custom fonts and Font related API's fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants