Rich text class for SFML2. Allows the user to draw lines of text with different styles and colors.
C++
Pull request Compare This branch is 22 commits behind skyrpex:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitattributes
.gitignore
README.md
RichText.cpp
RichText.hpp

README.md

RichText

Rich text class for SFML2. Allows the user to draw lines of text with different styles and colors.

Author

How to use

  1. Include the header and the source to your project.
  2. Link to SFML2 (obviously :P!).

Repository

You can get the current development version from the git repository.

Example

#include "RichText.hpp"
#include <SFML/Graphics.hpp>

int main()
{
  sfe::RichText text;
  text << sf::Text::Bold << sf::Color::Cyan << "This"
    << sf::Text::Italic << sf::Color::White << " is cool "
    << sf::Text::Regular << sf::Color::Green << "mate"
    << sf::Color::White << ". "
    << sf::Text::Underlined << "I wish I could lick it!";

  text.setCharacterSize(25);
  text.setPosition(400, 300);
  text.setOrigin(text.getWidth()/2.f, text.getHeight()/2.f);

  sf::RenderWindow window;
  window.create(sf::VideoMode(800, 600), "Rich text");

  while(window.isOpen())
  {
    sf::Event event;
    while(window.pollEvent(event))
    {
      if(event.type == sf::Event::Closed)
        window.close();
    }

    window.clear();
    window.draw(text);
    window.display();
  }
}