xyginext  0.2.0
Second generation of xygine game creation framework
Public Member Functions | List of all members
xy::BitmapFont Class Referencefinal

Bitmap font class. Bitmap fonts are created by loading a font atlas with the following layout: 10 characters wide, by 10 characters high, starting with ASCII character 32 (space) and ending with ASCII character 126 (tilde). Some or all of the characters may be implemented but unimplemented characters should be left blank. As bitmap fonts are very simplistic anything other than ASCII encoding is not supported. More...

#include <BitmapFont.hpp>

Public Member Functions

 BitmapFont (const std::string &path)
 Constructor. More...
 
bool loadTextureFromFile (const std::string &)
 Load a texture from file to use for this font. More...
 
sf::FloatRect getGlyph (char) const
 returns the texture rect for the requested character
 
const sf::Texture * getTexture () const
 Returns a pointer to the loaded texture.
 
sf::Vector2f getCharacterSize () const
 Returns the width / height of a character.
 

Detailed Description

Bitmap font class. Bitmap fonts are created by loading a font atlas with the following layout: 10 characters wide, by 10 characters high, starting with ASCII character 32 (space) and ending with ASCII character 126 (tilde). Some or all of the characters may be implemented but unimplemented characters should be left blank. As bitmap fonts are very simplistic anything other than ASCII encoding is not supported.

Bitmap fonts are used with the BitmapText and BitmapTextSystem classes. As BitmapFonts contain their own texture instances they must live at least as long as any BitmapText instances which use them, and should be resource managed as regular fonts, preferably with xy::ResourceHandler

See also
BitmapText

Constructor & Destructor Documentation

◆ BitmapFont()

xy::BitmapFont::BitmapFont ( const std::string &  path)
explicit

Constructor.

Parameters
pathString containing the path to a texture atlas containing the bitmap font.

Member Function Documentation

◆ loadTextureFromFile()

bool xy::BitmapFont::loadTextureFromFile ( const std::string &  )

Load a texture from file to use for this font.

Returns
True on success else false on failure