In order to simplify releases, I’m collecting all of my XNA tools, classes and sample code into a single XNAExtras package. You can find a link to the latest version of XNAExtras here.
This first XNAExtras release contains updated versions of BMFontGen and BitmapFont:
Added font face name, size and style info to XML font descriptor file.
Added option to prevent custom glyphs from being tinted when drawing colored text.
Fixed crash when cancelling the font select dialog (oops!).
Changed code to prevent substitute fonts being used when the requested font is unavailable.
Changed “origin” attribute in font XML files to “loc” (location) since this is a better description and is more consistent with usage in sprite/texture XML files. Fonts created with “origin” attribute are still supported.
Removed support for ClearType anti-aliasing.
Fixed path problem whereby font image files weren’t found if the font was in a subdirectory.
Changed GlyphInfo struct (in BitmapFont) to use bytes/sbytes instead of ints.
Added support for new features in XML font file.
Added TextBox method to format left, center or right-aligned text in a rectangle.
Added Save/RestoreState methods to save and restore the font rendering state.
Thanks to David Wyand, Thijs Kruithof (Gleoi), Jim Welch and Roger Bocksnick for their comments/suggestions.
In addition, a few extra classes (and associated demos) have been added:
TextBox : Class to manage more complex text rendering, includes support for rendering text borders to create UI elements. Makes use of BitmapFont and Border. (TextBox.cs)
Border : Class to draw sprite-based borders around rectangles. Makes use of XSprite. (Border.cs)
XSprite : Classes to manage sprites. Supports shared textures, animated sprites, different framerates for each sprite, keeps sprites sorted by depth (so that transparency works correctly) and allows sprites to be loaded from an XML descriptor file. (XSprite.cs, XSpriteBase.cs, XSpriteManager.cs, TexturePool.cs)
Note that I wasn’t originally intending to include the XSprite classes with this release because there are still a few features that I wanted to add and I still need to finish the sprite demo to make it more interesting. However, because the Border class relies on it, you get to see a preview of these classes.
I’ll probably talk about these classes and demos more in upcoming posts. As always, comments, suggestions and bug reports are welcome.