[SOLVED] bitmapfont.MeasureString() doesn't measure space correctly

Hey everyone!

I wrote a method that can string dialogue that is made up of different spritefonts/bitmapfonts together seamlessly, allowing me to bold or italicize words in the middle of character dialogue. This requires me to do all sorts of surgery to strings and stringbuilders while knowing the width of the dialogue so far (including the spaces between words).

I recently began using Monogame.Extended for the nicer fonts, but I noticed that when I measure a single space the value returns as “1”. Then, I tried measuring the width of a couple things:

" " : 1px (single space)
“you” : 30px (word, no space)
“you " 32px (space after the word)
" you”: 35px (space before the word)

Maybe this is due to some setting in BMFont? I’m not sure. Any thoughts on why this might be measuring so inconsistently?

In true “publicly asking for help” fashion, I figured this out immediately after posting the question.

For anyone that might be running into this same problem for whatever reason, I needed to check “force offsets to zero” in the “Export Options” in BMFont.

I’m glad you figured it out. This one could have been difficult to solve :wink:

We implemented MeasureString to behave exactly the same way as the equivalent method for SpriteFont. Of course it’s always possible that something is broken but that’s the intention anyway.

I suspected that I was just saving the font incorrectly somehow, and I’m glad that was the case.For the last three years we’ve hated how bad the fonts in our game look; I’m really happy that there’s a solution to that.

Hopefully Extended works well with console ports, too! Has anyone tried yet?