Share Fonts in Maui

Kannan C 21 Reputation points
2022-09-16T12:05:43.293+00:00

In Xamarin Forms fonts are embedded into the library. So, the Font files in library files are working fine. I can share/use the library without issue.

Same behavior how can I use it in Maui. I just want to share the font files.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,542 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 43,371 Reputation points Microsoft Vendor
    2022-09-19T08:13:51.96+00:00

    Hello,

    It is not Embedded Resource but MAUIFont in MAUI, you could refer to Fonts in .NET MAUI to get the following content:

    Fonts can also be added to other folders of your app project. However, in this scenario their build action must be manually set to MauiFont in the Properties window.

    Therefore, you need to change the property of font file to MauiFont in your library.

    Then, after adding referrence, you could use the font file as the following:

       fonts.AddFont("YourFontFile.ttf", "FontName");  
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.