Thanks. I did the font system myself, yes. I first loaded all of the character images into a std::Vector of a struct containing a character which represents that image and the sf::Image itself, so it was like
struct CharImg
{
char cha;
sf::Image img;
};
(using integer ascii codes is useful for this so you can loop-load them)
Then I made a function which gets a desired character image pointer, like so:
sf::Image* Font::GetCharImage(char character)
{
for(int i = 0; i < chars.size(); i++)
{
if(chars[i]->cha == character)
return &chars[i]->img;
}
return 0;
}
Then for the font drawing, I do something like this:
void Font::DrawText(std::string string, sf::Vector2f position, sf::Vector2f scale, sf::RenderWindow* rwindow)
{
std::vector<sf::Sprite> spriteVector;
sf::Vector2f nextpos(position);
for(int i = 0; i < string.length(); i++)
{
if(string[i] == '\n')
nextpos = sf::Vector2f(position.x, nextpos.y + (10 * scale.y));
else if(string[i] == ' ')
nextpos.x += (7 * scale.x);
else
{
spriteVector.push_back(sf::Sprite(*GetCharImage(string[i]), nextpos, scale));
nextpos.x += (7 * scale.x);
}
}
for(int i = 0; i < spriteVector.size(); i++)
{
rwindow->Draw(spriteVector[i]);
}
}
So not super efficient, creating a vector of the sprites each time I want to draw the text, but I wasn't concerned with that at the time since I was on a time limit for a small competition on another forum.
As you can see, for a newline I take the initial position and add some Y to it, that will put me below the first char in the text. For a space I simply advance the X position and for any other char I display the image and advance the X position.
Hope this helped!