Custom fonts not working when uploading Maui Android project to Play Store

Mujtaba Ali Panjwani 25 Reputation points
2024-05-21T16:58:13.6333333+00:00

I have added custom fonts in the font directory of my Maui project's Resources directory and updated the MauiProgram.cs file accordingly. The fonts work fine when I deploy the application using Visual Studio, but when I publish the app and upload it to Play Store, the custom fonts are not working at all. Can someone please help me with this issue?

Thank you.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,833 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,207 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Joaquín Salas 20 Reputation points
    2024-11-09T06:46:44.04+00:00

    Good evening! I had the same issue, and after hours of trying different things (haha), I finally managed to fix it by updating the .csproj file in the main project. Initially, I had:

    <!-- Custom Fonts --> <MauiFont Include="Resources\Fonts*" />

    But what worked for me was specifying each font individually like this:

    <ItemGroup>

    <MauiFont Include="Resources/Fonts/LexendDeca-Black.ttf" Alias="Black" />

    <MauiFont Include="Resources/Fonts/LexendDeca-Bold.ttf" Alias="Bold" />

    <MauiFont Include="Resources/Fonts/LexendDeca-ExtraBold.ttf" Alias="ExtraBold" />

    <MauiFont Include="Resources/Fonts/LexendDeca-ExtraLight.ttf" Alias="ExtraLight" />

    <MauiFont Include="Resources/Fonts/LexendDeca-Light.ttf" Alias="Light" />

    <MauiFont Include="Resources/Fonts/LexendDeca-Medium.ttf" Alias="Medium" />

    <MauiFont Include="Resources/Fonts/LexendDeca-Regular.ttf" Alias="Regular" />

    <MauiFont Include="Resources/Fonts/LexendDeca-SemiBold.ttf" Alias="SemiBold" />

    <MauiFont Include="Resources/Fonts/LexendDeca-Thin.ttf" Alias="Thin" />

    <MauiFont Include="Resources/Fonts/MaterialIcons.ttf" Alias="MaterialIcons" />

    </ItemGroup>

    After making this change, the icons finally displayed correctly in Release mode, and I got rid of the issue where only an "X" would appear instead of the icon. I hope this helps someone else! Best regards.

    4 people found this answer helpful.

  2. Anton Moroder 0 Reputation points
    2024-05-29T12:34:47.2866667+00:00

    I solved the problem by publishing with visual studio version 17.10.0.

    0 comments No comments

  3. Dave 0 Reputation points
    2024-09-15T15:02:16.3433333+00:00

    @Norman Mackay "(happens randomly in debug too although several clean and rebuilds eventually fix this)." Unfortunate, but it works. Thank you.

    0 comments No comments

  4. Stefan Cuypers 0 Reputation points
    2024-10-03T11:45:39.02+00:00

    I'm experiencing the same issue in VS 17.11.4.

    Fonts work fine in debug mode, but when running in release mode they do not work.

    0 comments No comments

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.