Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Multiple colors in a text using sf::String?  (Read 3937 times)

0 Members and 1 Guest are viewing this topic.

djzmo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Multiple colors in a text using sf::String?
« 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  :)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Multiple colors in a text using sf::String?
« Reply #1 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.)
SFML / OS X developer

djzmo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Multiple colors in a text using sf::String?
« Reply #2 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.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Multiple colors in a text using sf::String?
« Reply #3 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.

 

anything