2012-07-26 04:04:54 -07:00
|
|
|
RichText
|
|
|
|
========
|
|
|
|
|
|
|
|
Rich text class for [SFML2](https://github.com/LaurentGomila/SFML/). Allows the
|
|
|
|
user to draw lines of text with different styles and colors.
|
|
|
|
|
2012-12-16 11:21:15 -08:00
|
|
|
License
|
|
|
|
-------
|
|
|
|
|
|
|
|
This code is licensed under public domain.
|
|
|
|
|
2014-02-24 10:52:13 -08:00
|
|
|
Authors
|
|
|
|
-------
|
2012-07-26 04:04:54 -07:00
|
|
|
|
|
|
|
* [Cristian Pallarés](https://github.com/Skyrpex) - Original code
|
|
|
|
* [Lukas Dürrenberger](https://github.com/eXpl0it3r/) - Conversion to the new SFML2 API
|
|
|
|
|
|
|
|
How to use
|
|
|
|
----------
|
|
|
|
|
|
|
|
1. Include the header and the source to your project.
|
|
|
|
2. Link to SFML2 (obviously :P!).
|
2014-02-24 10:52:38 -08:00
|
|
|
3. Use a C++11 ready compiler.
|
2012-07-26 04:04:54 -07:00
|
|
|
|
2014-02-24 11:01:41 -08:00
|
|
|
Note: For a non C++11 ready compilers, there is a [support branch](https://github.com/Skyrpex/RichText/tree/support/no-c%2B%2B11).
|
|
|
|
However, it's not guaranteed to be fully updated.
|
|
|
|
|
2012-07-26 04:04:54 -07:00
|
|
|
Repository
|
|
|
|
----------
|
|
|
|
|
|
|
|
You can get the current development version from the [git repository](https://github.com/Skyrpex/RichText).
|
|
|
|
|
|
|
|
Example
|
|
|
|
-------
|
|
|
|
|
|
|
|
#include "RichText.hpp"
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2014-02-24 10:39:00 -08:00
|
|
|
sf::RenderWindow window;
|
|
|
|
window.create(sf::VideoMode(800, 600), "sfe::RichText");
|
|
|
|
window.setFramerateLimit(30);
|
|
|
|
|
|
|
|
sf::Font font;
|
|
|
|
font.loadFromFile("/usr/share/fonts/truetype/freefont/FreeMono.ttf");
|
|
|
|
|
|
|
|
sfe::RichText text(font);
|
|
|
|
text << sf::Text::Bold << sf::Color::Cyan << "This "
|
|
|
|
<< sf::Text::Italic << sf::Color::White << "is\ncool\n"
|
|
|
|
<< sf::Text::Regular << sf::Color::Green << "mate"
|
|
|
|
<< sf::Color::White << ".\n"
|
|
|
|
<< sf::Text::Underlined << "I wish I could lick it!";
|
2012-07-26 04:04:54 -07:00
|
|
|
|
2014-02-24 10:39:00 -08:00
|
|
|
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();
|
2012-07-26 04:04:54 -07:00
|
|
|
}
|
2014-02-24 10:39:00 -08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|