Spritefont style (bold, italic, etc) isn't working

Hello,

Longtime XNA user; new to MonoGame (v3.3). I’m in the process of porting my code-base (Windows “Desktop”) to MG.

First off, I want to start out saying thank you all for what you do!

My issue is with spritefonts and the rendered result not having the correct font style.

After getting everything ported over to MG, compiled and running, I noticed that none of our font styles are working: they’re all appearing “Regular” when rendered on screen (even though they have Bold, and the like, set in the spritefont file). Manipulating the “Size” tag alters the text size, as expected, so I know the file is loading properly; the only thing that doesn’t seem to work is the “Style”.

Has anyone experienced this or have any insight as to why this would be happening?

Thanks,
Richard

I ran into a similar issue today and was wondering if there has been any feedback on this?

Is anyone else running into this issue? What is your platform and setup? I want to look into this.

I ran into the issue by trying to set Arial font to bold on MonoGame.WindowsDX 3.4, after which I noticed that none of the styles have any effect at all. The spritefont file was generated using MonoGame Pipeline GUI tool.

I’m running Win 10 x64.

Try using BMFont.
http://www.angelcode.com/products/bmfont/

I’ve always got problems with spritefonts and this tool is extremely easy to use.

Thanks for the suggestion!

I also found a content pipeline extension for custom font processing here:


http://dylanwilson.net/bmfont-rendering-with-monogame-extended

Anyway, I resolved my issue by simply using font name “Arial Bold” instead of style “Bold”.

1 Like

That’s very interesting. Worked for me too. Then I tried “Arial Italic Bold” and that worked.

This needs to be placed in the documentation.

I have the same issue and i don’t want to use any additionnal extension because in the past i had many issues with extensions used for games projects.(compatibility issues for most cases and lack of updates).

How can i fix it without extension ?

Ok, i was using Verdana font (TrueType) and I have found a solution : Instead of using the style, i use “Verdana Bold” instead of “Veradana” for the font name.It’s working.
So if you want to use styles for a font, in fact you will have to get a font for regular, one for bold, one for italic etc
It’s the most clean and simple way to do it.

Thanks for posting the fix - changing the font name property to “Arial Bold” fixes the problem.

THanks everyone for the workarounds.

Regardless, this bug still exists as of today.

1 Like

For anyone else looking for answers on this problem. The builder code for importing the spritefont XML file is in FontDescriptionProcessor.cs where you can see that the Style tag is only used if (CurrentPlatform.OS == OS.Linux). So, if using Windows fonts then just use the FontName tag and ignore the Style tag. This should really be added to the comment for the tag.

1 Like