[SOLVED] Text seems to fade or "distort" after X amount of strings drawn


I am new to the forums here but I have been messing with the MonoGame library for sometime. I’m having an issue with SpriteBatch.DrawString(); (it may not be an issue with the method itself but I can’t find a similar problem anywhere else).

The problem is easier to describe in an image as opposed to text:

As you can see, the text that reads, “Copyright 2018-2019 SolitudeDevelopment.” is slightly darker and a bit odd looking in comparison to the other strings. It’s not as “crisp.” This pastebin links to the code I have used to render the strings, it seems to be standard: Code for string drawing

Thank you :slight_smile:

Kneejerk guess is that either your draw position or origin are being given a *.5 value. Ex: Vector2(3.5, 6.5) as opposed to a rounded value: Vector2(3, 6)

Not a bad thought, but other strings use float values and there’s no issue with it.
However, I did try your solution and to no avail :frowning:

EDIT: Funny enough, I had this same issue back when I was using Slick2D.

Do you see the same result with a different font?

It doesn’t necessarily matter. It all depends on how the rasterizer resolves the non integer pixels in that particular position. I’ve had results where visuals on the left side of the screen look fine, but an integer translation to the right side of the screen show a missing pixel.

Unless the text is moving, it’s generally a good idea to resolve the position to integers just prior to rendering. If nothing else it’s quick test. Do this…

mySpriteBatch.DrawString(myFont, "blahblah", myPosition.ToPoint().ToVector2());

See if that makes the problem go away. If it doesn’t, you’ve got other issues :smiley:


@Trinith, wow, that worked! No more blurry text! I don’t know if it was the position or origin causing it so I applied that solution to either one. Thank you very much :smiley:

I’ll continue to use this solution and if the issue pops up again I’ll re-post.

@TheKelsam, for reference, it did happen with every font I’ve used now and in the past, any size, any format.

1 Like