Page 1 of 1

SpriteFont and non-'freetype based' fonts

Posted: Wed Nov 16, 2011 10:13 am
by twarpie
As far as I understand the code, OpenRA normally takes TTF fonts and converts a certain range of glyphs into Sprites using FreeType, which are then used in the DrawText*(..) and Measure(..) methods.

Fonts already in bitmap form don't need the FreeType render step, so I was wondering what the 'correct' approach here would be to support non-freetype-needing SpriteFonts? One approach could be an interface between users of SpriteFont and actual SpriteFont implementations, another could be taking the initialization code out of SpriteFont and make it purely a glyph container with added DrawText etc methods.

Any ideas?

Posted: Wed Nov 16, 2011 8:27 pm
by chrisf
You can use most popular bitmap font formats with FreeType as well.

Posted: Wed Nov 16, 2011 10:06 pm
by twarpie
chrisf wrote: You can use most popular bitmap font formats with FreeType as well.
Yes, but in this case it's a decoded TD/RA95 'fnt' file. I've implemented a FntReader to be able to use the original fnt fonts from RA95 in OpenRA and am now wondering as to how to convert the bitmaps to glyphs SpriteFont can use.