Sprite Font Importer

In Monogame it is really hard to draw text that looks good. The Spirte Font Importer does a really poor job especially with smaller and thinner text. This was also the case in XNA but why copy it? Text is really importent for games and I am wondering why it is so hard to get good looking fonts into monogame. It looks like a easy task to fix.

Did you try changing the TextureFormat of the spritefont to NoChange?
The default value of this property is Compressed and it really looks awful. :slight_smile:

It still doesn’t look good. With Segoe UI size 12 some letters are thicker compared to others: image

The problem is that current Sprite Font Importer is using little bit obsolete tech so generated bitmap is very poor quality and it has very little to do with texture compression. The bitmap generator itself is crap.

There are better ways how to generate fonts including technique called signed distance field. You can generate fonts, which you can scale without loss of quality these days, but MonoGame is bit sleeping in XNA age.

I was seriously thinking to add support for new “fonts” in MonoGame, but it would need some changes (minor) and work and I don’t have the time to do it alone. So if anyone is interested, shout.

It may be an older technique, but it is still very widely used. The rasterizer we use in the content pipeline is FreeType, which usually gives a cleaner result than the GDI rasterizer that XNA used, but does have some issues with some font hinting, and Segoe UI is one of those (the fat verticals). FreeType 2.64 (released a few weeks ago) introduced a new bytecode hinting mode that drastically improves the rendering, as shown here.

Signed Distance Field (SDF) fonts are certainly possible. I’ve used them before in TY the Tasmanian Tiger on the Windows Store. It didn’t use the content pipeline (it used an external tool to generate the SDF data for each glyph stored in a custom data file), and was part of a font cache system that only loaded the glyphs being used at that point in time (very handy for support of Asian languages and the several thousands glyphs they use). SDF images need a special shader for rendering. While it’s not a difficult shader, but it’s also something to keep in mind.

I have been considering making these available, but they will need a lot of cleaning up first (and the SDF font glyph generation tool ported from C++ to C#).

The problem with current implementation is not the technique itself, but the rasterizer lib (or it’s usage, i didn’t check deep enough). Empty Keys UI supports not just MonoGame, but other engines and I can tell that MonoGame has the worst quality of sprite fonts. Look at Xenko engine for example. So even “old” bitmap fonts can be so much better.

About SDF, yes, I know what is needed. I just finished SDF support for EK UI Xenko version for it. I thought it would be cool if we can add something similar directly to MonoGame. I can create Issue on GitHub, if you are willing to think about it.

So I just need to wait for SharpFont to update to the new FreeType version?