Skip to content

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

License

Notifications You must be signed in to change notification settings

skyrpex/RichText

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RichText

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

Authors

How to use

  1. Include the header and the source to your project.
  2. Link to SFML 2.4.x.
  3. Use a C++11 ready compiler.

Support branches

Notice: There's no guarantee that these branches are fully updated.

Repository

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

Example

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

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "sfe::RichText");
    window.setFramerateLimit(30);

    sf::Font font;
    font.loadFromFile("FreeMono.ttf");

    sfe::RichText text(font);
    text << sf::Text::Bold       << sf::Color::Cyan  << "This "
         << sf::Text::Italic     << sf::Color::White << "is\nan\n"
         << sf::Text::Regular    << sf::Color::Green << "example"
         << sf::Color::White     << ".\n"
         << sf::Text::Underlined << "It looks good!";

    text.setCharacterSize(25);
    text.setPosition(400, 300);
    text.setOrigin(text.getGlobalBounds().width / 2.f, text.getGlobalBounds().height / 2.f);

    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();
    }
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages