Archive

Posts Tagged ‘fonts’

Auto-generate Custom Bitmap Fonts for XNA

2010/07/10 8 comments

image

UPDATE: The tool mentioned here is made by the fine folks at NUBIK

I recently spent many an hour trying to create a glow-effect for fonts in XNA using the XNA Bitmap Font Maker tool and Photoshop only to discover that it is yet another thing beyond my feeble artistic and technical ability. I thought I understood alpha-channels…what was a XNA noob to do?

Enter the free, rather schmick[1] tool – SpriteFont 2 that generates bitmap font sheets with glow, drop shadow, outline effects and more.  It’s wizard-style interface allows you to quickly pick a font, size, style, effects all while displaying a rather nice preview of what is to come.  Once you are happy hit Export and voila – instant BMP, JPEG, PNG etc that can be immediately added to your XNA project as a texture.

When dragging into your project you must set the Content Processor to Spite Font Texture – XNA Framework.  XNA defaults to Texture – XNA Framework or something or other.

image

Apparently, .spritefont files get compiled to an image anyway so whether you decide to use them or pre-generated font bitmaps, the result is the same by the time you load the font in your XNA program via:

_spriteFont = Content.Load<SpriteFont>("Fonts/my spiffy font");

Just be sure that you rasterise fonts from the redistributable XNA font list else the men in black will come a-knocking on your door.

Here’s an example of how I use the fonts in my XNA space simulator thus far.  Here I am using fonts in the multi-function displays  – the Primary Flight Display (PFD) (showing auto-pilots) and the Navigational Display (ND) at bottom-left and bottom-centre respectively.  The PFD draws fonts in the ‘speedo’ ticker-tape and the ND shows ecliptic azimuth via transformed text on the large dial.


[1] schmick, adjective; meaning ‘very cool’.  seems to be an Australian slang word. yay! we invented something Winking smile

Categories: Development Tags: ,