An utility that generates a bitmap-font texture (sprite sheet) that is compatible with the SpriteFont and FontTextureProcessor included in MonoGame and FNA (successors to the Microsoft's XNA Framework).
Get the latest version in Releases, unzip it to a folder,
and run xfontgen
.
The app can be run on the following platforms:
- Windows 10+ (x64)
- Linux (Debian 10+/Ubuntu 18.04+/Fedora 36+) (x64)
- macOS 10.15+ (x64)
Executing the app requires .NET 8.0 Runtime to be installed.
When adding the generated PNG texture to your content pipeline, make sure to set the following content settings:
- Importer – Texture Importer
- Processor – Font Texture
- First Character – Should match "Min char"
Such a sprite font can then be loaded into the SpriteFont
object:
_spriteFont = Content.Load<SpriteFont>("TestFont");
Which can then be drawn by regular means of SpriteBatch.DrawString
as follows:
_spriteBatch.Begin();
_spriteBatch.DrawString(_spriteFont, "The quick brown fox\r\njumps over the lazy dog.",
new Vector2(30, 30), Color.MediumSpringGreen);
_spriteBatch.End();
Code licensed under the MIT License.