SFML community forums

General => Feature requests => Topic started by: NGM88 on January 06, 2019, 09:26:10 am

Title: Multiple Colors in sf::Text
Post by: NGM88 on January 06, 2019, 09:26:10 am
Would it be possible to have sf::Text use multiple colors? As far as implementation goes, it could hold a vector of strings instead of one and you could do something like

txtObject.addString("str", sf::Color::Red)

instead of just setString().
Title: Re: Multiple Colors in sf::Text
Post by: Nexus on January 06, 2019, 01:44:47 pm
This would lead to a complex formatting feature -- the next request would be to apply style (bold/italics/underline) and size (pt) partially.

It's possible to build such a formatter out of separate sf::Text instances, and it has been done before, IIRC one of them with a markup language similar to HTML. If you look on the forum or the Wiki, you should find such extensions.
Title: Re: Multiple Colors in sf::Text
Post by: eXpl0it3r on January 06, 2019, 02:41:18 pm
There are extension libraries like RichText that provide such features: https://github.com/skyrpex/RichText

I'd say it's not necessarily out of SFML's scope, but since it can be implemented in many ways with certain trade-offs, it's not as simple to pick an API that works for most everyone.