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

Author Topic: sf::Text coloring chosen characters?  (Read 3075 times)

0 Members and 1 Guest are viewing this topic.

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
sf::Text coloring chosen characters?
« on: April 29, 2012, 04:26:06 pm »
Hello,

is it possible to implement a function that allows to give choosen Characters a special Color...

The problem is that it is to difficult if i work with hundred of sf::Text Objects...
This is the only solution that i can think of... So with my solution i must split the sf::Text Object
in many part sf::Text Objects...

Is there a way to make this easier?
If not, can you implement a function that allows this?

Because a picture says more than thousend words, thats what i want:


I think a function like these:

setCharacterColor(fromCharacterPos, toCharacterPos, newColor)

would be perfect...

Lg

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Text coloring chosen characters?
« Reply #1 on: April 29, 2012, 04:35:55 pm »
It seems like a very specific request, I can't find any use case where one would like to assign colors to specific characters in a text.

Could you tell me more about your use case?
Laurent Gomila - SFML developer

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: sf::Text coloring chosen characters?
« Reply #2 on: April 29, 2012, 05:20:34 pm »
I need it for a syntax highlighter and for a chat... :)

It is difficult and a little bit complicated using my solution for large Strings because of this
I ask here for this feature... don't hate me... :P

Contadotempo

  • Full Member
  • ***
  • Posts: 167
  • Firelink Shrine
    • View Profile
Re: sf::Text coloring chosen characters?
« Reply #3 on: April 29, 2012, 07:13:13 pm »
You could use something like this instead:
http://www.sfml-dev.org/wiki/en/sources/richtext

It's coded for SFML 1.6 but you could easily adapt it to SFML 2.0.

Perde

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: sf::Text coloring chosen characters?
« Reply #4 on: April 29, 2012, 07:16:54 pm »
Why don't you simply post your solution? You might even get a hint or two.