Frage

I am currently working in XNA 4.0 trying to render a font that I got. The font is rendered with this:

spriteBatch.DrawString(this.font, this.text, new Vector2(10, 10), this.color);

But some of my letters gets blurry and low quality (See image)

I have tried to change the SamplerState of the GraphicDevice but that does not seem to improve anything.

-Update- After testing one of the ideas were XNA would compress the text and in that case loosing quality i tried out to create my own font texture instead of generating one using a .spritefont. And then sending that into the contentloader, the results I managed to get was just slightly larger text but with the same artifacts. See Image

And I was now wondering if the problem still can have to do with compressing problems or if there could be another issue making the font get a lower quality in the program compared to using it ouside the program. The way I am currently loading my font is using

font= ContentManager.Load<SpriteFont>(FontPath);
War es hilfreich?

Lösung

It's because XNA uses compression for spritefonts. The possible workarounds are:

  • Use Nuclex framework, which includes an alternative font importer;
  • Make your own font texture, following the instructions from Shawn Hargreaves's blog;
  • In your SpriteFont definition, double the size of generated font, then draw it at half its size.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top