16
Feature requests / Re: Make sf::Font abstract, in order to make sf::Text re-usable for bitmap fonts
« on: June 28, 2014, 11:34:47 pm »I just grab a texture which has all the letters. The constructor also takes a "mapping" from characters to indices. Otherwise I mostly copied the interface of sf::Font, returning an sf::Glyph, and not supporting italic/bold/...
Is your bitmap font a monospace one (all letters have the same width and height) ? If it's the case, your bitmap font class doesn't need to return a glyph, a simple texture sub rectangle is enough, and the API will be much simpler than sf::Font's one. A simple bitmap font is merely a tileset, and your bitmap texts are tilemaps.
Feel free to have a look at my implementation of BitmapFont/BitmapText if you want (I closely followed sf::Font/sf::Text semantics). See screenshot.
On a side note, sf::Font also supports bitmap fonts, and rendering at small size has been fixed in the upcoming 2.2 release, making custom BitmapFont classes quite useless (except if you really need an image).