Loading fonts on real Android device causes crash; works on emulator fine

I’m working in Visual Studio 2022 w/ Monogame Android templates porting an existing Monogame Win/Mac/Linux desktop title to Android. I’m learning a lot along the way, but I’ve hit a snag when it comes to basic displaying of text on real devices (P30 Lite, P30) vs. the emulator.

-Using prebuilt .xnb spritefronts from the desktop version of our title works under the emulator, but not on real hardware. (I assume this has to do perhaps with compression? I had to rebuild our graphics as our desktop version uses DXT compression, something it seems most real devices do not.)

-I followed the guide here: TrueType fonts | MonoGame Documentation and added a spritefont and accompying .ttf file via Content.mgcb with the spritefront set to build and the ttf file copy.

Again everything works like a charm under the emulator but immediately crashes on real hardware when it tries to load any font. I’ve tried different fonts without success.

I feel as if I am perhaps missing something basic. Any advice would be appreciated!

Some guesses are that either your device runs out of memory,
or the texture of the font is too big for the specs of the device.

Move the font as the very first thing you load, and check on the desktop what are the dimensions of font.Texture.Windth|Height.

Thanks for the advice. Unfortunately still no luck. I now have the font the very first thing that loads and the game crashes even faster now :slight_smile:

This is what my code currently looks like - it crashes right at the:
font = Content.Load(“fonts\font”); line

ok, you didn’t tell me about the font size, but the font size and character range are reasonably within limits. Do you have trimming enabled?

Do you get are error message/exception/stack trace of the error?

I did try disabling trimming. I also attempted a solution mentioned in this thread:

No luck so far. I’ve haven’t setup debugging when running on a real device yet. That’s my next thing to learn about Android development :slight_smile:

I really appreciate the advice so far! Thanks!

Are you building your .mgcb with an Android target?