SFML community forums

Help => Graphics => Topic started by: djzmo on October 03, 2010, 05:11:56 pm

Title: Multiple colors in a text using sf::String?
Post by: djzmo on October 03, 2010, 05:11:56 pm
Hello there,

Is it possible to give a text some different colors by just drawing a sf::String?

For example: Hello world!

The text will be dynamic and prolly long, so I cannot simply make string objects with different colors.

If no, can you tell me an alternative way to do that?

Thanks  :)
Title: Multiple colors in a text using sf::String?
Post by: Hiura on October 03, 2010, 05:29:17 pm
No, not with ONE sf::String/sf::Text. Use a container/class to store all your strings. (Take a look at the wiki, there may be something over there useful.)
Title: Multiple colors in a text using sf::String?
Post by: djzmo on October 03, 2010, 05:56:38 pm
Quote from: "Hiura"
No, not with ONE sf::String/sf::Text. Use a container/class to store all your strings. (Take a look at the wiki, there may be something over there useful.)


Sweet.

So here's the answer to my own question  :P

http://www.sfml-dev.org/wiki/en/sources/richtext

Thanks.
Title: Multiple colors in a text using sf::String?
Post by: panithadrum on October 03, 2010, 07:09:53 pm
Quote from: "djzmo"
Quote from: "Hiura"
No, not with ONE sf::String/sf::Text. Use a container/class to store all your strings. (Take a look at the wiki, there may be something over there useful.)


Sweet.

So here's the answer to my own question  :P

http://www.sfml-dev.org/wiki/en/sources/richtext

Thanks.

I was going to happily spam that wiki entry, but you saw it first! Take care with the '\n' characters. To use multiple lines you should use a stl container or something similar.